2

我安装了rvideo.

gem install rvideo
aptitude install ffmpeg

我在阅读手册时使用 rvideo 编写了以下内容。

#!/usr/bin/env ruby

file = RVideo::Inspector.new(:file => "/home/user/r/input.mp4")
file.fps        # => "29.97" 
file.duration   # => "00:40:23.4" 

transcoder = RVideo::Transcoder.new

recipe = "ffmpeg -i $input_file$ -ar 22050 -ab 64 -f flv -r 29.97 -s"
recipe += " $resolution$ -y $output_file$"
recipe += "\nflvtool2 -U $output_file$"
begin
transcoder.execute(recipe, {:input_file => "/home/user/r/input.mp4",
:output_file => "/home/user/r/output.flv", :resolution => "640x360"})
rescue TranscoderError => e
puts "Unable to transcode file: #{e.class} - #{e.message}"
end

transcoder.original     # RVideo::Inspector object
transcoder.processed    # RVideo::Inspector object

当我做:

$ ruby hw.rb

我得到:

first.rb:3: uninitialized constant RVideo (NameError)

在手册中,我找到了这段代码:

require 'test/unit/assertions'
include Test::Unit::Assertions
puts assert_equal nil == nil, nil.nil?

如何在我的案例中包含 rvideo 库?我怎么知道图书馆的路径?

4

1 回答 1

2
#!/usr/bin/env ruby

require 'rubygems'
require 'rvideo'

file = RVideo::Inspector.new(:file => "/home/user/r/input.mp4")
file.fps        # => "29.97" 
file.duration   # => "00:40:23.4" 

# rest of the code follows
于 2013-01-09T10:34:04.337 回答