axtro-rvideo 0.9.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) 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 +67 -0
  6. data/README +91 -0
  7. data/RULES +11 -0
  8. data/Rakefile +63 -0
  9. data/axtro-rvideo.gemspec +36 -0
  10. data/config/boot.rb +25 -0
  11. data/lib/rvideo.rb +44 -0
  12. data/lib/rvideo/errors.rb +24 -0
  13. data/lib/rvideo/float.rb +7 -0
  14. data/lib/rvideo/frame_capturer.rb +129 -0
  15. data/lib/rvideo/inspector.rb +483 -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 +414 -0
  23. data/lib/rvideo/tools/ffmpeg.rb +286 -0
  24. data/lib/rvideo/tools/ffmpeg2theora.rb +42 -0
  25. data/lib/rvideo/tools/flvtool2.rb +50 -0
  26. data/lib/rvideo/tools/mencoder.rb +103 -0
  27. data/lib/rvideo/tools/mp4box.rb +21 -0
  28. data/lib/rvideo/tools/mp4creator.rb +35 -0
  29. data/lib/rvideo/tools/mplayer.rb +31 -0
  30. data/lib/rvideo/tools/qtfaststart.rb +37 -0
  31. data/lib/rvideo/tools/yamdi.rb +44 -0
  32. data/lib/rvideo/transcoder.rb +120 -0
  33. data/lib/rvideo/version.rb +9 -0
  34. data/rvideo.gemspec +36 -0
  35. data/scripts/txt2html +67 -0
  36. data/setup.rb +1585 -0
  37. data/spec/files/boat.avi +0 -0
  38. data/spec/files/kites.mp4 +0 -0
  39. data/spec/fixtures/ffmpeg_builds.yml +28 -0
  40. data/spec/fixtures/ffmpeg_results.yml +608 -0
  41. data/spec/fixtures/files.yml +398 -0
  42. data/spec/fixtures/recipes.yml +58 -0
  43. data/spec/integrations/formats_spec.rb +315 -0
  44. data/spec/integrations/frame_capturer_spec.rb +26 -0
  45. data/spec/integrations/inspection_spec.rb +112 -0
  46. data/spec/integrations/recipes_spec.rb +0 -0
  47. data/spec/integrations/rvideo_spec.rb +17 -0
  48. data/spec/integrations/transcoder_integration_spec.rb +29 -0
  49. data/spec/integrations/transcoding_spec.rb +9 -0
  50. data/spec/spec.opts +1 -0
  51. data/spec/spec_helper.rb +16 -0
  52. data/spec/support.rb +36 -0
  53. data/spec/units/abstract_tool_spec.rb +123 -0
  54. data/spec/units/ffmpeg_spec.rb +327 -0
  55. data/spec/units/flvtool2_spec.rb +324 -0
  56. data/spec/units/frame_capturer_spec.rb +72 -0
  57. data/spec/units/inspector_spec.rb +59 -0
  58. data/spec/units/mencoder_spec.rb +4994 -0
  59. data/spec/units/mp4box_spec.rb +34 -0
  60. data/spec/units/mp4creator_spec.rb +34 -0
  61. data/spec/units/mplayer_spec.rb +34 -0
  62. data/spec/units/qtfaststart_spec.rb +35 -0
  63. data/spec/units/string_spec.rb +8 -0
  64. data/spec/units/transcoder_spec.rb +156 -0
  65. data/tasks/deployment.rake +5 -0
  66. data/tasks/testing.rake +27 -0
  67. data/tasks/transcoding.rake +40 -0
  68. data/tasks/website.rake +8 -0
  69. metadata +178 -0
@@ -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
+ before 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
@@ -0,0 +1,72 @@
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.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 -r 1 -f image2 -vframes 1 '#{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 -r 1 -f image2 -vframes 1 '#{f.output}'},
61
+ f.command
62
+ end
63
+
64
+ it "captures multiple frames with an interval" do
65
+ f = FrameCapturer.new :input => spec_file('kites.mp4'),
66
+ :interval => 5
67
+ assert_equal \
68
+ %{ffmpeg -i '#{f.input}' -ss 0 -r 0.2 -f image2 -vframes 1 '#{f.output}'},
69
+ f.command
70
+ end
71
+ end
72
+ 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"
57
+ end
58
+ end
59
+ end