rvideo 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/ENV +100 -0
  2. data/ENV2 +129 -0
  3. data/History.txt +3 -0
  4. data/License.txt +20 -0
  5. data/Manifest.txt +44 -0
  6. data/README.txt +91 -0
  7. data/RULES +11 -0
  8. data/Rakefile +163 -0
  9. data/config/boot.rb +16 -0
  10. data/lib/rvideo.rb +19 -0
  11. data/lib/rvideo/errors.rb +21 -0
  12. data/lib/rvideo/inspector.rb +486 -0
  13. data/lib/rvideo/reporter.rb +176 -0
  14. data/lib/rvideo/reporter/views/index.html.erb +27 -0
  15. data/lib/rvideo/reporter/views/report.css +27 -0
  16. data/lib/rvideo/reporter/views/report.html.erb +81 -0
  17. data/lib/rvideo/reporter/views/report.js +9 -0
  18. data/lib/rvideo/tools/abstract_tool.rb +79 -0
  19. data/lib/rvideo/tools/ffmpeg.rb +111 -0
  20. data/lib/rvideo/tools/flvtool2.rb +45 -0
  21. data/lib/rvideo/transcoder.rb +113 -0
  22. data/lib/rvideo/version.rb +9 -0
  23. data/scripts/txt2html +67 -0
  24. data/setup.rb +1585 -0
  25. data/spec/files/kites.mp4 +0 -0
  26. data/spec/fixtures/ffmpeg_builds.yml +28 -0
  27. data/spec/fixtures/files.yml +374 -0
  28. data/spec/fixtures/recipes.yml +6 -0
  29. data/spec/integrations/files/files.yml +361 -0
  30. data/spec/integrations/formats_spec.rb +287 -0
  31. data/spec/integrations/inspection_spec.rb +15 -0
  32. data/spec/integrations/recipes_spec.rb +0 -0
  33. data/spec/integrations/rvideo_spec.rb +17 -0
  34. data/spec/integrations/transcoding_spec.rb +9 -0
  35. data/spec/spec.opts +1 -0
  36. data/spec/spec_helper.rb +11 -0
  37. data/spec/units/abstract_tool_spec.rb +112 -0
  38. data/spec/units/ffmpeg_spec.rb +703 -0
  39. data/spec/units/flvtool2_spec.rb +314 -0
  40. data/spec/units/inspector_spec.rb +41 -0
  41. data/spec/units/transcoder_spec.rb +140 -0
  42. data/website/index.html +219 -0
  43. data/website/index.txt +142 -0
  44. data/website/javascripts/rounded_corners_lite.inc.js +285 -0
  45. metadata +94 -0
