jagthedrummer-rvideo 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/lib/rvideo/errors.rb +24 -0
  2. data/lib/rvideo/float.rb +7 -0
  3. data/lib/rvideo/inspector.rb +528 -0
  4. data/lib/rvideo/reporter/views/index.html.erb +27 -0
  5. data/lib/rvideo/reporter/views/report.css +27 -0
  6. data/lib/rvideo/reporter/views/report.html.erb +81 -0
  7. data/lib/rvideo/reporter/views/report.js +9 -0
  8. data/lib/rvideo/reporter.rb +176 -0
  9. data/lib/rvideo/string.rb +5 -0
  10. data/lib/rvideo/tools/abstract_tool.rb +393 -0
  11. data/lib/rvideo/tools/ffmpeg.rb +273 -0
  12. data/lib/rvideo/tools/ffmpeg2theora.rb +42 -0
  13. data/lib/rvideo/tools/flvtool2.rb +50 -0
  14. data/lib/rvideo/tools/mencoder.rb +103 -0
  15. data/lib/rvideo/tools/mp4box.rb +21 -0
  16. data/lib/rvideo/tools/mp4creator.rb +35 -0
  17. data/lib/rvideo/tools/mplayer.rb +31 -0
  18. data/lib/rvideo/tools/yamdi.rb +44 -0
  19. data/lib/rvideo/transcoder.rb +120 -0
  20. data/lib/rvideo/version.rb +9 -0
  21. data/lib/rvideo.rb +42 -0
  22. data/spec/files/boat.avi +0 -0
  23. data/spec/files/kites.mp4 +0 -0
  24. data/spec/fixtures/ffmpeg_builds.yml +28 -0
  25. data/spec/fixtures/ffmpeg_results.yml +608 -0
  26. data/spec/fixtures/files.yml +398 -0
  27. data/spec/fixtures/recipes.yml +58 -0
  28. data/spec/integrations/formats_spec.rb +315 -0
  29. data/spec/integrations/inspection_spec.rb +112 -0
  30. data/spec/integrations/recipes_spec.rb +0 -0
  31. data/spec/integrations/rvideo_spec.rb +17 -0
  32. data/spec/integrations/transcoder_integration_spec.rb +53 -0
  33. data/spec/integrations/transcoding_spec.rb +9 -0
  34. data/spec/spec.opts +1 -0
  35. data/spec/spec_helper.rb +16 -0
  36. data/spec/support.rb +36 -0
  37. data/spec/units/abstract_tool_spec.rb +111 -0
  38. data/spec/units/ffmpeg_spec.rb +311 -0
  39. data/spec/units/flvtool2_spec.rb +324 -0
  40. data/spec/units/inspector_spec.rb +103 -0
  41. data/spec/units/mencoder_spec.rb +4994 -0
  42. data/spec/units/mp4box_spec.rb +34 -0
  43. data/spec/units/mp4creator_spec.rb +34 -0
  44. data/spec/units/mplayer_spec.rb +34 -0
  45. data/spec/units/string_spec.rb +8 -0
  46. data/spec/units/transcoder_spec.rb +156 -0
  47. metadata +110 -0
