An example command from FFmpeg’s wiki, Create a video slideshow from images:


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

I’ve been using it since 2013/10/20 18:56:45 to create videos from frames I grabbed, the latest one was one using 50 frames per second — though output video only 30 fps — it can generate a better quality video in terms of fps on my computer, which wouldn’t be able to encode such rate in real-time, that’s why I sometimes opted to grab frame by frame slowly and let FFmpeg to do the job on its on time.

The command is quite simple, only one and a half options are new:

  • -i img%03d.png: If you are aware of printf(3), then you already know how to use it to get the images. Basically, the file name’s number part has prefixing zeros.
  • -framerate: The number follows means how many input images you want to show in a second, that is the input fps, but not the output. If you grab 12 frames a second, then the number it’s 12. In my case, the grabbing is frame by frame, but I know I want each to show 0.02 seconds, so that is 50 frames per seconds and that is the number to set. In the example code above, it’s one frame showing for 5 seconds, the number is 0.2 fps, hence 1/5.