Skip to content
Newer
Older
100644 91 lines (60 sloc) 3.13 KB
61f5a90 first commit
Jonathan Conway authored
1 RVideo
2
3 RVideo allows you to inspect and process video files.
4
5
6 Installation is a little involved. First, install the gem:
7
8 sudo gem install rvideo
9
10 Next, install ffmpeg and (possibly) other related libraries. This is
11 documented elsewhere on the web, and can be a headache. If you are on OS X,
12 the Darwinports build is reasonably good (though not perfect). Install with:
13
14 sudo port install ffmpeg
15
16 Or, for a better build (recommended), add additional video- and audio-related
17 libraries, like this:
18
19 sudo port install ffmpeg +lame +libogg +vorbis +faac +faad +xvid +x264 +a52
20
21 Most package management systems include a build of ffmpeg, but many include a
22 poor build. So you may need to compile from scratch.
23
24 If you want to create Flash Video files, also install flvtool2:
25
26 sudo gem install flvtool2
27
28 Once ffmpeg and RVideo are installed, you're set.
29
30 To inspect a file, initialize an RVideo file inspector object. See the
31 documentation for details.
32
33 A few examples:
34
35 file = RVideo::Inspector.new(:file => "#{APP_ROOT}/files/input.mp4")
36
37 file = RVideo::Inspector.new(:raw_response => @existing_response)
38
39 file = RVideo::Inspector.new(:file => "#{APP_ROOT}/files/input.mp4",
40 :ffmpeg_binary => "#{APP_ROOT}/bin/ffmpeg")
41
42 file.fps # "29.97"
43 file.duration # "00:05:23.4"
44
45 To transcode a video, initialize a Transcoder object.
46
47 transcoder = RVideo::Transcoder.new
48
49 Then pass a command and valid options to the execute method
50
51 recipe = "ffmpeg -i $input_file$ -ar 22050 -ab 64 -f flv -r 29.97 -s"
52 recipe += " $resolution$ -y $output_file$"
53 recipe += "\nflvtool2 -U $output_file$"
54 begin
55 transcoder.execute(recipe, {:input_file => "/path/to/input.mp4",
56 :output_file => "/path/to/output.flv", :resolution => "640x360"})
57 rescue TranscoderError => e
58 puts "Unable to transcode file: #{e.class} - #{e.message}"
59 end
60
61 If the job succeeds, you can access the metadata of the input and output
62 files with:
63
64 transcoder.original # RVideo::Inspector object
65 transcoder.processed # RVideo::Inspector object
66
67 If the transcoding succeeds, the file may still have problems. RVideo
68 will populate an errors array if the duration of the processed video
69 differs from the duration of the original video, or if the processed
70 file is unreadable.
71
72 Thanks to Peter Boling for early work on RVideo.
73
74 Contribute to RVideo! If you want to help out, there are a few things you can
75 do.
76
77 - Use, test, and submit bugs/patches
78 - We need a RVideo::Tools::Mencoder class to add mencoder support.
79 - Other tool classes would be great - On2, mp4box, Quicktime (?), etc.
80 - Submit other fixes, features, optimizations, and refactorings
81
82 If RVideo is useful to you, you may also be interested in RMovie, another Ruby
83 video library. See http://rmovie.rubyforge.org/ for more.
84
85 Finally, watch for Spinoza, a commercial video transcoder built by Slantwise
86 Design. Spinoza uses RVideo for its video processing, but adds file queuing,
87 distributed transcoding, a web-based transcoder dashboard, and more. See
88 http://spinoza.tv or http://slantwisedesign.com for more.
89
90 Copyright (c) 2007 Jonathan Dahl and Slantwise Design. Released under the MIT
91 license.
Something went wrong with that request. Please try again.