我安装了 Paperclip-ffmpeg 并尝试上传一个 flv 文件,但转换文件似乎有一些问题。
我按照 paperclip-ffmpeg github 页面上的说明将Paperclip.options[:command_path] = "/usr/bin/"
(我通过使用 获得了路径which ffmpeg
)添加到我的文件中。config/environments/development.rb
这是我的模型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
由 question.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
。
谢谢!