ffmpeg-ruby
ffmpeg-ruby copied to clipboard
Channels.com's Ruby Interface to FFMpeg.
= Ruby FFMpeg Library
"ffmpeg-ruby" is a ruby gem library (work in progress) that provides bindings allowing you to access the ffmpeg under ruby. FFMpeg is a cross-platform solution to record, convert and stream audio and video. It includes libavcodec - the leading audio/video codec library.
This implementation is starting by doing the translation for some of the functions in libavcodec and libavformat to ruby.
FFMpeg is provided by http://ffmpeg.org/ under the LGPL license.
This bindings gem is graciously provided by http://www.channels.com under the LGPL license.
== Installing
$ gem install ffmpeg-ruby
== Installation troubleshooting
If you run into trouble, it could be the C bundle not building. This is known to happen on MacOS 64-bit or with the ffmpeg from macports. You basically need to run ruby extconf yourself then.
$ ruby extconf.rb
You may need to add +--with+ on mac, to point it to macports' /opt/local for the libraries.
== Mac Notes
Because of the way the library gets built, it needs to match the architecture type of your ruby. You can force it to do this by specifying the ++-arch++ flag. For a 64-bit ruby on Snow Leopard:
$ sudo port install ffmpeg (go have coffee) $ sudo env ARCHFLAGS="-arch x86_64" gem install ffmpeg-ruby
If your machine is 32 bit, the +ARCHFLAGS+ above should be ++ARCHFLAGS="-arch i386"+
This will provide you with a bundle you can require.
== Usage
See the code on +test/+ for usage. But basically it goes like this:
require 'ffmpeg-ruby'
# Get a list of the video codecs supported
FFMpeg::AVCodec.supported_video_codecs
# Get a list of the audio codecs supported
FFMpeg::AVCodec.supported_video_codecs
# Create new AVFormatContext
f = FFMpeg::AVFormatContext.new("/path/to/my/video.mov")
f.codec_contexts.each{ |ctx|
puts ctx.name # The name of the codec this file uses.
}