Is there a proper way to get heroku ffmpeg installed and running so that my users can upload videos in my rails app?
Tried the Heroku references on the topic which led to my app running the heroku error check logs page...
I know there has to be some installation I have to pass but don't seems to find anything on it - Please help with links or ideas :)
users can upload videos
We've had it working on Heroku before; we used paperclip-ffmpeg
(which is now paperclip-av-transcoder
) with the actual Paperclip gem.
Whilst I can't provide any information about the buildpacks, I can share how we were able to get video uploading working on Heroku...
#app/models/attachment.rb
class Attachment < ActiveRecord::Base
has_attached_file :attachment,
styles: { thumb: { geometry: "100x100#", format: 'jpg', time: 10}, medium: { geometry: "300x300#", format: 'jpg', time: 10} },
processors: [ :transcoder ]
end
As long as the paperclip-av-transcoder
gem installs (ensure you've got it in your Gemfile
), this should allow you to store the videos - and images - you need.
Got heroku Video uploads to work!
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'
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):
Go to your terminal and type in:
brew options ffmpeg
Then run the following to install ffmpeg:
brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libas
At this point video uploads will work locally
Now for remote uploads you will need to setup https://devcenter.heroku.com/articles/buildpacks
After setting up Heroku buildpacks you may get an 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!