Encode frames into MP4

Creating MP4 video from individual frames

To create an mp4 from these frames:

1ffmpeg -r 30 -start_number 1 -i out%08d.jpeg -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

Note there are two -r parameters for the frame rate. The first one is the source frame rate. The second one is the output frame rate of the final video.

Parameter Description Notes
-r 30 The source frame rate. This can be either lower than, equal or greater to the output rate
-start_number 1 The start frame number. This is optional and will default to 1 if omitted.
-i out%08d.jpeg The source frame filename format This should match that used to create the frames
-c:v libx264 Video encoding format
-r 30 Output frame rate
-pix_fmt yuv420p Output video frame format

For the source frame rate, do not confuse this with the capture frame rate. Instead, set it to how fast you want the source frames to be read in at when creating the video.

For example: When generating a 30fps video, and you want each frame image to be exactly one frame from the source then set it to 30 here and for the output frame rate.

If you want the output to be 30 fps but the input at just 10fps (so one source frame is 3 in the output) then set the input to 10 and the output as 30.

Setting the source to a value larger than the input will cause frames to be dropped from the source.


Last modified November 11, 2021: Change format of command lines (522944e)