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,103 @@
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, " when grabbing a frame" do
22
+ before do
23
+ @file = Inspector.new(:raw_response => files(:kites))
24
+ end
25
+
26
+ it "should calculate a timecode, when given a percentage" do
27
+ @file.duration.should == 19600
28
+ @file.calculate_time("10%").should be_close(1.96, 0.1)
29
+ @file.calculate_time("1%").should be_close(0.196, 0.001)
30
+ @file.calculate_time("75%").should be_close(14.7, 0.1)
31
+ @file.calculate_time("100%").should be_close(19.6, 0.1)
32
+ end
33
+
34
+ it "should calculate a timecode, when given a frame" do
35
+ @file.fps.should == "10.00"
36
+ @file.calculate_time("10f").should be_close(1.0, 0.1)
37
+ @file.calculate_time("27.6f").should be_close(2.76, 0.1)
38
+
39
+ @file.stub!(:fps).and_return(29.97)
40
+ @file.calculate_time("276f").should be_close(9.2, 0.1)
41
+ @file.calculate_time("10f").should be_close(0.3, 0.1)
42
+ @file.calculate_time("29.97f").should be_close(1.0, 0.01)
43
+ end
44
+
45
+ it "should return itself when given seconds" do
46
+ [1, 10, 14, 3.7, 2.8273, 16].each do |t|
47
+ @file.calculate_time("#{t}s").should == t
48
+ end
49
+ end
50
+
51
+ it "should return itself when given no letter" do
52
+ [1, 10, 14, 3.7, 2.8273, 16].each do |t|
53
+ @file.calculate_time("#{t}").should == t
54
+ end
55
+ end
56
+
57
+ it "should return a frame at 99%, when given something outside of the bounds of the file" do
58
+ nn = @file.calculate_time("99%")
59
+ %w(101% 20s 99 300f).each do |tc|
60
+ @file.calculate_time(tc).should be_close(nn, 0.01)
61
+ end
62
+ end
63
+ end
64
+
65
+ describe Inspector, " parsing ffmpeg info" do
66
+
67
+ it "should read ffmpeg build data successfully (with a darwinports build)" do
68
+ file = Inspector.new(:raw_response => ffmpeg('darwinports'))
69
+ 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"
70
+ file.ffmpeg_version.should == "SVN-r6399"
71
+ file.ffmpeg_libav.should == ["libavutil version: 49.0.1", "libavcodec version: 51.16.0", "libavformat version: 50.5.0"]
72
+ file.ffmpeg_build.should == "built on Mar 29 2007 17:18:04, gcc: 4.0.1 (Apple Computer, Inc. build 5367)"
73
+ file.raw_metadata.should =~ /^Input #/
74
+ end
75
+
76
+ it "should read ffmpeg build data successfully (with a compiled build)" do
77
+ file = Inspector.new(:raw_response => ffmpeg(:osx_intel_1))
78
+ 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"
79
+ file.ffmpeg_version.should == "CVS"
80
+ file.ffmpeg_libav.should == ["libavutil version: 49.0.0", "libavcodec version: 51.9.0", "libavformat version: 50.4.0"]
81
+ file.ffmpeg_build.should == "built on Apr 15 2006 04:58:19, gcc: 4.0.1 (Apple Computer, Inc. build 5250)"
82
+ file.raw_metadata.should =~ /^Input #/
83
+ end
84
+
85
+ it 'should handle "\n" newline characters' do
86
+ raw_response = "FFmpeg version SVN-r10656, Copyright (c) 2000-2007 Fabrice Bellard, et al.
87
+ 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
88
+ libavutil version: 49.5.0
89
+ libavcodec version: 51.44.0
90
+ libavformat version: 51.14.0
91
+ built on Oct 9 2007 18:53:49, gcc: 4.1.2 (Ubuntu 4.1.2-0ubuntu4)
92
+ Input #0, mp3, from '/mnt/app/worker/tmp/2112/2007-07-29_11AM.mp3':
93
+ Duration: 00:22:09.2, bitrate: 80 kb/s
94
+ Stream #0.0: Audio: mp3, 22050 Hz, stereo, 80 kb/s
95
+ Must supply at least one output file
96
+ "
97
+
98
+ file = Inspector.new(:raw_response => raw_response)
99
+ file.ffmpeg_version.should == "SVN-r10656"
100
+ file.audio_codec.should == "mp3"
101
+ end
102
+ end
103
+ end