我安装了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库?我怎么知道去图书馆的路?
#!/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