stlondemand-rvideo 0.9.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGELOG +70 -0
  2. data/ENV +100 -0
  3. data/ENV2 +129 -0
  4. data/LICENSE +20 -0
  5. data/Manifest +72 -0
  6. data/README +106 -0
  7. data/RULES +11 -0
  8. data/Rakefile +63 -0
  9. data/config/boot.rb +25 -0
  10. data/lib/rvideo.rb +49 -0
  11. data/lib/rvideo/command_executor.rb +91 -0
  12. data/lib/rvideo/errors.rb +24 -0
  13. data/lib/rvideo/float.rb +7 -0
  14. data/lib/rvideo/frame_capturer.rb +139 -0
  15. data/lib/rvideo/inspector.rb +519 -0
  16. data/lib/rvideo/reporter.rb +176 -0
  17. data/lib/rvideo/reporter/views/index.html.erb +27 -0
  18. data/lib/rvideo/reporter/views/report.css +27 -0
  19. data/lib/rvideo/reporter/views/report.html.erb +81 -0
  20. data/lib/rvideo/reporter/views/report.js +9 -0
  21. data/lib/rvideo/string.rb +5 -0
  22. data/lib/rvideo/tools/abstract_tool.rb +459 -0
  23. data/lib/rvideo/tools/ffmpeg.rb +314 -0
  24. data/lib/rvideo/tools/ffmpeg2theora.rb +72 -0
  25. data/lib/rvideo/tools/flvtool2.rb +50 -0
  26. data/lib/rvideo/tools/handbrakecli.rb +61 -0
  27. data/lib/rvideo/tools/lame.rb +58 -0
  28. data/lib/rvideo/tools/mencoder.rb +126 -0
  29. data/lib/rvideo/tools/mp4box.rb +21 -0
  30. data/lib/rvideo/tools/mp4creator.rb +35 -0
  31. data/lib/rvideo/tools/mplayer.rb +31 -0
  32. data/lib/rvideo/tools/qtfaststart.rb +37 -0
  33. data/lib/rvideo/tools/segmenter.rb +29 -0
  34. data/lib/rvideo/tools/yamdi.rb +44 -0
  35. data/lib/rvideo/transcoder.rb +170 -0
  36. data/lib/rvideo/version.rb +9 -0
  37. data/scripts/txt2html +67 -0
  38. data/spec/files/boat.avi +0 -0
  39. data/spec/files/kites.mp4 +0 -0
  40. data/spec/fixtures/ffmpeg_builds.yml +28 -0
  41. data/spec/fixtures/ffmpeg_results.yml +608 -0
  42. data/spec/fixtures/files.yml +398 -0
  43. data/spec/fixtures/recipes.yml +58 -0
  44. data/spec/integrations/formats_spec.rb +315 -0
  45. data/spec/integrations/frame_capturer_spec.rb +26 -0
  46. data/spec/integrations/inspection_spec.rb +125 -0
  47. data/spec/integrations/recipes_spec.rb +0 -0
  48. data/spec/integrations/rvideo_spec.rb +17 -0
  49. data/spec/integrations/transcoder_integration_spec.rb +29 -0
  50. data/spec/integrations/transcoding_spec.rb +9 -0
  51. data/spec/spec.opts +1 -0
  52. data/spec/spec_helper.rb +16 -0
  53. data/spec/support.rb +36 -0
  54. data/spec/units/abstract_tool_spec.rb +111 -0
  55. data/spec/units/command_executor_spec.rb +106 -0
  56. data/spec/units/ffmpeg_spec.rb +385 -0
  57. data/spec/units/flvtool2_spec.rb +323 -0
  58. data/spec/units/frame_capturer_spec.rb +71 -0
  59. data/spec/units/inspector_spec.rb +59 -0
  60. data/spec/units/mencoder_spec.rb +4994 -0
  61. data/spec/units/mp4box_spec.rb +34 -0
  62. data/spec/units/mp4creator_spec.rb +34 -0
  63. data/spec/units/mplayer_spec.rb +34 -0
  64. data/spec/units/qtfaststart_spec.rb +35 -0
  65. data/spec/units/string_spec.rb +8 -0
  66. data/spec/units/transcoder_spec.rb +154 -0
  67. data/stlondemand-rvideo.gemspec +36 -0
  68. data/tasks/deployment.rake +5 -0
  69. data/tasks/testing.rake +27 -0
  70. data/tasks/transcoding.rake +40 -0
  71. data/tasks/website.rake +8 -0
  72. data/test_progress_reporting.rb +14 -0
  73. metadata +187 -0
