Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to know video width, height, duration, bit_rate, checksum... #20

Open
hyperrjas opened this issue Dec 4, 2013 · 4 comments
Open

Comments

@hyperrjas
Copy link

I would like if it's possible to know this information.

This is my process encode_video:

process encode_video: [:mp4, resolution: "1280x720", callbacks: { after_transcode: :set_success } ]

Thanks!

@rheaton
Copy link
Owner

rheaton commented Dec 4, 2013

carrierwave-video depends on this gem: https://github.com/streamio/streamio-ffmpeg

The encode_video method https://github.com/rheaton/carrierwave-video/blob/master/lib/carrierwave/video.rb#L42 is where you relevant changes would likely go.

@hyperrjas
Copy link
Author

Thanks, I would like set/send this info (duration, width, height...etc) to my model with a callback:

DEFAULTS = {
 callbacks: { after_transcode: :set_success },
 resolution: { 
    default: "1280x720"
  }
}
process :encode
def encode
  encode_video(:mp4, DEFAULTS) do |movie, params|
    params[:resolution][:default] = "1280x720"
  end
end

My question is, How can I set/send movie.duration or movie.width via callback to my model like :set_success method?

Thanks!

@rheaton
Copy link
Owner

rheaton commented Dec 4, 2013

You'd need to make some changed to the gem.

Have a look at this pull request for some guidance: #18

@emanuelbaran
Copy link

I got some help and managed to do something like this for duration:
In your uploader class (my case 'VideoUploader < CarrierWave::Uploader::Base')

process :save_video_duration
.....
# then I have the version :mp4 ...
....
def save_video_duration
    video = FFMPEG::Movie.new(file.file).duration
    model.playTime = video
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants