Rails 3: How can I make Paperclip-FFMPEG work?

I have Rails 3.0.3 with these gems:

  • delayed_job 2.1.4
  • delayed_paperclip 0.7.1
  • paperclip 2.3.16
  • paperclip-ffmpeg 0.7.0

(This combination is very specific. Some new gems will not work with others.)

Here is my Video Model:

class Video < Upload has_attached_file :file, :default_style => :view, :processors => [:ffmpeg], :url => '/system/:class/:attachment/:id/:style/:basename.:extension', :path => ':rails_root/public/system/:class/:attachment/:id/:style' \ + '/:basename.:extension', :default_url => '/images/en/processing.png', :styles => { :mp4video => { :geometry => '520x390', :format => 'mp4', :convert_options => { :output => { :vcodec => 'libx264', :vpre => 'ipod640', :b => '250k', :bt => '50k', :acodec => 'libfaac', :ab => '56k', :ac => 2 } } }, :oggvideo => { :geometry => '520x390', :format => 'ogg', :convert_options => { :output => { :vcodec => 'libtheora', :b => '250k', :bt => '50k', :acodec => 'libvorbis', :ab => '56k', :ac => 2 } } }, :view => { :geometry => '520x390', :format => 'jpg', :time => 1 }, :preview => { :geometry => '160x120', :format => 'jpg', :time => 1 } } validates_attachment_content_type :file, :content_type => VIDEOTYPES, :if => Proc.new { |upload| upload.file.file? } process_in_background :file end 

When you create a new video object with an attachment, the original file is saved, but the conversion will not be performed. Even a call to Video.last.file.reprocess! there will be nothing but returning true . (Not sure what โ€œtruthโ€ means in this case, since it does not work.)

I tried hardcoding the path to ffmpeg in Paperclip::options[:command_path] . I even tried to delete the paperclip-ffmpeg.rb file and replace it with an empty file. Actually, thinking that I will get an exception by doing this later, instead, I will simply โ€œreturnโ€ again.

It looks like the paperclip-ffmpeg.rb file is loading because it is required by config/application.rb , but when you try to create a thumbnail or convert the video, nothing is called.

Can anyone help me with this? Thanks in advance!

+4
source share
2 answers

It seems that I myself solved this problem, and it was caused by what I did.

I wrote my own script to import files and a database from an old application into Rails. The files were in place, but someone I updated the database with the wrong file extensions (in this case, ".jpg" instead of ".MOV").

Paperclip first checks if the source file exists before calling any processor based on the name of the file stored in the database. Like not, Paperklip just didn't do anything. As soon as I corrected the data, everything went as expected. (I had problems with FFMPEG, but this is another problem.)

My apologies if I took the time to spend time. Hope this can be helpful for someone.

+2
source

I use a similar configuration for one of my projects (but Rails 3.1.1) and everything works fine. I added paperclip-ffmpeg to my Gemfile not with config / application.rb. Maybe this helps !?

+1
source

Source: https://habr.com/ru/post/1380112/


All Articles