Module: FLVTool2
- Defined in:
- lib/flvtool2.rb,
lib/flvtool2/base.rb,
lib/flvtool2/version.rb
Defined Under Namespace
Modules: Base
Constant Summary collapse
- SHELL_COMMAND_NAME =
(RUBY_PLATFORM =~ /win32/) ? 'flvtool2.exe' : 'flvtool2'
- SWITCHES =
%w{ s v r p x c i o k t n l a }
- COMMANDS =
%w{ U C P D A V }
- PROGRAMM_VERSION =
[1, 0, 6]
- PROGRAMM_VERSION_EXTENSION =
''
Class Method Summary collapse
- .execute!(options) ⇒ Object
- .parse_arguments ⇒ Object
- .show_usage ⇒ Object
- .show_version ⇒ Object
- .throw_error(error) ⇒ Object
- .validate_options(options) ⇒ Object
- .version ⇒ Object
Class Method Details
.execute!(options) ⇒ Object
164 165 166 167 168 169 170 |
# File 'lib/flvtool2.rb', line 164 def self.execute!() if [:commands].include? :help show_usage else FLVTool2::Base::execute!( ) end end |
.parse_arguments ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/flvtool2.rb', line 35 def self.parse_arguments = {} [:commands] = [] [:metadatacreator] = "inlet media FLVTool2 v#{PROGRAMM_VERSION.join('.')} - http://www.inlet-media.de/flvtool2" [:metadata] = {} [:in_path] = nil [:in_pipe] = false [:out_path] = nil [:out_pipe] = false [:simulate] = false [:verbose] = false [:recursive] = false [:preserve] = false [:xml] = false [:compatibility_mode] = false [:in_point] = nil [:out_point] = nil [:keyframe_mode] = false [:tag_file] = nil [:tag_number] = nil [:stream_log] = false [:collapse] = false while (arg = ARGV.shift) case arg when /^-([a-zA-Z0-9]+?):(.+)$/ [:metadata][$1] = $2 when /^-([a-zA-Z0-9]+?)#([0-9]+)$/ [:metadata][$1] = $2.to_f when /^-([a-zA-Z0-9]+?)@(\d{4,})-(\d{2,})-(\d{2,}) (\d{2,}):(\d{2,}):(\d{2,})$/ [:metadata][$1] = Time.local($2, $3, $4, $5, $6, $7) when /^-(.+)$/ $1.split(//).flatten.each do |switch| case switch when 's' [:simulate] = true when 'v' [:verbose] = true when 'r' [:recursive] = true when 'p' [:preserve] = true when 'x' [:xml] = true when 'c' [:compatibility_mode] = true when 'i' [:in_point] = ARGV.shift.to_i when 'o' [:out_point] = ARGV.shift.to_i when 'k' [:keyframe_mode] = true when 't' [:tag_file] = ARGV.shift when 'n' [:tag_number] = ARGV.shift.to_i when 'l' [:stream_log] = true when 'a' [:collapse] = true when 'U' [:commands] << :update when 'P' [:commands] << :print when 'C' [:commands] << :cut when 'D' [:commands] << :debug when 'A' [:commands] << :add when 'H' [:commands] << :help when 'V' [:commands] << :version end end when /^([^-].*)$/ if [:in_path].nil? [:in_path] = $1 if [:in_path].downcase =~ /stdin|pipe/ [:in_pipe] = true [:in_path] = 'pipe' else [:in_path] = File.( [:in_path] ) end else [:out_path] = $1 if [:out_path].downcase =~ /stdout|pipe/ [:out_pipe] = true [:out_path] = 'pipe' else [:out_path] = File.( [:out_path] ) end end end end return end |
.show_usage ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/flvtool2.rb', line 176 def self.show_usage self.show_version puts "Copyright (c) 2005-2007 Norman Timmler (inlet media e.K., Hamburg, Germany)\n" puts "Get the latest version from http://www.inlet-media.de/flvtool2\n" puts "This program is published under the BSD license.\n" puts "\n" puts "Usage: #{SHELL_COMMAND_NAME} [-#{COMMANDS.sort.join}#{SWITCHES.sort.join}]... [-key:value]... in-path|stdin [out-path|stdout]\n" puts "\n" puts "If out-path is omitted, in-path will be overwritten.\n" puts "In-path can be a single file, or a directory. If in-path is a directory,\n" puts "out-path has to be likewise, or can be omitted. Directory recursion\n" puts "is controlled by the -r switch. You can use stdin and stdout keywords\n" puts "as in- and out-path for piping or redirecting.\n" puts "\n" puts "Chain commands like that: -UP (updates FLV file than prints out meta data)\n" puts "\n" puts "Commands:\n" puts " -A Adds tags from -t tags-file\n" puts " -C Cuts file using -i inpoint and -o outpoint\n" puts " -D Debugs file (writes a lot to stdout)\n" puts " -H Helpscreen will be shown\n" puts " -P Prints out meta data to stdout\n" puts " -U Updates FLV with an onMetaTag event\n" puts "\n" puts "Switches:\n" puts " -a Collapse space between cutted regions\n" puts " -c Compatibility mode calculates some onMetaTag values different\n" puts " -key:value Key-value-pair for onMetaData tag (overwrites generated values)\n" puts " -i timestamp Inpoint for cut command in miliseconds\n" puts " -k Keyframe mode slides onCuePoint(navigation) tags added by the\n" puts " add command to nearest keyframe position\n" puts " -l Logs FLV stream reading to stream.log in current directory\n" puts " -n Number of tag to debug\n" puts " -o timestamp Outpoint for cut command in miliseconds\n" puts " -p Preserve mode only updates FLVs that have not been processed\n" puts " before\n" puts " -r Recursion for directory processing\n" puts " -s Simulation mode never writes FLV data to out-path\n" puts " -t path Tagfile (MetaTags written in XML)\n" puts " -v Verbose mode\n" puts " -x XML mode instead of YAML mode\n" puts "\n" puts "REPORT BUGS at http://projects.inlet-media.de/flvtool2" puts "Powered by Riva VX, http://rivavx.com\n" end |
.show_version ⇒ Object
172 173 174 |
# File 'lib/flvtool2.rb', line 172 def self.show_version puts "FLVTool2 #{version}" end |
.throw_error(error) ⇒ Object
222 223 224 |
# File 'lib/flvtool2.rb', line 222 def self.throw_error(error) puts "ERROR: #{error}" end |
.validate_options(options) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/flvtool2.rb', line 135 def self.( ) if [:commands].empty? show_usage exit 0 end [:commands].each do |command| case command when :print if [:out_pipe] throw_error "Could not use print command in conjunction with output piping or redirection" exit 1 end when :debug if [:out_pipe] throw_error "Could not use debug command in conjunction with output piping or redirection" exit 1 end when :help show_usage exit 0 when :version show_version exit 0 end end end |
.version ⇒ Object
6 7 8 |
# File 'lib/flvtool2/version.rb', line 6 def self.version "#{PROGRAMM_VERSION.join('.')}#{PROGRAMM_VERSION_EXTENSION}" end |