質問

I have a simple rails application that allows uploading video files and I need to get the duration of each file. The last is being unsolved for several days till now...

I am using:

  1. Ubuntu 13.04
  2. JRuby 1.7.3
  3. Rails 3.2.13
  4. paperclip (3.4.1)
  5. paperclip-ffmpeg (0.10.2)
  6. rvideo (0.9.3)

The paperclip-ffmpeg allows me to upload videos and I am using the rvideo gem following this tutorial to get the duration. In my model, I have the following method:

  def get_video_duration
    file = RVideo::Inspector.new(file: video.path(:original), ffmpeg_binary:'/usr/bin/')
    file.duration
  end

But the duration method is returning nil. I have printed the file structure in my view:

--- !ruby/object:RVideo::Inspector
filename: The_Rolling_Stones_-_Paint_It_Black.mp4
full_filename: "/home/gotqn/RubyMineProjects/beta/public/webinars/42/original/The_Rolling_Stones_-_Paint_It_Black.mp4"
unknown_format: true
path: "/home/gotqn/RubyMineProjects/beta/public/webinars/42/original"
raw_response: |
  /bin/sh: 1: /usr/bin/: Permission denied
ffmpeg_binary: "/usr/bin/"

Can enayone tell what I am doing wrong here?

Also, I have found it very difficult to find a proper gem which I can use to get the duration. Some of them are out dated, some of them can be used with Jruby and some of them I can used because I am with Ubuntu 13.04 and the support of ffmeg is low.

So, if anyone could advise me a better gem I will be glad to try it.

役に立ちましたか?

解決

I strongly recommend you to use streamio-ffmpeg gem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top