Using ffmpeg to convert a set of images into a video 2016-04-05
Original 2012-11-16, Updated 2016-04-05: cleanup and information about overlaying images.
When using ffmpeg to compress a video, I recommend using the libx264 codec, from experience it has given me excellent quality for small video sizes. I have noticed that different versions of ffmpeg will produce different output file sizes, so your mileage may vary.
To take a list of images that are padded with zeros (pic0001.png
, pic0002.png
…. etc) use the following command:
where the %04d means that zeros will be padded until the length of the string is 4 i.e 0001
…0020
…0030
…2000
and so on. If no padding is needed use something similar to pic%d.png
or %d.png
.
-r
is the framerate (fps)-crf
is the quality, lower means better quality, 15-25 is usually good-s
is the resolution-pix_fmt yuv420p
specifies the pixel format, change this as needed
the file will be output (in this case) to: test.mp4
Specifying start and end frames
-start_number
specifies what image to start at-vframes 1000
specifies the number frames/images in the video