xeroshogun
xeroshogun

Reputation: 1092

Convert a series of jpg into an mov file in Ruby (or using any language)

I am making a site in Ruby in which I have a series of images, (almost like a powerpoint) and I need to automatically convert those images into one continuous video file (mov, mpeg) that shows each image for 5 seconds or so. Any one have any clues where to start.

I'm also open to using another language if there are tools to get the job done.

Upvotes: 1

Views: 390

Answers (1)

Wander Nauta
Wander Nauta

Reputation: 19675

You could probably use FFmpeg to do this. Here's an example from the FFmpeg Wiki on the subject:

ffmpeg -framerate 1/5 -i img%03d.jpg -c:v libx264 -r 30 -pix_fmt yuv420p -movflags +faststart out.mp4

What this would do is...

  • -i img%03d.jpg
    Read input from a series of JPEG files named img001.jpg, img002.jpg and so on
  • -framerate 1/5
    ...at one frame per five seconds...
  • -c:v libx264
    ...then turn it into H.264/MPEG-4 AVC...
  • -r 30
    ...at thirty frames per second...
  • -pix_fmt yuv420p
    ...with YUV420 pixel format (really, all the FFmpeg flags work here)...
  • -movflags +faststart
    ...after encoding completes, relocate some data to the beginning of the file so playback can begin before the file is completely downloaded...
  • out.mp4
    ...and store it into out.mp4.

If you were using this from Ruby you'd likely launch a subprocess. The flags would be similar if you really want a (QuickTime) .mov file instead of H.264 MPEG-4.

Upvotes: 7

Related Questions