加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 使用carrierwave-video上传视频时出现错误:“

发布时间:2020-12-17 01:56:13 所属栏目:百科 来源:网络整理
导读:我已经将新列添加到微博中作为视频.现在我想使用carrierwave-video gem( https://github.com/rheaton/carrierwave-video).现在,当我尝试上传视频时,我遇到了错误. (我试图以.MOV格式上传视频) 错误 Video Failed to transcode with FFmpeg. Check ffmpeg ins
我已经将新列添加到微博中作为视频.现在我想使用carrierwave-video gem( https://github.com/rheaton/carrierwave-video).现在,当我尝试上传视频时,我遇到了错误. (我试图以.MOV格式上传视频)

错误

Video Failed to transcode with FFmpeg. Check ffmpeg install and verify video is not corrupt or cut short. Original error: undefined method `set_success' for #<Micropost:0x007fbf0d40dd68>

video_uploader.rb

class VideoUploader < CarrierWave::Uploader::Base
  include CarrierWave::Video

  process encode_video: [:mp4,callbacks: { after_transcode: :set_success } ]
  storage :file

  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end
end

的Gemfile

gem 'carrierwave','0.10.0'
 gem 'carrierwave-video'

微博模型

mount_uploader :video,VideoUploader

我还在我的FFmpeg文件中进行了配置,并从FFmpeg下载了文件.

Taner-MacBook-Pro:~ tanerkoroglu$ /Users/tanerkoroglu/Downloads/SnowLeopard_Lion_Mountain_Lion_Mavericks_12.12.2015/ffmpeg ; exit;
 ffmpeg version 2.8.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --disable-doc --arch=x86_64 --enable-runtime-cpudetect
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
 Hyper fast Audio and Video encoder
   usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

  Use -h to get full help or,even better,run 'man ffmpeg'
   logout
   Saving session...
    ...copying shared history...
     ...saving history...truncating history files...
      ...completed.
    Deleting expired sessions...146 completed.

解决方法

将gem“carrierwave-ffmpeg”添加到您的Gemfile中,并确保通过计算机上的 homebrew安装ffmpeg和ffmpeg2theora.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读