@@ -0,0 +1,323 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ module Tools
5
+
6
+ describe Flvtool2 do
7
+ before(:each) 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.should_receive(:parse_result).once #.with /\AERROR: No such file or directory/
22
+ @flvtool2.execute
23
+ end
24
+
25
+ it "should mixin AbstractTool" do
26
+ Flvtool2.included_modules.include?(AbstractTool::InstanceMethods).should be_true
27
+ end
28
+
29
+ it "should set supported options successfully" do
30
+ @flvtool2.options[:temp_file].should == @options[:temp_file]
31
+ @flvtool2.options[:output_file].should == @options[:output_file]
32
+ end
33
+
34
+ end
35
+
36
+ describe Flvtool2, " when parsing a result" do
37
+ before(:each) do
38
+ setup_flvtool2_spec
39
+ end
40
+
41
+ it "should set metadata if called with -P option" do
42
+ @flvtool2.send(:parse_result, @metadata_result).should be_true
43
+ @flvtool2.raw_metadata.should == @metadata_result
44
+ end
45
+
46
+ it "should succeed but not set metadata without -P option" do
47
+ @flvtool2.send(:parse_result,"").should be_true
48
+ end
49
+ end
50
+
51
+ context Flvtool2, " result parsing should raise an exception" do
52
+
53
+ before(:each) do
54
+ setup_flvtool2_spec
55
+ end
56
+
57
+ it "when not passed a command" do
58
+ lambda {
59
+ @flvtool2.send(:parse_result, @helptext)
60
+ }.should raise_error(TranscoderError::InvalidCommand, /flvtool2 help text/)
61
+ end
62
+
63
+ it "when receiving an empty file" do
64
+ lambda {
65
+ @flvtool2.send(:parse_result, @empty_file)
66
+ }.should raise_error(TranscoderError::InvalidFile, /Output file was empty/)
67
+ end
68
+
69
+ it "when passed an invalid input file" do
70
+ lambda {
71
+ @flvtool2.send(:parse_result, @non_flv_input)
72
+ }.should raise_error(TranscoderError::InvalidFile, "input must be a valid FLV file")
73
+ end
74
+
75
+ it "when input file not found" do
76
+ lambda {
77
+ @flvtool2.send(:parse_result, @no_input_file)
78
+ }.should raise_error(TranscoderError::InputFileNotFound, /^ERROR: No such file or directory/)
79
+ end
80
+
81
+ it "when receiving unexpected results" do
82
+ lambda {
83
+ @flvtool2.send(:parse_result, @unexpected_results)
84
+ }.should raise_error(TranscoderError::UnexpectedResult, /ffmpeg/i)
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ def setup_flvtool2_spec
91
+ @options = {:temp_file => "foo", :output_file => "bar"}
92
+ @command = "flvtool2 -U $temp_file$ $output_file$"
93
+ @flvtool2 = RVideo::Tools::Flvtool2.new(@command, @options)
94
+
95
+ @helptext = "FLVTool2 1.0.6
96
+ Copyright (c) 2005-2007 Norman Timmler (inlet media e.K., Hamburg, Germany)
97
+ Get the latest version from http://www.inlet-media.de/flvtool2
98
+ This program is published under the BSD license.
99
+
100
+ Usage: flvtool2 [-ACDPUVaciklnoprstvx]... [-key:value]... in-path|stdin [out-path|stdout]
101
+
102
+ If out-path is omitted, in-path will be overwritten.
103
+ In-path can be a single file, or a directory. If in-path is a directory,
104
+ out-path has to be likewise, or can be omitted. Directory recursion
105
+ is controlled by the -r switch. You can use stdin and stdout keywords
106
+ as in- and out-path for piping or redirecting.
107
+
108
+ Chain commands like that: -UP (updates FLV file than prints out meta data)
109
+
110
+ Commands:
111
+ -A Adds tags from -t tags-file
112
+ -C Cuts file using -i inpoint and -o outpoint
113
+ -D Debugs file (writes a lot to stdout)
114
+ -H Helpscreen will be shown
115
+ -P Prints out meta data to stdout
116
+ -U Updates FLV with an onMetaTag event
117
+
118
+ Switches:
119
+ -a Collapse space between cutted regions
120
+ -c Compatibility mode calculates some onMetaTag values different
121
+ -key:value Key-value-pair for onMetaData tag (overwrites generated values)
122
+ -i timestamp Inpoint for cut command in miliseconds
123
+ -k Keyframe mode slides onCuePoint(navigation) tags added by the
124
+ add command to nearest keyframe position
125
+ -l Logs FLV stream reading to stream.log in current directory
126
+ -n Number of tag to debug
127
+ -o timestamp Outpoint for cut command in miliseconds
128
+ -p Preserve mode only updates FLVs that have not been processed
129
+ before
130
+ -r Recursion for directory processing
131
+ -s Simulation mode never writes FLV data to out-path
132
+ -t path Tagfile (MetaTags written in XML)
133
+ -v Verbose mode
134
+ -x XML mode instead of YAML mode
135
+
136
+ REPORT BUGS at http://projects.inlet-media.de/flvtool2
137
+ Powered by Riva VX, http://rivavx.com"
138
+
139
+ @non_flv_input = "ERROR: IO is not a FLV stream. Wrong signature.
140
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:393:in `read_header'
141
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flv/stream.rb:57:in `initialize'
142
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:272:in `new'
143
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:272:in `open_stream'
144
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:238:in `process_files'
145
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `each'
146
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `process_files'
147
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:44:in `execute!'
148
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:168:in `execute!'
149
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:228
150
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
151
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
152
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/bin/flvtool2:2
153
+ ERROR: /opt/local/bin/flvtool2:18:in `load'
154
+ ERROR: /opt/local/bin/flvtool2:18"
155
+
156
+ @no_input_file = "ERROR: No such file or directory - /Users/jon/code/spinoza/rvideo/foobar
157
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `initialize'
158
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `open'
159
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:259:in `open_stream'
160
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:238:in `process_files'
161
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `each'
162
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:225:in `process_files'
163
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2/base.rb:44:in `execute!'
164
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:168:in `execute!'
165
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/lib/flvtool2.rb:228
166
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
167
+ ERROR: /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
168
+ ERROR: /opt/local/lib/ruby/gems/1.8/gems/flvtool2-1.0.6/bin/flvtool2:2
169
+ ERROR: /opt/local/bin/flvtool2:18:in `load'
170
+ ERROR: /opt/local/bin/flvtool2:18"
171
+
172
+ @unexpected_results = "FFmpeg version CVS, Copyright (c) 2000-2004 Fabrice Bellard
173
+ Mac OSX universal build for ffmpegX
174
+ 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
175
+ libavutil version: 49.0.0
176
+ libavcodec version: 51.9.0
177
+ libavformat version: 50.4.0
178
+ built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250)
179
+
180
+ Seems that stream 1 comes from film source: 600.00 (600/1) -> 59.75 (239/4)
181
+ Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'jobjob2.mov':
182
+ Duration: 00:01:09.0, start: 0.000000, bitrate: 28847 kb/s
183
+ Stream #0.0(eng): Audio: aac, 44100 Hz, stereo
184
+ Stream #0.1(eng), 59.75 fps(r): Video: dvvideo, yuv411p, 720x480
185
+ Stream mapping:
186
+ Stream #0.1 -> #0.0
187
+ Stream #0.0 -> #0.1
188
+ Press [q] to stop encoding"
189
+
190
+ @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"
191
+
192
+ @metadata_result = "---
193
+ /Users/jon/code/spinoza/rvideo/temp.flv:
194
+ hasKeyframes: true
195
+ cuePoints:
196
+ audiodatarate: 64.8512825785226
197
+ hasVideo: true
198
+ stereo: false
199
+ canSeekToEnd: false
200
+ framerate: 30
201
+ audiosamplerate: 44000
202
+ videocodecid: 2
203
+ datasize: 992710
204
+ lasttimestamp: 19.453
205
+ audiosamplesize: 16
206
+ audiosize: 165955
207
+ hasAudio: true
208
+ audiodelay: 0
209
+ videosize: 825165
210
+ metadatadate: Fri Sep 14 13:25:58 GMT-0500 2007
211
+ metadatacreator: inlet media FLVTool2 v1.0.6 - http://www.inlet-media.de/flvtool2
212
+ lastkeyframetimestamp: 19.219
213
+ height: 240
214
+ filesize: 998071
215
+ hasMetadata: true
216
+ keyframes:
217
+ times:
218
+ - 0
219
+ - 0.4
220
+ - 0.801
221
+ - 1.201
222
+ - 1.602
223
+ - 2.002
224
+ - 2.402
225
+ - 2.803
226
+ - 3.203
227
+ - 3.604
228
+ - 4.004
229
+ - 4.404
230
+ - 4.805
231
+ - 5.205
232
+ - 5.606
233
+ - 6.006
234
+ - 6.406
235
+ - 6.807
236
+ - 7.207
237
+ - 7.608
238
+ - 8.008
239
+ - 8.408
240
+ - 8.809
241
+ - 9.209
242
+ - 9.61
243
+ - 10.01
244
+ - 10.41
245
+ - 10.811
246
+ - 11.211
247
+ - 11.612
248
+ - 12.012
249
+ - 12.412
250
+ - 12.813
251
+ - 13.213
252
+ - 13.614
253
+ - 14.014
254
+ - 14.414
255
+ - 14.815
256
+ - 15.215
257
+ - 15.616
258
+ - 16.016
259
+ - 16.416
260
+ - 16.817
261
+ - 17.217
262
+ - 17.618
263
+ - 18.018
264
+ - 18.418
265
+ - 18.819
266
+ - 19.219
267
+ filepositions:
268
+ - 1573
269
+ - 24627
270
+ - 56532
271
+ - 90630
272
+ - 137024
273
+ - 185134
274
+ - 225110
275
+ - 262990
276
+ - 291508
277
+ - 330947
278
+ - 370739
279
+ - 398621
280
+ - 426203
281
+ - 448515
282
+ - 468895
283
+ - 488660
284
+ - 508208
285
+ - 523991
286
+ - 541463
287
+ - 558463
288
+ - 572248
289
+ - 590480
290
+ - 604788
291
+ - 620959
292
+ - 632658
293
+ - 645806
294
+ - 655949
295
+ - 668266
296
+ - 684172
297
+ - 697064
298
+ - 713306
299
+ - 728607
300
+ - 746615
301
+ - 760836
302
+ - 774867
303
+ - 790766
304
+ - 804779
305
+ - 821676
306
+ - 843681
307
+ - 857278
308
+ - 873427
309
+ - 888404
310
+ - 900958
311
+ - 914336
312
+ - 927537
313
+ - 941037
314
+ - 958188
315
+ - 974841
316
+ - 988796
317
+ audiocodecid: 2
318
+ videodatarate: 336.705289672544
319
+ duration: 19.486
320
+ hasCuePoints: false
321
+ width: 320
322
+ ..."
323
+ end
@@ -0,0 +1,71 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ describe FrameCapturer, "calculating offset from a timecode argument" do
5
+ before do
6
+ @file = FrameCapturer.new :input => spec_file('kites.mp4')
7
+ end
8
+
9
+ it "should calculate a timecode, when given a percentage" do
10
+ @file.inspector.duration.should == 19600
11
+ @file.calculate_time("10%").should be_close(1.96, 0.1)
12
+ @file.calculate_time("1%").should be_close(0.196, 0.001)
13
+ @file.calculate_time("75%").should be_close(14.7, 0.1)
14
+ @file.calculate_time("100%").should be_close(19.6, 0.1)
15
+ end
16
+
17
+ it "should calculate a timecode, when given a frame" do
18
+ @file.inspector.fps.to_i.should == 10
19
+ @file.calculate_time("10f").should be_close(1.0, 0.1)
20
+ @file.calculate_time("27.6f").should be_close(2.76, 0.1)
21
+
22
+ @file.inspector.stub!(:fps).and_return(29.97)
23
+ @file.calculate_time("276f").should be_close(9.2, 0.1)
24
+ @file.calculate_time("10f").should be_close(0.3, 0.1)
25
+ @file.calculate_time("29.97f").should be_close(1.0, 0.01)
26
+ end
27
+
28
+ it "should return itself when given seconds" do
29
+ [1, 10, 14, 3.7, 2.8273, 16].each do |t|
30
+ @file.calculate_time("#{t}s").should == t
31
+ end
32
+ end
33
+
34
+ it "should return itself when given no letter" do
35
+ [1, 10, 14, 3.7, 2.8273, 16].each do |t|
36
+ @file.calculate_time("#{t}").should == t
37
+ end
38
+ end
39
+
40
+ it "should return a frame at 99%, when given something outside of the bounds of the file" do
41
+ nn = @file.calculate_time("99%")
42
+ %w(101% 20s 99 300f).each do |tc|
43
+ @file.calculate_time(tc).should be_close(nn, 0.01)
44
+ end
45
+ end
46
+
47
+ ###
48
+
49
+ it "captures one frame at the start with no arguments" do
50
+ f = FrameCapturer.new :input => spec_file('kites.mp4')
51
+ assert_equal \
52
+ %{ffmpeg -i '#{f.input}' -ss 0 -vframes 1 -vcodec mjpeg -y -f image2 -vf 'scale=176:144' '#{f.output}'},
53
+ f.command
54
+ end
55
+
56
+ it "captures one frame with only offset" do
57
+ f = FrameCapturer.new :input => spec_file('kites.mp4'),
58
+ :offset => 10
59
+ assert_equal \
60
+ %{ffmpeg -i '#{f.input}' -ss 10.0 -vframes 1 -vcodec mjpeg -y -f image2 -vf 'scale=176:144' '#{f.output}'},
61
+ f.command
62
+ end
63
+
64
+ it "captures using any ffmpeg binary" do
65
+ f = FrameCapturer.new :input => spec_file('kites.mp4'), :ffmpeg_binary => "ffmpeg06"
66
+ assert_equal \
67
+ %{ffmpeg06 -i '#{f.input}' -ss 0 -vframes 1 -vcodec mjpeg -y -f image2 -vf 'scale=176:144' '#{f.output}'},
68
+ f.command
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,59 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ describe Inspector do
5
+ it "should raise an error if ffmpeg cannot be found" do
6
+ lambda {
7
+ file = Inspector.new(:file => spec_file("kites.mp4"), :ffmpeg_binary => "ffmpeg-nonexistant")
8
+ }.should raise_error(RuntimeError, /^ffmpeg could not be found/)
9
+ end
10
+
11
+ it "should raise an error if it doesn't recognize a file format" do
12
+ unrecognized_format(:text)
13
+ end
14
+
15
+ def unrecognized_format(format)
16
+ file = Inspector.new(:raw_response => files(format))
17
+ file.unknown_format?.should be_true
18
+ end
19
+ end
20
+
21
+ describe Inspector, " parsing ffmpeg info" do
22
+
23
+ it "should read ffmpeg build data successfully (with a darwinports build)" do
24
+ file = Inspector.new(:raw_response => ffmpeg('darwinports'))
25
+ file.ffmpeg_configuration.should == "--prefix=/opt/local --prefix=/opt/local --disable-vhook --mandir=/opt/local/share/man --extra-cflags=-DHAVE_LRINTF --extra-ldflags=-d -L/opt/local/lib --enable-gpl --enable-mp3lame --enable-libogg --enable-vorbis --enable-faac --enable-faad --enable-xvid --enable-x264 --enable-a52 --enable-dts"
26
+ file.ffmpeg_version.should == "SVN-r6399"
27
+ file.ffmpeg_libav.should == ["libavutil version: 49.0.1", "libavcodec version: 51.16.0", "libavformat version: 50.5.0"]
28
+ file.ffmpeg_build.should == "built on Mar 29 2007 17:18:04, gcc: 4.0.1 (Apple Computer, Inc. build 5367)"
29
+ file.raw_metadata.should =~ /^Input #/
30
+ end
31
+
32
+ it "should read ffmpeg build data successfully (with a compiled build)" do
33
+ file = Inspector.new(:raw_response => ffmpeg(:osx_intel_1))
34
+ file.ffmpeg_configuration.should == "--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"
35
+ file.ffmpeg_version.should == "CVS"
36
+ file.ffmpeg_libav.should == ["libavutil version: 49.0.0", "libavcodec version: 51.9.0", "libavformat version: 50.4.0"]
37
+ file.ffmpeg_build.should == "built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250)"
38
+ file.raw_metadata.should =~ /^Input #/
39
+ end
40
+
41
+ it 'should handle "\n" newline characters' do
42
+ raw_response = "FFmpeg version SVN-r10656, Copyright (c) 2000-2007 Fabrice Bellard, et al.
43
+ configuration: --enable-libmp3lame --enable-libogg --enable-libvorbis --enable-liba52 --enable-libxvid --enable-libfaac --enable-libfaad --enable-libx264 --enable-libxvid --enable-pp --enable-shared --enable-gpl --enable-libtheora --enable-libfaadbin --enable-liba52bin --enable-libamr_nb --enable-libamr_wb --enable-libacfr16 --extra-ldflags=-L/root/src/ffmpeg/libavcodec/acfr16/ --extra-libs=-lacfr
44
+ libavutil version: 49.5.0
45
+ libavcodec version: 51.44.0
46
+ libavformat version: 51.14.0
47
+ built on Oct 9 2007 18:53:49, gcc: 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
48
+ Input #0, mp3, from '/mnt/app/worker/tmp/2112/2007-07-29_11AM.mp3':
49
+ Duration: 00:22:09.2, bitrate: 80 kb/s
50
+ Stream #0.0: Audio: mp3, 22050 Hz, stereo, 80 kb/s
51
+ Must supply at least one output file
52
+ "
53
+
54
+ file = Inspector.new(:raw_response => raw_response)
55
+ file.ffmpeg_version.should == "SVN-r10656"
56
+ # file.audio_codec.should == "mp3" no idea what this is
57
+ end
58
+ end
59
+ end