微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – Paperclip AV Transcoder无法在远程服务器上运行

我可以在本地上传视频.使用回形针处理视频,并且还可以正确保存所有元数据.当我尝试使用远程服务器上传视频时,收到错误消息:
Av::UnabletoDetect (Unable to detect any supported library)

我已经使用linuxbrew安装了ffmpeg.它说一切都安装正确(检查哪个brew和哪个ffmpeg,以及检查gem是否正确安装).

当我在我的视频模型中设置样式(这使得能够存储元信息并控制视频的上传方式)时,它无法远程工作.

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]

但是,当我从我的模型中删除它并具有:

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

视频上传到S3(没有我需要的数据或样式).

任何帮助将不胜感激.我认为AV无法找到ffmpeg,但我不确定为什么或如何去修复它.提前感谢任何建议.

解决方法

就在上周我遇到了同样的问题 – 试试吧!
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/

确保您已捆绑:

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

运行回形针迁移:

rails g paperclip model video

一定要在post_controller.rb中添加

private

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

上传表格:

<%= f.file_field :video %>

显示页面

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

此时你应该得到这个错误

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

对于Mac

转到您的终端并输入:

brew options ffmpeg

然后运行以下命令安装ffmpeg:

对于旧版本的酿造配方:

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

对于较新版本的酿造配方:

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

对于基于Linux Mint / Ubuntu / Debian的Linux

打开终端(Ctrl Alt T)并逐个执行以下命令以安装ffmpeg.

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

此时,视频上传将在本地运行

现在进行远程上传,您需要设置https://devcenter.heroku.com/articles/buildpacks

这应该会带给您错误

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

您需要在app目录的根目录中创建一个procfile,有关procfile的更多信息,请访问:https://devcenter.heroku.com/articles/procfile

touch procfile

希望这可以帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