簡體   English   中英

將視頻上傳到Heroku時出錯

[英]Error when uploading video to heroku

我在Rails應用程序中使用paperclip和paperclip-av-transcoder,現在已經可以在本地上傳視頻了。 但是當我在heroku中嘗試時,出現此錯誤。 Av :: UnableToDetect(無法檢測任何受支持的庫):

我可能必須添加一些內容才能使其與s3一起使用,但是我之前已將其與圖像一起使用,因此應為s3進行所有設置。

這是我模型中的代碼

class Classvideo < ActiveRecord::Base
    belongs_to :user
    has_attached_file :video, :styles => { 
        :medium => {:geometry => "640x480", :format => 'flv'},
        :thumb => { :geometry => "100x100#", :format => 'jpg', :time => 10 }
    }, :processors => [:transcoder]

validates_attachment_content_type :video, :content_type => ["video/mp4", "video.mov", "video/mpeg","video/mpeg4", "image/jpg", "image/jpeg"]
end

上周我遇到了同樣的問題-試試這個!

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(無法檢測任何受支持的庫):

轉到終端並輸入:

brew options ffmpeg

然后運行以下命令安裝ffmpeg:

brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools

重新啟動服務器並嘗試立即上傳視頻! 希望對您有所幫助-編碼愉快:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM