Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include libraries in a ruby project?

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?

like image 859
volkov Avatar asked Dec 01 '25 01:12

volkov


1 Answers

#!/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
like image 191
Anand Shah Avatar answered Dec 02 '25 16:12

Anand Shah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!