我安裝了Paperclip-ffmpeg並試圖上傳一個flv文件,但似乎轉換文件時出現了一些問題。Paperclip-ffmpeg無法在Rails上工作
我加入Paperclip.options[:command_path] = "/usr/bin/"
(我用which ffmpeg
路徑)我config/environments/development.rb
文件,以下回形針,ffmpeg的GitHub的頁面上的說明。
這裏是我的模型subquestion.rb
,其中包含一個名爲qflv回形針場:
class Subquestion < ActiveRecord::Base
belongs_to :question
has_many :qimages , :dependent => :destroy
has_attached_file :qflv, styles: {
medium: {geometry: "640*480", format: 'flv'},
thumb: {geometry: "100*100#", format: 'jpg', time: 10}
}, processors: [:ffmpeg]
這裏是我的_subquestion_fields.html.erb
文件,其中用戶上傳視頻:
<%= f.file_field :qflv %>
_subquestion_fields.html.erb
是問題呈現。 html.erb文件:
<%= nested_form_for @question, :url => {:action => 'create_question'} do |f| %>
<%= f.fields_for :subquestions do |builder| %>
<%= render 'subquestion_fields', :f => builder %>
這裏是錯誤消息的一部分:
WARNING: gnome-keyring:: couldn't connect to: /run/user/li/keyring-CsW4u8/pkcs11: No such file or directory
ffmpeg version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:23:21 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[flv @ 0x8ba50a0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9.flv':
Metadata:
metadatacreator : modified by youku.com in 20111202
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
Duration: 00:05:25.03, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 448x336 [PAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16
Incorrect frame size
Failed to set value '0x0' for option 's'
WARNING: gnome-keyring:: couldn't connect to: /run/user/li/keyring-CsW4u8/pkcs11: No such file or directory
ffmpeg version 0.8.6-6:0.8.6-1ubuntu2, Copyright (c) 2000-2013 the Libav developers
built on Mar 30 2013 22:23:21 with gcc 4.7.2
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
[flv @ 0x86490a0] Estimating duration from bitrate, this may be inaccurate
Input #0, flv, from '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9.flv':
Metadata:
metadatacreator : modified by youku.com in 20111202
hasKeyframes : true
hasVideo : true
hasAudio : true
hasMetadata : true
Duration: 00:05:25.03, start: 0.000000, bitrate: N/A
Stream #0.0: Video: h264 (High), yuv420p, 448x336 [PAR 1:1 DAR 4:3], 15 tbr, 1k tbn, 30 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0x864c180] w:448 h:336 pixfmt:yuv420p
[scale @ 0x8653840] w:448 h:336 fmt:yuv420p -> w:448 h:336 fmt:yuvj420p flags:0x4
[crop @ 0x864dc20] w:448 h:336 -> w:0 h:0
[crop @ 0x864dc20] Invalid too big or non positive size for width '0' or height '0'
Error opening filters!
Started POST "/test_geisinger/roots/questions/create" for 127.0.0.1 at 2013-07-27 23:12:31 -0400
Processing by RootsController#create_question as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"EiJk5dBf1nL96BtUiKc0qALCg0Bj9mQ0dx9IodfYdO0=", "question"=>{"explanation"=>"flv", "choice_id"=>"8", "correct_selection_id"=>"32", "quiz_id"=>"10", "subquestions_attributes"=>{"0"=>{"subquestion_type"=>"flv", "_destroy"=>"false", "qflv"=>#<ActionDispatch::Http::UploadedFile:0x9d94640 @original_filename="03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE7.flv", @content_type="video/x-flv", @headers="Content-Disposition: form-data; name=\"question[subquestions_attributes][0][qflv]\"; filename=\"03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE7.flv\"\r\nContent-Type: video/x-flv\r\n", @tempfile=#<Tempfile:/tmp/RackMultipart20130727-1837-1f6g2s0>>}}}, "commit"=>"Submit"}
[paperclip] [ffmpeg] ffmpeg -i "/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9.flv" 2>&1
[paperclip] [ffmpeg] Command Success
[paperclip] [ffmpeg] Making...
[paperclip] [ffmpeg] Building Destination File: '03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9' + 'flv'
[paperclip] [ffmpeg] Destination File Built
[paperclip] [ffmpeg] Adding Geometry
[paperclip] [ffmpeg] Extracting Target Dimensions
[paperclip] [ffmpeg] Target Size is Available
[paperclip] [ffmpeg] Keeping Aspect Ratio
[paperclip] [ffmpeg] Resize
[paperclip] [ffmpeg] Convert Options: 0x0
[paperclip] [ffmpeg] Adding Format
[paperclip] [ffmpeg] Adding Source
[paperclip] [ffmpeg] Building Parameters
[paperclip] [ffmpeg] -i :source -s 0x0 -y :dest
Command :: ffmpeg -i '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9.flv' -s 0x0 -y '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l920130727-1837-11o3enh.flv'
[paperclip] An error was received while processing: #<Paperclip::Error: error while processing video for 03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9: Command 'ffmpeg -i '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l9.flv' -s 0x0 -y '/tmp/03000201005171FC8274A20623ECA86B119768-56C7-7A62-DB7A-A4B599F64EE720130727-1837-13757l920130727-1837-11o3enh.flv'' returned 1. Expected 0
可能有一些問題,所以PKCS11我發現這篇文章:
https://bugzilla.redhat.com/show_bug.cgi?id=783568
但我找不到/etc/xdg/autostart/gnome-keyring-*.desktop
。
謝謝!
非常感謝!我實際上使用了一個名爲'rails-ffmpeg'的gem,所以如果我將「錯誤的ffmpeg」改爲FFmpeg,gem是否會受到影響? – Lee7355512727
我找不到任何名爲'rails-ffmpeg'的Gem。 「受影響」是什麼意思?我很確定Gem沒有發佈自己的'ffmpeg'二進制文件,所以它可能會與其他人一起工作。 – slhck
對不起,它是[paperclip-ffmpeg](https://github.com/owahab/paperclip-ffmpeg)。謝謝!! – Lee7355512727