Coder Social home page Coder Social logo

paperclip-ffmpeg's Introduction

Paperclip FFMPEG

Adding video handling to Paperclip via ffmpeg. This gem has been tested under Linux and Mac OS X, YMMV under Windows.

Requirements

FFMPEG must be installed and Paperclip must have access to it. To ensure that it does, on your command line, run which ffmpeg. This will give you the path where ffmpeg is installed. For example, it might return /usr/local/bin/ffmpeg.

Then, in your environment config file, let Paperclip know to look there by adding that directory to its path.

In development mode, you might add this line to config/environments/development.rb):

Paperclip.options[:command_path] = "/usr/local/bin/"

Installation

Include the gem in your Gemfile:

gem "paperclip-ffmpeg"

Quick Start

In your model:

class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => { 
      :medium => { :geometry => "640x480", :format => 'flv' }
      :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
    }, :processors => [:ffmpeg]
end

This will produce:

  1. 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.
  2. A screenshot :thumb with the requested dimensions regardless of the aspect ratio.

You may optionally add <attachment>_meta to your model and paperclip-ffmpeg will add information about the processed video.

Streaming Video

When ffmpeg produces mp4 files, it places the moov atom at the end which makes it unstreamable. To handle this, paperclip-ffmpeg includes a processor to run qtfaststart after producing the video file.

In your model:

class Lesson < ActiveRecord::Base
  has_attached_file :video, :styles => {
      :mobile => {:geometry => "400x300", :format => 'mp4', :streaming => true}
  }, :processors => [:ffmpeg, :qtfaststart]
end

See danielgtaylor/qtfaststart for instructions on how to setup qtfaststart.

License

Licensed under BSD license.

paperclip-ffmpeg's People

Contributors

antonvolkoff avatar fredkelly avatar owahab avatar zmillman avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.