@@ -0,0 +1,287 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ context "Using various builds of ffmpeg, RVideo should properly inspect" do
5
+ specify "a cell-phone MP4 file" do
6
+ @file = Inspector.new(:raw_response => files(:kites))
7
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
8
+ @file.raw_duration.should == "00:00:19.6"
9
+ @file.duration.should == 19600
10
+ @file.bitrate.should == 98
11
+ @file.bitrate_units.should == "kb/s"
12
+ @file.audio_stream_id.should == "#0.1"
13
+ @file.audio_codec.should == "samr / 0x726D6173"
14
+ @file.audio_sample_rate.should == 8000
15
+ @file.audio_sample_units.should == "Hz"
16
+ @file.audio_channels_string.should == "mono"
17
+ @file.video_codec.should == "mpeg4"
18
+ @file.video_stream_id.should == "#0.0"
19
+ @file.video_colorspace.should == "yuv420p"
20
+ @file.width.should == 176
21
+ @file.height.should == 144
22
+ @file.fps.should == "10.00"
23
+ end
24
+
25
+ specify "fancypants" do
26
+ @file = Inspector.new(:raw_response => files(:fancypants))
27
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
28
+ @file.raw_duration.should == "00:00:35.4"
29
+ @file.duration.should == 35400
30
+ @file.bitrate.should == 1980
31
+ @file.bitrate_units.should == "kb/s"
32
+ @file.audio_stream_id.should == "#0.1"
33
+ @file.audio_codec.should == "aac"
34
+ @file.audio_sample_rate.should == 44100
35
+ @file.audio_sample_units.should == "Hz"
36
+ @file.audio_channels_string.should == "stereo"
37
+ @file.video_codec.should == "h264"
38
+ @file.video_stream_id.should == "#0.0"
39
+ @file.video_colorspace.should == "yuv420p"
40
+ @file.width.should == 720
41
+ @file.height.should == 400
42
+ @file.fps.should == "23.98"
43
+ end
44
+
45
+ specify "mpeg4/xvid" do
46
+ @file = Inspector.new(:raw_response => files(:chainsaw))
47
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
48
+ @file.raw_duration.should == "00:01:09.5"
49
+ @file.duration.should == 69500
50
+ @file.bitrate.should == 970
51
+ @file.bitrate_units.should == "kb/s"
52
+ @file.audio_stream_id.should == "#0.1"
53
+ @file.audio_codec.should == "mp2"
54
+ @file.audio_sample_rate.should == 48000
55
+ @file.audio_sample_units.should == "Hz"
56
+ @file.audio_channels_string.should == "stereo"
57
+ @file.video_codec.should == "mpeg4"
58
+ @file.video_stream_id.should == "#0.0"
59
+ @file.video_colorspace.should == "yuv420p"
60
+ @file.width.should == 624
61
+ @file.height.should == 352
62
+ @file.fps.should == "23.98"
63
+ end
64
+
65
+ specify "mpeg1" do
66
+ @file = Inspector.new(:raw_response => files(:mpeg1_957))
67
+ @file.container.should == "mpeg"
68
+ @file.raw_duration.should == "00:00:22.6"
69
+ @file.duration.should == 22600
70
+ @file.bitrate.should == 808
71
+ @file.bitrate_units.should == "kb/s"
72
+ @file.audio_stream_id.should == "#0.0"
73
+ @file.audio_codec.should == "mp2"
74
+ @file.audio_sample_rate.should == 32000
75
+ @file.audio_sample_units.should == "Hz"
76
+ @file.audio_channels_string.should == "mono"
77
+ @file.video_codec.should == "mpeg1video"
78
+ @file.video_stream_id.should == "#0.1"
79
+ @file.video_colorspace.should == "yuv420p"
80
+ @file.width.should == 320
81
+ @file.height.should == 240
82
+ @file.fps.should == "25.00"
83
+ end
84
+
85
+ specify "avi/mpeg4/mp3" do
86
+ @file = Inspector.new(:raw_response => files(:buffy))
87
+ @file.container.should == "avi"
88
+ @file.raw_duration.should == "00:43:25.3"
89
+ @file.duration.should == 2605300
90
+ @file.bitrate.should == 1266
91
+ @file.bitrate_units.should == "kb/s"
92
+ @file.audio_stream_id.should == "#0.1"
93
+ @file.audio_codec.should == "mp3"
94
+ @file.audio_sample_rate.should == 48000
95
+ @file.audio_sample_units.should == "Hz"
96
+ @file.audio_channels_string.should == "stereo"
97
+ @file.video_codec.should == "mpeg4"
98
+ @file.video_stream_id.should == "#0.0"
99
+ @file.video_colorspace.should == "yuv420p"
100
+ @file.width.should == 640
101
+ @file.height.should == 464
102
+ @file.fps.should == "23.98"
103
+ end
104
+
105
+ specify "HD mpeg2" do
106
+ @file = Inspector.new(:raw_response => files(:chairprank))
107
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
108
+ @file.raw_duration.should == "00:00:36.6"
109
+ @file.duration.should == 36600
110
+ @file.bitrate.should == 26602
111
+ @file.bitrate_units.should == "kb/s"
112
+ @file.audio_stream_id.should == "#0.0"
113
+ @file.audio_codec.should == "pcm_s16le"
114
+ @file.audio_sample_rate.should == 48000
115
+ @file.audio_sample_units.should == "Hz"
116
+ @file.audio_channels_string.should == "stereo"
117
+ @file.video_codec.should == "mpeg2video"
118
+ @file.video_stream_id.should == "#0.1"
119
+ @file.video_colorspace.should == "yuv420p"
120
+ @file.width.should == 1440
121
+ @file.height.should == 1080
122
+ @file.fps.should == "29.97"
123
+ end
124
+
125
+ specify "h264 (1)" do
126
+ @file = Inspector.new(:raw_response => files(:fire_short))
127
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
128
+ @file.raw_duration.should == "00:00:10.0"
129
+ @file.duration.should == 10000
130
+ @file.bitrate.should == 23232
131
+ @file.bitrate_units.should == "kb/s"
132
+ @file.audio_stream_id.should == "#0.0"
133
+ @file.audio_codec.should == "pcm_s16le"
134
+ @file.audio_sample_rate.should == 48000
135
+ @file.audio_sample_units.should == "Hz"
136
+ @file.audio_channels_string.should == "stereo"
137
+ @file.video_codec.should == "h264"
138
+ @file.video_stream_id.should == "#0.1"
139
+ @file.video_colorspace.should == "yuv420p"
140
+ @file.width.should == 1280
141
+ @file.height.should == 720
142
+ @file.fps.should == "29.97"
143
+ end
144
+
145
+ specify "h264 video only" do
146
+ @file = Inspector.new(:raw_response => files(:fire_video_only))
147
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
148
+ @file.raw_duration.should == "00:00:10.0"
149
+ @file.duration.should == 10000
150
+ @file.bitrate.should == 506
151
+ @file.bitrate_units.should == "kb/s"
152
+ @file.audio?.should == false
153
+ @file.audio_codec.should == nil
154
+ @file.video_codec.should == "h264"
155
+ @file.video_stream_id.should == "#0.0"
156
+ @file.video_colorspace.should == "yuv420p"
157
+ @file.width.should == 320
158
+ @file.height.should == 180
159
+ @file.fps.should == "29.97"
160
+ end
161
+
162
+ specify "aac audio only" do
163
+ @file = Inspector.new(:raw_response => files(:fire_audio_only))
164
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
165
+ @file.raw_duration.should == "00:00:10.0"
166
+ @file.duration.should == 10000
167
+ @file.bitrate.should == 86
168
+ @file.bitrate_units.should == "kb/s"
169
+ @file.audio_stream_id.should == "#0.0"
170
+ @file.audio_codec.should == "aac"
171
+ @file.audio_sample_rate.should == 48000
172
+ @file.audio_sample_units.should == "Hz"
173
+ @file.audio_channels_string.should == "stereo"
174
+ @file.video?.should == false
175
+ @file.video_codec.should be_nil
176
+ end
177
+
178
+ specify "apple intermediate" do
179
+ @file = Inspector.new(:raw_response => files(:fireproof))
180
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
181
+ @file.raw_duration.should == "00:00:18.7"
182
+ @file.duration.should == 18700
183
+ @file.bitrate.should == 24281
184
+ @file.bitrate_units.should == "kb/s"
185
+ @file.audio_stream_id.should == "#0.0"
186
+ @file.audio_codec.should == "pcm_s16be"
187
+ @file.audio_sample_rate.should == 48000
188
+ @file.audio_sample_units.should == "Hz"
189
+ @file.audio_channels_string.should == "mono"
190
+ @file.video_codec.should == "Apple Intermediate Codec"
191
+ @file.video_stream_id.should == "#0.1"
192
+ @file.video_colorspace.should == nil
193
+ @file.width.should == 1280
194
+ @file.height.should == 720
195
+ @file.fps.should == "600.00" # this is a known FFMPEG problem
196
+ end
197
+
198
+ specify "dv video" do
199
+
200
+ end
201
+
202
+ specify "msmpeg4" do
203
+
204
+ end
205
+
206
+ specify "mpeg2 ac3" do
207
+
208
+ end
209
+
210
+ specify "m4v h264" do
211
+
212
+ end
213
+
214
+ specify "3g2" do
215
+
216
+ end
217
+
218
+ specify "3gp (1)" do
219
+
220
+ end
221
+
222
+ specify "3gp (2)" do
223
+
224
+ end
225
+
226
+ specify "flv" do
227
+
228
+ end
229
+
230
+ specify "wmv (1)" do
231
+
232
+ end
233
+
234
+ specify "wmv/wmv3/wmav2" do
235
+
236
+ end
237
+
238
+ specify "wmva/wmva2" do
239
+
240
+ end
241
+
242
+ specify "mov/msmpeg4" do
243
+
244
+ end
245
+
246
+ specify "audio only mp3" do
247
+ @file = Inspector.new(:raw_response => files(:duck))
248
+ @file.container.should == "mp3"
249
+ @file.raw_duration.should == "00:02:03.0"
250
+ @file.duration.should == 123000
251
+ @file.bitrate.should == 128
252
+ @file.bitrate_units.should == "kb/s"
253
+ @file.audio_stream_id.should == "#0.0"
254
+ @file.audio_codec.should == "mp3"
255
+ @file.audio_sample_rate.should == 44100
256
+ @file.audio_sample_units.should == "Hz"
257
+ @file.audio_channels_string.should == "stereo"
258
+ @file.audio?.should == true
259
+ @file.video?.should == false
260
+ end
261
+
262
+ specify "audio only aac" do
263
+ @file = Inspector.new(:raw_response => files(:eiffel))
264
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
265
+ @file.raw_duration.should == "00:02:50.3"
266
+ @file.duration.should == 170300
267
+ @file.bitrate.should == 162
268
+ @file.bitrate_units.should == "kb/s"
269
+ @file.audio_stream_id.should == "#0.0"
270
+ @file.audio_codec.should == "aac"
271
+ @file.audio_sample_rate.should == 44100
272
+ @file.audio_sample_units.should == "Hz"
273
+ @file.audio_channels_string.should == "stereo"
274
+ @file.audio?.should == true
275
+ @file.video?.should == false
276
+ end
277
+
278
+ specify "invalid file" do
279
+ @file = Inspector.new(:raw_response => files(:invalid))
280
+ @file.container.should == "mov,mp4,m4a,3gp,3g2,mj2"
281
+ @file.raw_duration.should be_nil
282
+ @file.valid?.should be_false
283
+ @file.unknown_format?.should be_false
284
+ @file.unreadable_file?.should be_true
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ module RVideo
4
+ describe RVideo::Inspector do
5
+ before do
6
+ @files = YAML::load(File.open("#{FIXTURE_PATH}/files.yml"))
7
+ #return f[key.to_s]['response']
8
+ end
9
+
10
+ it "should parse properly" do
11
+
12
+ end
13
+
14
+ end
15
+ end
File without changes
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ module RVideo
4
+ describe RVideo, " with every recipe and file" do
5
+ it "should interpolate commands correctly" do
6
+
7
+ end
8
+
9
+ it "should parse prepopulated output successfully" do
10
+
11
+ end
12
+
13
+ it "should transcode to a viewable file" do
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ module RVideo
4
+ describe RVideo do
5
+ before do
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/../lib/rvideo'
2
+
3
+ def ffmpeg(key)
4
+ f = YAML::load(File.open("#{FIXTURE_PATH}/ffmpeg_builds.yml"))
5
+ return f[key.to_s]['response']
6
+ end
7
+
8
+ def files(key)
9
+ f = YAML::load(File.open("#{FIXTURE_PATH}/files.yml"))
10
+ return f[key.to_s]['response']
11
+ end
@@ -0,0 +1,112 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module RVideo
4
+ module Tools
5
+ describe AbstractTool, "#assign" do
6
+
7
+ before do
8
+ @command = "ffmpeg -i $input_file$ $output_file$"
9
+ @options = {:input_file => "foo", :output_file => "bar"}
10
+ end
11
+
12
+ it "should assign commands properly with options - ffmpeg" do
13
+ Ffmpeg.should_receive(:new).with(@command, @options)
14
+ AbstractTool.assign(@command, @options)
15
+ end
16
+
17
+ it "should assign properly without options - ffmpeg" do
18
+ Ffmpeg.should_receive(:new).with(@command, {})
19
+ AbstractTool.assign(@command)
20
+ end
21
+
22
+ it "should return an instance of the specified tool" do
23
+ tool = AbstractTool.assign(@command, @options)
24
+ tool.class.should == Ffmpeg
25
+ end
26
+ end
27
+
28
+ describe AbstractTool, " when building a command" do
29
+
30
+ before do
31
+ @options = {:input_file => "foo", :output_file => "bar", :resolution => "baz"}
32
+ @simple_avi = "ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec mp3 -r 29.97 -s $resolution$ -y $output_file$"
33
+ end
34
+
35
+ it "should set supported options successfully" do
36
+ ffmpeg = Ffmpeg.new(@simple_avi, @options)
37
+ ffmpeg.options['resolution'].should == @options[:resolution]
38
+ ffmpeg.options['input_file'].should == @options[:input_file]
39
+ ffmpeg.options['output_file'].should == @options[:output_file]
40
+ end
41
+
42
+ it "should work if options defined as strings, but referenced as symbols" do
43
+ options = {'input_file' => "foo", 'output_file' => "bar", 'resolution' => "baz"}
44
+ ffmpeg = Ffmpeg.new(@simple_avi, options)
45
+ ffmpeg.options[:resolution].should == options['resolution']
46
+ ffmpeg.options[:input_file].should == options['input_file']
47
+ ffmpeg.options[:output_file].should == options['output_file']
48
+ end
49
+
50
+ it "should ignore extra options (not needed by the recipe)" do
51
+ Ffmpeg.new(@simple_avi, @options.merge(:foo => "bar"))
52
+ end
53
+
54
+ it "should interpolate variables successfully" do
55
+ ffmpeg = Ffmpeg.new(@simple_avi, @options)
56
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -vcodec xvid -acodec mp3 -r 29.97 -s #{@options[:resolution]} -y #{@options[:output_file]}"
57
+ end
58
+
59
+ it "the matched_variable method should reference the variable without $" do
60
+ ffmpeg = Ffmpeg.new(@simple_avi, @options)
61
+ ffmpeg.matched_variable("$resolution$").should == "baz"
62
+ end
63
+
64
+ it "the matched_variable method should raise an error when the variable is not found" do
65
+ ffmpeg = Ffmpeg.new(@simple_avi, @options)
66
+ lambda {
67
+ ffmpeg.matched_variable("$foo$")
68
+ }.should raise_error(TranscoderError::ParameterError)
69
+ end
70
+
71
+ it "should raise an exception when a required variable isn't set (1)" do
72
+ lambda {
73
+ ffmpeg = Ffmpeg.new(@simple_avi, {:input_file => "baz"})
74
+ }.should raise_error(TranscoderError::ParameterError)
75
+ end
76
+
77
+ it "the should raise an error when a recipe includes a variable not supplied (2)" do
78
+ lambda {
79
+ ffmpeg = Ffmpeg.new(@simple_avi + " $novar$", @options)
80
+ }.should raise_error(TranscoderError::ParameterError)
81
+ end
82
+
83
+ it "the should not raise an error when a variable is supplied but nil" do
84
+ ffmpeg = Ffmpeg.new(@simple_avi, @options.merge(:resolution => nil))
85
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -vcodec xvid -acodec mp3 -r 29.97 -s -y #{@options[:output_file]}"
86
+ end
87
+
88
+ it 'should ignore escaped leading \$' do
89
+ ffmpeg = Ffmpeg.new('ffmpeg -i $input_file$ -ar 44100 -ab 64 -fakeoptions \$foo$ -vcodec xvid -acodec mp3 -r 29.97 -s $resolution$ -y $output_file$', @options)
90
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -fakeoptions $foo$ -vcodec xvid -acodec mp3 -r 29.97 -s #{@options[:resolution]} -y #{@options[:output_file]}"
91
+ end
92
+
93
+ it 'should ignore escaped trailing \$' do
94
+ ffmpeg = Ffmpeg.new('ffmpeg -i $input_file$ -ar 44100 -ab 64 -fakeoptions $foo\$ -vcodec xvid -acodec mp3 -r 29.97 -s $resolution$ -y $output_file$', @options)
95
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -fakeoptions $foo$ -vcodec xvid -acodec mp3 -r 29.97 -s #{@options[:resolution]} -y #{@options[:output_file]}"
96
+ end
97
+
98
+ it 'should ignore two escaped \$' do
99
+ ffmpeg = Ffmpeg.new('ffmpeg -i $input_file$ -ar 44100 -ab 64 -fakeoptions \$foo\$ -vcodec xvid -acodec mp3 -r 29.97 -s $resolution$ -y $output_file$', @options)
100
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -fakeoptions $foo$ -vcodec xvid -acodec mp3 -r 29.97 -s #{@options[:resolution]} -y #{@options[:output_file]}"
101
+ end
102
+
103
+ it 'should access the original fps' do
104
+ @mock_inspector = mock("inspector")
105
+ Inspector.stub!(:new).and_return(@mock_inspector)
106
+ @mock_inspector.stub!(:fps).and_return 23.98
107
+ ffmpeg = Ffmpeg.new("ffmpeg -i $input_file$ -ar 44100 -ab 64 -vcodec xvid -acodec mp3 $original_fps$ -s $resolution$ -y $output_file$", @options)
108
+ ffmpeg.command.should == "ffmpeg -i #{@options[:input_file]} -ar 44100 -ab 64 -vcodec xvid -acodec mp3 -r 23.98 -s #{@options[:resolution]} -y #{@options[:output_file]}"
109
+ end
110
+ end
111
+ end
112
+ end