rFFmpeg
A tiny wrapper for ffmpeg
Requirements
rFFmpeg requires that you already have ffmpeg installed, obviously :)
Install
gem install polly-rffmpeg --source http://gems.github.com
Note
Please note that this is still pretty experimental and should be viewed more as an api proposal
rather than production ready.
However it does work so you can use it right now, if you so choose, but expect some major api
changes as time goes on.
Usage
=== You can use RFFmpef like so:
require 'rubygems'
require 'rffmpeg'
include RFFmpeg
capture_stream "/path/to/video/<filename>.<ext>" do |input_stream|
input_stream.seek "00:02:10"
input_stream.duration "00:04:53"
input_stream.output_to "/path/to/video/<filename>.<ext>" do |output_stream|
output_stream.resolution "800x600"
output_stream.overwrite_existing true
end
end
RFFmpeg::run
=== or like this:
require 'rubygems'
require 'rffmpeg'
include RFFmpeg
capture_stream("/path/to/video/<filename>.<ext>").output_to("/path/to/video/<filename>.<ext>")
RFFmpeg::run
=== or how about:
require 'rubygems'
require 'rffmpeg'
include RFFmpeg
capture_stream("/path/to/video/<filename>.<ext>")
output_to("/path/to/video/<filename>.<ext>")
RFFmpeg::run
=== this also works:
require 'rubygems'
require 'rffmpeg'
include RFFmpeg
capture_stream("/path/to/video/<filename>.<ext>").seek("00:02:10").output_to("/path/to/video/<filename>.<ext>").resolution("800x600")
RFFmpeg::run
Extending
You can extend it with your own methods if they aren't already available, or even overide the default
behaviour of existing ones. Here's how you would go about it:
RFFmpeg::add_method :my_extension, :args do |args|
RFFmpegCommand.add args
end
So if you wanted to add a method for say, setting the video quantizer scale blur for example, here's
how you could do it:
RFFmpeg::add_method :quantizer_scale_blur, :blur do |blur|
RFFmpegCommand.add "-qblur #{blur}"
end
You would then call it just like any other method:
capture_stream "/path/to/video/<filename>.<ext>" do |input_stream|
input_stream.quantizer_scale_blur "0.5" # Your method is now available just like any other
# library method.
input_stream.output_to "/path/to/video/<filename>.<ext>" do |output_stream|
output_stream.resolution "800x600"
output_stream.overwrite_existing true
end
end
RFFmpeg::run