Search code examples
ruby-on-railsmp4rmagick

Generate 30FPS MP4 with Rmagick


I am using Imagemagick and Rmagick in Rails to generate MP4 videos. I am trying to change the frame rate and it keeps comming up at 25FPS.

I see in some examples that at a command line level you can use -delay 1x2, Nobody explains the 1x2, i'm guessing its ticks/second and tick/frame. but it doesn't seem to change the delay when using Rmagick.

I've also set the ticks_per_second to 600 and the delay to 30 on the Imagelist object. No joy.


Solution

  • Okay I made this work. if i do the math correctly:) 600/30=20FPS

    set ticks_per_second to 60 on the ImageList and delay to 2 on each image in the ImageList.

    animation=ImageList.new
    animation.ticks_per_second=60
    frames.each{ |frame|
       animation.push(frame)
       animation.cur_image.delay=2
    }
    animation.write('my file')
    

    I get an film at the right speed. But the film info window in Quicktime still shows 25FPS. That's probably a defect but easy to ignore.