I installed rvideo.
gem install rvideo
aptitude install ffmpeg
I wrote the following using rvideo while reading a manual.
#!/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
When I do:
$ ruby hw.rb
I get:
first.rb:3: uninitialized constant RVideo (NameError)
In the manual, I found this code:
require 'test/unit/assertions'
include Test::Unit::Assertions
puts assert_equal nil == nil, nil.nil?
How do I include rvideo library in my case? How do I know the path to the library?
#!/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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With