Audio/Video Transcoder for Paperclip using FFMPEG/Avconv.
This is a replacement for ( https://github.com/owahab/paperclip-ffmpeg ).
Add this line to your application's Gemfile:
gem 'paperclip-av-transcoder'
And then execute:
$ bundle
Or install it yourself as:
$ gem install paperclip-av-transcoder
In your model:
# app/models/user.rb
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => {
:medium => { :geometry => "640x480", :format => 'flv' },
:thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
}, :processors => [:transcoder]
end
This will produce:
- A transcoded
:medium
FLV file with the requested dimensions if they will match the aspect ratio of the original file, otherwise, width will be maintained and height will be recalculated to keep the original aspect ration. - A screenshot
:thumb
with the requested dimensions regardless of the aspect ratio.
You may optionally add <attachment>_meta
to your model and it will get populated with information about the processed video.
The geometry parameters are:
- '!' - Keep the same aspect of the image/video, but with the passed dimesion.
- '#' - Pad the image/video.
- '<' - Enlarge the image/video.
- '>' - Shrink the image/video.
- Fork it ( https://github.com/ruby-av/paperclip-av-transcoder/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request