@@ -0,0 +1,311 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ def setup_ffmpeg_spec
4
+ @options = {
5
+ :input_file => spec_file("kites.mp4"),
6
+ :output_file => "bar",
7
+ :width => "320", :height => "240"
8
+ }
9
+ @simple_avi = "ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$"
10
+ @ffmpeg = RVideo::Tools::Ffmpeg.new(@simple_avi, @options)
11
+ end
12
+
13
+ def parsing_result(result_fixture_key)
14
+ lambda { @ffmpeg.send(:parse_result, ffmpeg_result(result_fixture_key)) }
15
+ end
16
+
17
+ module RVideo
18
+ module Tools
19
+
20
+ describe Ffmpeg do
21
+ before do
22
+ setup_ffmpeg_spec
23
+ end
24
+
25
+ it "should initialize with valid arguments" do
26
+ @ffmpeg.class.should == Ffmpeg
27
+ end
28
+
29
+ it "should have the correct tool_command" do
30
+ @ffmpeg.tool_command.should == 'ffmpeg'
31
+ end
32
+
33
+ it "should call parse_result on execute, with a ffmpeg result string" do
34
+ @ffmpeg.should_receive(:parse_result).once.with /\AFFmpeg version/
35
+ @ffmpeg.execute
36
+ end
37
+
38
+ it "should mixin AbstractTool" do
39
+ Ffmpeg.included_modules.include?(AbstractTool::InstanceMethods).should be_true
40
+ end
41
+
42
+ it "should set supported options successfully" do
43
+ @ffmpeg.options[:resolution].should == @options[:resolution]
44
+ @ffmpeg.options[:input_file].should == @options[:input_file]
45
+ @ffmpeg.options[:output_file].should == @options[:output_file]
46
+ end
47
+
48
+ end
49
+
50
+ describe Ffmpeg, " magic variables" do
51
+ before do
52
+ @options = {
53
+ :input_file => spec_file("boat.avi"),
54
+ :output_file => "test"
55
+ }
56
+
57
+ Ffmpeg.video_bit_rate_parameter = Ffmpeg::DEFAULT_VIDEO_BIT_RATE_PARAMETER
58
+ end
59
+
60
+ it 'supports copying the originsl :fps' do
61
+ @options.merge! :fps => "copy"
62
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame $fps$ -s 320x240 -y $output_file$", @options)
63
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 15.10 -s 320x240 -y '#{@options[:output_file]}'"
64
+ end
65
+
66
+ it 'supports :width and :height options to build :resolution' do
67
+ @options.merge! :width => "640", :height => "360"
68
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$", @options)
69
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 -s 640x360 -y '#{@options[:output_file]}'"
70
+ end
71
+
72
+ it 'supports calculated :height' do
73
+ @options.merge! :width => "640"
74
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$", @options)
75
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 -s 640x480 -y '#{@options[:output_file]}'"
76
+ end
77
+
78
+ it 'supports calculated :width' do
79
+ @options.merge! :height => "360"
80
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$", @options)
81
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 -s 480x360 -y '#{@options[:output_file]}'"
82
+ end
83
+
84
+ ###
85
+
86
+ it 'supports :video_bit_rate' do
87
+ @options.merge! :video_bit_rate => 666
88
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_bit_rate$ -y $output_file$", @options)
89
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 666k -y '#{@options[:output_file]}'"
90
+ end
91
+
92
+ it "supports :video_bit_rate and configurable command flag" do
93
+ Ffmpeg.video_bit_rate_parameter = "v"
94
+ @options.merge! :video_bit_rate => 666
95
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_bit_rate$ -y $output_file$", @options)
96
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -v 666k -y '#{@options[:output_file]}'"
97
+ end
98
+
99
+ ###
100
+
101
+ it "supports :video_bit_rate_tolerance" do
102
+ @options.merge! :video_bit_rate_tolerance => 666
103
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_bit_rate_tolerance$ -y $output_file$", @options)
104
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -bt 666k -y '#{@options[:output_file]}'"
105
+ end
106
+
107
+ ###
108
+
109
+ it "supports :video_bit_rate_max and :video_bit_rate_min" do
110
+ @options.merge! :video_bit_rate => 666, :video_bit_rate_min => 666, :video_bit_rate_max => 666
111
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_bit_rate$ $video_bit_rate_min$ $video_bit_rate_max$ -y $output_file$", @options)
112
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 666k -minrate 666k -maxrate 666k -y '#{@options[:output_file]}'"
113
+ end
114
+
115
+ ###
116
+
117
+ # TODO for these video quality specs we might want to show that the expected
118
+ # bitrate is calculated based on dimensions and framerate so you can better
119
+ # understand it without going to the source.
120
+
121
+ it "supports :video_quality => 'low'" do
122
+ @options.merge! :video_quality => "low"
123
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
124
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 96k -crf 30 -me zero -subq 1 -refs 1 -threads auto -y '#{@options[:output_file]}'"
125
+ end
126
+
127
+ it "supports :video_quality => 'medium'" do
128
+ @options.merge! :video_quality => "medium"
129
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
130
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 128k -crf 22 -flags +loop -cmp +sad -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me hex -subq 3 -trellis 1 -refs 2 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -y '#{@options[:output_file]}'"
131
+ end
132
+
133
+ it "supports :video_quality => 'high'" do
134
+ @options.merge! :video_quality => "high"
135
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
136
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 322k -crf 18 -flags +loop -cmp +sad -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me full -subq 6 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -y '#{@options[:output_file]}'"
137
+ end
138
+
139
+ ###
140
+
141
+ it "supports :video_quality => 'low' with arbitrary :video_bit_rate" do
142
+ @options.merge! :video_quality => "low", :video_bit_rate => 666
143
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
144
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 666k -crf 30 -me zero -subq 1 -refs 1 -threads auto -y '#{@options[:output_file]}'"
145
+ end
146
+
147
+ it "supports :video_quality => 'medium' with arbitrary :video_bit_rate" do
148
+ @options.merge! :video_quality => "medium", :video_bit_rate => 666
149
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
150
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 666k -crf 22 -flags +loop -cmp +sad -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me hex -subq 3 -trellis 1 -refs 2 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -y '#{@options[:output_file]}'"
151
+ end
152
+
153
+ it "supports :video_quality => 'high' with arbitrary :video_bit_rate" do
154
+ @options.merge! :video_quality => "high", :video_bit_rate => 666
155
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ $video_quality$ -y $output_file$", @options)
156
+ ffmpeg.command.should == "ffmpeg -i '#{@options[:input_file]}' -b 666k -crf 18 -flags +loop -cmp +sad -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs -me full -subq 6 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -y '#{@options[:output_file]}'"
157
+ end
158
+
159
+ # These appear unsupported..
160
+ #
161
+ # it 'should support passthrough height' do
162
+ # options = {:input_file => spec_file("kites.mp4"), :output_file => "bar", :width => "640"}
163
+ # command = "ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$"
164
+ # ffmpeg = Ffmpeg.new(command, options)
165
+ # ffmpeg.command.should == "ffmpeg -i '#{options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 -s 640x720 -y 'bar'"
166
+ # end
167
+ #
168
+ # it 'should support passthrough width' do
169
+ # options = {:input_file => spec_file("kites.mp4"), :output_file => "bar", :height => "360"}
170
+ # command = "ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 $resolution$ -y $output_file$"
171
+ # ffmpeg = Ffmpeg.new(command, options)
172
+ # ffmpeg.command.should == "ffmpeg -i '#{options[:input_file]}' -ar 44100 -ab 64 -vcodec xvid -acodec libmp3lame -r 29.97 -s 1280x360 -y 'bar'"
173
+ # end
174
+ end
175
+
176
+ describe Ffmpeg, " when parsing a result" do
177
+ before do
178
+ setup_ffmpeg_spec
179
+
180
+ @result = ffmpeg_result(:result1)
181
+ @result2 = ffmpeg_result(:result2)
182
+ @result3 = ffmpeg_result(:result3)
183
+ @result4 = ffmpeg_result(:result4)
184
+ end
185
+
186
+ it "should create correct result metadata" do
187
+ @ffmpeg.send(:parse_result, @result).should be_true
188
+ @ffmpeg.frame.should == '4126'
189
+ @ffmpeg.output_fps.should be_nil
190
+ @ffmpeg.q.should == '31.0'
191
+ @ffmpeg.size.should == '5917kB'
192
+ @ffmpeg.time.should == '69.1'
193
+ @ffmpeg.output_bitrate.should == '702.0kbits/s'
194
+ @ffmpeg.video_size.should == "2417kB"
195
+ @ffmpeg.audio_size.should == "540kB"
196
+ @ffmpeg.header_size.should == "0kB"
197
+ @ffmpeg.overhead.should == "100.140277%"
198
+ @ffmpeg.psnr.should be_nil
199
+ end
200
+
201
+ it "should create correct result metadata (2)" do
202
+ @ffmpeg.send(:parse_result, @result2).should be_true
203
+ @ffmpeg.frame.should == '584'
204
+ @ffmpeg.output_fps.should be_nil
205
+ @ffmpeg.q.should == '6.0'
206
+ @ffmpeg.size.should == '708kB'
207
+ @ffmpeg.time.should == '19.5'
208
+ @ffmpeg.output_bitrate.should == '297.8kbits/s'
209
+ @ffmpeg.video_size.should == "49kB"
210
+ @ffmpeg.audio_size.should == "153kB"
211
+ @ffmpeg.header_size.should == "0kB"
212
+ @ffmpeg.overhead.should == "250.444444%"
213
+ @ffmpeg.psnr.should be_nil
214
+ end
215
+
216
+ it "should create correct result metadata (3)" do
217
+ @ffmpeg.send(:parse_result, @result3).should be_true
218
+ @ffmpeg.frame.should == '273'
219
+ @ffmpeg.output_fps.should == "31"
220
+ @ffmpeg.q.should == '10.0'
221
+ @ffmpeg.size.should == '398kB'
222
+ @ffmpeg.time.should == '5.9'
223
+ @ffmpeg.output_bitrate.should == '551.8kbits/s'
224
+ @ffmpeg.video_size.should == "284kB"
225
+ @ffmpeg.audio_size.should == "92kB"
226
+ @ffmpeg.header_size.should == "0kB"
227
+ @ffmpeg.overhead.should == "5.723981%"
228
+ @ffmpeg.psnr.should be_nil
229
+ end
230
+
231
+ it "should create correct result metadata (4)" do
232
+ @ffmpeg.send(:parse_result, @result4).should be_true
233
+ @ffmpeg.frame.should be_nil
234
+ @ffmpeg.output_fps.should be_nil
235
+ @ffmpeg.q.should be_nil
236
+ @ffmpeg.size.should == '1080kB'
237
+ @ffmpeg.time.should == '69.1'
238
+ @ffmpeg.output_bitrate.should == '128.0kbits'
239
+ @ffmpeg.video_size.should == "0kB"
240
+ @ffmpeg.audio_size.should == "1080kB"
241
+ @ffmpeg.header_size.should == "0kB"
242
+ @ffmpeg.overhead.should == "0.002893%"
243
+ @ffmpeg.psnr.should be_nil
244
+ end
245
+
246
+ it "ffmpeg should calculate PSNR if it is turned on" do
247
+ @ffmpeg.send(:parse_result, @result.gsub("Lsize=","LPSNR=Y:33.85 U:37.61 V:37.46 *:34.77 size=")).should be_true
248
+ @ffmpeg.psnr.should == "Y:33.85 U:37.61 V:37.46 *:34.77"
249
+ end
250
+ end
251
+
252
+ context Ffmpeg, "result parsing should raise an exception" do
253
+ setup do
254
+ setup_ffmpeg_spec
255
+ @results = load_fixture :ffmpeg_results
256
+ end
257
+
258
+ specify "when a param is missing a value" do
259
+ parsing_result(:param_missing_value).
260
+ should raise_error(TranscoderError::InvalidCommand, /Expected .+ for .+ but found: .+/)
261
+ end
262
+
263
+ specify "when codec not supported" do
264
+ parsing_result(:amr_nb_not_supported).
265
+ should raise_error(TranscoderError::InvalidFile, "Codec amr_nb not supported by this build of ffmpeg")
266
+ end
267
+
268
+ specify "when not passed a command" do
269
+ parsing_result(:missing_command).
270
+ should raise_error(TranscoderError::InvalidCommand, "must pass a command to ffmpeg")
271
+ end
272
+
273
+ specify "when given a broken command" do
274
+ parsing_result(:broken_command).
275
+ should raise_error(TranscoderError::InvalidCommand, "Unable for find a suitable output format for 'foo'")
276
+ end
277
+
278
+ specify "when the output file has no streams" do
279
+ parsing_result(:output_has_no_streams).
280
+ should raise_error(TranscoderError, /Output file does not contain.*stream/)
281
+ end
282
+
283
+ specify "when given a missing input file" do
284
+ parsing_result(:missing_input_file).
285
+ should raise_error(TranscoderError::InvalidFile, /I\/O error: .+/)
286
+ end
287
+
288
+ specify "when given a file it can't handle"
289
+
290
+ specify "when cancelled halfway through"
291
+
292
+ specify "when receiving unexpected results" do
293
+ parsing_result(:unexpected_results).
294
+ should raise_error(TranscoderError::UnexpectedResult, 'foo - bar')
295
+ end
296
+
297
+ specify "with an unsupported codec" do
298
+ @ffmpeg.original = Inspector.new(:raw_response => files('kites2'))
299
+
300
+ parsing_result(:unsupported_codec).
301
+ should raise_error(TranscoderError::InvalidFile, /samr/)
302
+ end
303
+
304
+ specify "when a stream cannot be written" do
305
+ parsing_result(:unwritable_stream).
306
+ should raise_error(TranscoderError, /flv doesnt support.*incorrect codec/)
307
+ end
308
+
309
+ end
310
+ end
311
+ end
@@ -0,0 +1,324 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ module Tools
5
+
6
+ describe Flvtool2 do
7
+ before do
8
+ setup_flvtool2_spec
9
+ end
10
+
11
+ it "should initialize with valid arguments" do
12
+ @flvtool2.class.should == Flvtool2
13
+ end
14
+
15
+ it "should have the correct tool_command" do
16
+ @flvtool2.tool_command.should == 'flvtool2'
17
+ end
18
+
19
+ it "should call parse_result on execute, with a result string" do
20
+ @flvtool2.stub!(:do_execute)
21
+ @flvtool2.stub!(:populate_raw_result) # avoid `tail` barfing because there's no log file
22
+ @flvtool2.should_receive(:parse_result).once #.with /\AERROR: No such file or directory/
23
+ @flvtool2.execute
24
+ end
25
+
26
+ it "should mixin AbstractTool" do
27
+ Flvtool2.included_modules.include?(AbstractTool::InstanceMethods).should be_true
28
+ end
29
+
30
+ it "should set supported options successfully" do
31
+ @flvtool2.options[:temp_file].should == @options[:temp_file]
32
+ @flvtool2.options[:output_file].should == @options[:output_file]
33
+ end
34
+
35
+ end
36
+
37
+ describe Flvtool2, " when parsing a result" do
38
+ before do
39
+ setup_flvtool2_spec
40
+ end
41
+
42
+ it "should set metadata if called with -P option" do
43
+ @flvtool2.send(:parse_result, @metadata_result).should be_true
44
+ @flvtool2.raw_metadata.should == @metadata_result
45
+ end
46
+
47
+ it "should succeed but not set metadata without -P option" do
48
+ @flvtool2.send(:parse_result,"").should be_true
49
+ end
50
+ end
51
+
52
+ context Flvtool2, " result parsing should raise an exception" do
53
+
54
+ setup do
55
+ setup_flvtool2_spec
56
+ end
57
+
58
+ specify "when not passed a command" do
59
+ lambda {
60
+ @flvtool2.send(:parse_result, @helptext)
61
+ }.should raise_error(TranscoderError::InvalidCommand, /flvtool2 help text/)
62
+ end
63
+
64
+ specify "when receiving an empty file" do
65
+ lambda {
66
+ @flvtool2.send(:parse_result, @empty_file)
67
+ }.should raise_error(TranscoderError::InvalidFile, /Output file was empty/)
68
+ end
69
+
70
+ specify "when passed an invalid input file" do
71
+ lambda {
72
+ @flvtool2.send(:parse_result, @non_flv_input)
73
+ }.should raise_error(TranscoderError::InvalidFile, "input must be a valid FLV file")
74
+ end
75
+
76
+ specify "when input file not found" do
77
+ lambda {
78
+ @flvtool2.send(:parse_result, @no_input_file)
79
+ }.should raise_error(TranscoderError::InputFileNotFound, /^ERROR: No such file or directory/)
80
+ end
81
+
82
+ specify "when receiving unexpected results" do
83
+ lambda {
84
+ @flvtool2.send(:parse_result, @unexpected_results)
85
+ }.should raise_error(TranscoderError::UnexpectedResult, /ffmpeg/i)
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ def setup_flvtool2_spec
92
+ @options = {:temp_file => "foo", :output_file => "bar"}
93
+ @command = "flvtool2 -U $temp_file$ $output_file$"
94
+ @flvtool2 = RVideo::Tools::Flvtool2.new(@command, @options)
95
+
96
+ @helptext = "FLVTool2 1.0.6
97
+ Copyright (c) 2005-2007 Norman Timmler (inlet media e.K., Hamburg, Germany)
98
+ Get the latest version from http://www.inlet-media.de/flvtool2
99
+ This program is published under the BSD license.
100
+
101
+ Usage: flvtool2 [-ACDPUVaciklnoprstvx]... [-key:value]... in-path|stdin [out-path|stdout]
102
+
103
+ If out-path is omitted, in-path will be overwritten.
104
+ In-path can be a single file, or a directory. If in-path is a directory,
105
+ out-path has to be likewise, or can be omitted. Directory recursion
106
+ is controlled by the -r switch. You can use stdin and stdout keywords
107
+ as in- and out-path for piping or redirecting.
108
+
109
+ Chain commands like that: -UP (updates FLV file than prints out meta data)
110
+
111
+ Commands:
112
+ -A Adds tags from -t tags-file
113
+ -C Cuts file using -i inpoint and -o outpoint
114
+ -D Debugs file (writes a lot to stdout)
115
+ -H Helpscreen will be shown
116
+ -P Prints out meta data to stdout
117
+ -U Updates FLV with an onMetaTag event
118
+
119
+ Switches:
120
+ -a Collapse space between cutted regions
121
+ -c Compatibility mode calculates some onMetaTag values different
122
+ -key:value Key-value-pair for onMetaData tag (overwrites generated values)
123
+ -i timestamp Inpoint for cut command in miliseconds
124
+ -k Keyframe mode slides onCuePoint(navigation) tags added by the
125
+ add command to nearest keyframe position
126
+ -l Logs FLV stream reading to stream.log in current directory
127
+ -n Number of tag to debug
128
+ -o timestamp Outpoint for cut command in miliseconds
129
+ -p Preserve mode only updates FLVs that have not been processed
130
+ before
131
+ -r Recursion for directory processing
132
+ -s Simulation mode never writes FLV data to out-path
133
+ -t path Tagfile (MetaTags written in XML)
134
+ -v Verbose mode
135
+ -x XML mode instead of YAML mode
136
+
137
+ REPORT BUGS at http://projects.inlet-media.de/flvtool2
138
+ Powered by Riva VX, http://rivavx.com"
139
+
140
+ @non_flv_input = "ERROR: IO is not a FLV stream. Wrong signature.
141
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:393:in `read_header'
142
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:57:in `initialize'
143
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:272:in `new'
144
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:272:in `open_stream'
145
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:238:in `process_files'
146
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `each'
147
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `process_files'
148
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:44:in `execute!'
149
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:168:in `execute!'
150
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:228
151
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
152
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
153
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/bin/flvtool2:2
154
+ ERROR: /opt/local/bin/flvtool2:18:in `load'
155
+ ERROR: /opt/local/bin/flvtool2:18"
156
+
157
+ @no_input_file = "ERROR: No such file or directory - /Users/jon/code/spinoza/rvideo/foobar
158
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `initialize'
159
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `open'
160
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `open_stream'
161
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:238:in `process_files'
162
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `each'
163
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `process_files'
164
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:44:in `execute!'
165
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:168:in `execute!'
166
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:228
167
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
168
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
169
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/bin/flvtool2:2
170
+ ERROR: /opt/local/bin/flvtool2:18:in `load'
171
+ ERROR: /opt/local/bin/flvtool2:18"
172
+
173
+ @unexpected_results = "FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
174
+ Mac OSX universal build for ffmpegX
175
+ configuration: --enable-memalign-hack --enable-mp3lame --enable-gpl --disable-vhook --disable-ffplay --disable-ffserver --enable-a52 --enable-xvid --enable-faac --enable-faad --enable-amr_nb --enable-amr_wb --enable-pthreads --enable-x264
176
+ libavutil version: 49.0.0
177
+ libavcodec version: 51.9.0
178
+ libavformat version: 50.4.0
179
+ built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250)
180
+
181
+ Seems that stream 1 comes from film source: 600.00 (600/1) -> 59.75 (239/4)
182
+ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'jobjob2.mov':
183
+ Duration: 00:01:09.0, start: 0.000000, bitrate: 28847 kb/s
184
+ Stream #0.0(eng): Audio: aac, 44100 Hz, stereo
185
+ Stream #0.1(eng), 59.75 fps(r): Video: dvvideo, yuv411p, 720x480
186
+ Stream mapping:
187
+ Stream #0.1 -> #0.0
188
+ Stream #0.0 -> #0.1
189
+ Press [q] to stop encoding"
190
+
191
+ @empty_file = "ERROR: undefined method `timestamp' for nil:NilClass ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:285:in `lasttimestamp' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:274:in `duration' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:181:in `add_meta_data_tag' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:137:in `update' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:47:in `send' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:47:in `execute!' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:46:in `each' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:46:in `execute!' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:239:in `process_files' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `each' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `process_files' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:44:in `execute!' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:168:in `execute!' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:228 ERROR: /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' ERROR: /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require' ERROR: /var/lib/gems/1.8/gems/flvtool2-1.0.6/bin/flvtool2:2 ERROR: /var/lib/gems/1.8/bin/flvtool2:18:in `load' ERROR: /var/lib/gems/1.8/bin/flvtool2:18"
192
+
193
+ @metadata_result = "---
194
+ /Users/jon/code/spinoza/rvideo/temp.flv:
195
+ hasKeyframes: true
196
+ cuePoints:
197
+ audiodatarate: 64.8512825785226
198
+ hasVideo: true
199
+ stereo: false
200
+ canSeekToEnd: false
201
+ framerate: 30
202
+ audiosamplerate: 44000
203
+ videocodecid: 2
204
+ datasize: 992710
205
+ lasttimestamp: 19.453
206
+ audiosamplesize: 16
207
+ audiosize: 165955
208
+ hasAudio: true
209
+ audiodelay: 0
210
+ videosize: 825165
211
+ metadatadate: Fri Sep 14 13:25:58 GMT-0500 2007
212
+ metadatacreator: inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2
213
+ lastkeyframetimestamp: 19.219
214
+ height: 240
215
+ filesize: 998071
216
+ hasMetadata: true
217
+ keyframes:
218
+ times:
219
+ - 0
220
+ - 0.4
221
+ - 0.801
222
+ - 1.201
223
+ - 1.602
224
+ - 2.002
225
+ - 2.402
226
+ - 2.803
227
+ - 3.203
228
+ - 3.604
229
+ - 4.004
230
+ - 4.404
231
+ - 4.805
232
+ - 5.205
233
+ - 5.606
234
+ - 6.006
235
+ - 6.406
236
+ - 6.807
237
+ - 7.207
238
+ - 7.608
239
+ - 8.008
240
+ - 8.408
241
+ - 8.809
242
+ - 9.209
243
+ - 9.61
244
+ - 10.01
245
+ - 10.41
246
+ - 10.811
247
+ - 11.211
248
+ - 11.612
249
+ - 12.012
250
+ - 12.412
251
+ - 12.813
252
+ - 13.213
253
+ - 13.614
254
+ - 14.014
255
+ - 14.414
256
+ - 14.815
257
+ - 15.215
258
+ - 15.616
259
+ - 16.016
260
+ - 16.416
261
+ - 16.817
262
+ - 17.217
263
+ - 17.618
264
+ - 18.018
265
+ - 18.418
266
+ - 18.819
267
+ - 19.219
268
+ filepositions:
269
+ - 1573
270
+ - 24627
271
+ - 56532
272
+ - 90630
273
+ - 137024
274
+ - 185134
275
+ - 225110
276
+ - 262990
277
+ - 291508
278
+ - 330947
279
+ - 370739
280
+ - 398621
281
+ - 426203
282
+ - 448515
283
+ - 468895
284
+ - 488660
285
+ - 508208
286
+ - 523991
287
+ - 541463
288
+ - 558463
289
+ - 572248
290
+ - 590480
291
+ - 604788
292
+ - 620959
293
+ - 632658
294
+ - 645806
295
+ - 655949
296
+ - 668266
297
+ - 684172
298
+ - 697064
299
+ - 713306
300
+ - 728607
301
+ - 746615
302
+ - 760836
303
+ - 774867
304
+ - 790766
305
+ - 804779
306
+ - 821676
307
+ - 843681
308
+ - 857278
309
+ - 873427
310
+ - 888404
311
+ - 900958
312
+ - 914336
313
+ - 927537
314
+ - 941037
315
+ - 958188
316
+ - 974841
317
+ - 988796
318
+ audiocodecid: 2
319
+ videodatarate: 336.705289672544
320
+ duration: 19.486
321
+ hasCuePoints: false
322
+ width: 320
323
+ ..."
324
+ end