# \[ANN\] RVideo - Ruby video transcoding library

**URL:** <https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145>\
**Category:** Ruby\
**Created:** [October 2, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145 "2007-10-02T22:18:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [October 2, 2007, 10:18pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145/1 "2007-10-02T22:18:37Z")

</div>

RVideo has just been released as a gem!

RVideo is a Ruby library inspects and processes video and audio files  
by providing an interface to free Unix tools like ffmpeg. Install  
with:

sudo gem install rvideo

(RVideo requires ffmpeg, and may require other video tools, depending  
on what you intend to do.)

For more information, see the full announcement at RailSpikes  
([railspikes.com](http://railspikes.com/2007/10/2/rvideo-0-9-is-now-available)), or the  
RVideo site at Google Code ([http://code.google.com/p/rvideo](http://code.google.com/p/rvideo))

## Code example 1: inspecting a video file

file = RVideo::Inspector.new(:file =\> “#{FILE\_PATH}/filename.mp4”)  
file.video\_codec # =\> mpeg4  
file.audio\_codec # =\> aac  
file.resolution # =\> 320x240

## Code example 2: transcoding a video file

command = “ffmpeg -i $input\_file -vcodec xvid -s $resolution$  
$output\_file$”  
options = {  
:input\_file =\> “#{FILE\_PATH}/filename.mp4”,  
:output\_file =\> “#{FILE\_PATH}/processed\_file.mp4”,  
:resolution =\> “640x480”  
}

transcoder = RVideo::Transcoder.new

transcoder.execute(command, options)

transcoder.processed.video\_codec # =\> xvid

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [October 3, 2007, 12:19pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145/2 "2007-10-03T12:19:23Z")

</div>

On 10/2/07, Jon D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> For more information, see the full announcement at RailSpikes  
> ([railspikes.com](http://railspikes.com/2007/10/2/rvideo-0-9-is-now-available)), or the  
> RVideo site at Google Code ([Google Code Archive - Long-term storage for Google Code Project Hosting.](http://code.google.com/p/rvideo))

Hey, great! Thanks for releasing this, it looks very useful.  
I’ll give it a spin once my replacement power supply arrives.

One API idea:  
RVideo.transcode(“filename.mp4”, “filename.avi”,  
:resolution =\> [640,480],  
:video\_codec =\> ‘xvid’,  
:audio\_codec =\> ‘mp3’)

Cheers,

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [October 3, 2007, 4:38pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145/3 "2007-10-03T16:38:41Z")

</div>

Ilmari H. wrote:

> One API idea:  
> RVideo.transcode(“filename.mp4”, “filename.avi”,  
> :resolution =\> [640,480],  
> :video\_codec =\> ‘xvid’,  
> :audio\_codec =\> ‘mp3’)

Thanks for the suggestion. I’d like to do something like that at some  
point, but I’m not exactly sure how.

I spent quite a bit of time thinking about the best way to define a  
command. The problem is that ffmpeg is extremely complex, and a good  
quality transcoding job often involves more than just resolution, codec,  
format, etc. There are literally hundreds of other options that can be  
set that control quality, file size, a/v sync, etc. So I didn’t want to  
reduce the power of ffmpeg by controlling the options too much.

So I decided for now to just do the simplest thing possible and pass in  
a command with variable interpolation. This allows you to store recipes  
on your system (in your database, in a yaml config file, etc.), and to  
pass in whatever variables you want.

For now, you can certainly build your own RVideo recipe constructor,  
which does exactly what you’re describing. It should just output a  
string, and then pass that string to a RVideo::Transcoder object.

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [October 3, 2007, 5:27pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145/4 "2007-10-03T17:27:30Z")

</div>

On 10/3/07, Jon D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks for the suggestion. I’d like to do something like that at some  
> a command with variable interpolation. This allows you to store recipes  
> on your system (in your database, in a yaml config file, etc.), and to  
> pass in whatever variables you want.

So why not do both? Offer support for a few basic commands, resolution,  
codecs, etc, and still provide a field :other\_options or something to  
pass  
in anything else you want. Then you’re free to add more commands as  
they  
become commonly used, but not reduce the flexibility or power of ffmpeg.

For now, you can certainly build your own RVideo recipe constructor,

---

<div class="post-metadata">

**Author:** ![jdruse](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b38774/32.png) [@jdruse](https://www.ruby-forum.com/u/jdruse)\
**Post date:** [October 3, 2007, 5:28pm UTC](https://www.ruby-forum.com/t/ann-rvideo-ruby-video-transcoding-library/116145/5 "2007-10-03T17:28:40Z")

</div>

On Oct 3, 2007, at 9:38 AM, Jon D. wrote:

> point, but I’m not exactly sure how.  
> So I decided for now to just do the simplest thing possible and  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

Check VLC (video lan client) it’s open source and they use ffmpeg.  
You might find some ideas in there.
