Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip AV Transcoder not working on remote server

I am able to upload videos locally. The videos are processed using paperclip and all the meta data is saved correctly, as well. When I tried to upload a video using our remote server, I received the error:

Av::UnableToDetect (Unable to detect any supported library)

I have installed ffmpeg using LinuxBrew. It says everything is installed correctly (checking which brew and which ffmpeg, as well as checking if the gem is appropriately installed).

When I have styling in my model for the video (which is what enables the meta information to be stored and to have control over how the video is uploaded) it doesn't work remotely.

has_attached_file :video, path: "/posts/:id/:style.:extension",
  :styles => {
    :medium => { :geometry => "493x877", :format => 'flv' },
    :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 },
    # :mobile => {:geometry => "640X480", :format => 'mp4', :streaming => true}
  }, :processors => [:transcoder]

However, when I remove this from my model and have:

has_attached_file :video, path: "/posts/:id/:style.:extension"

The video is uploaded to S3 (without the data or styling that I need).

Any help would be greatly appreciated. I think AV is having trouble finding ffmpeg but I am not sure why or how to go about fixing it. Thanks in advance for any advice.

like image 998
zreitano Avatar asked Jul 24 '15 14:07

zreitano


1 Answers

I had the same issue just this past week - Try this!

Video model:
    has_attached_file :video, styles: {
        :medium => {
          :geometry => "640x480",
          :format => 'mp4'
        },
        :thumb => { :geometry => "160x120", :format => 'jpeg', :time => 10}
    }, :processors => [:transcoder]
    validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/

Make sure you already bundled:

gem 'paperclip', '~> 4.3.1'
gem 'aws-sdk', '< 2.0'
gem 'paperclip-av-transcoder'
gem "paperclip-ffmpeg", "~> 1.2.0"

Run the paperclip migration:

rails g paperclip model video

Be sure to add in post_controller.rb:

private

    def bscenes_params
        params.require(:post).permit(:video)
    end

Upload form:

<%= f.file_field :video %>

Show page:

<%= video_tag bscene.video.url(:medium), controls: true, style: "max-width: 100%;" %>

At this point you should get this error:

Av::UnableToDetect (Unable to detect any supported library):

For Mac

Go to your terminal and type in:

brew options ffmpeg

Then run the following to install ffmpeg:

For older versions of brew recipe:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libas

For newer versions of brew recipe:

brew install ffmpeg --with-fdk-aac --with-sdl2 --with-freetype --with-frei0r --with-libass

For Linux Mint / Ubuntu / Debian based Linux

Open a terminal (Ctrl + Alt + T) and execute following commands one by one to install ffmpeg.

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

At this point Video uploads will work locally

Now for remote uploads you will need to setup https://devcenter.heroku.com/articles/buildpacks

This should now bring you to your error

Av::UnableToDetect (Unable to detect any supported library)

You will need to create a Procfile in the root of your app directory more information about Procfile here: https://devcenter.heroku.com/articles/procfile

touch Procfile

Hope this helps!

like image 65
James Brown Avatar answered Oct 11 '22 04:10

James Brown