Professional Documents
Culture Documents
Using Ffmpeg To Convert A Set of Images Into A Video: Specifying Start and End Frames
Using Ffmpeg To Convert A Set of Images Into A Video: Specifying Start and End Frames
Using Ffmpeg To Convert A Set of Images Into A Video: Specifying Start and End Frames
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 .
Assuming that you have an overlay image that is the same size as the video, you can use the following
command to add it during the ffmpeg compression process.
1 of 3 04/09/19, 6:33 am
Using ffmpeg to convert a set of images into a video http://hamelot.io/visualization/using-ffmpeg-to-...
You can use this technique to overlay multiple files on top of each other, or even have a dynamic overlay.
-filter_complex is a really flexible command and can do much much more than is shown here. See
the ffmpeg filters documentation (https://ffmpeg.org/ffmpeg-filters.html) for more information.
If the video has already been compressed the following can be used to change the codmpression to
h264:
Quicktime and some other codecs have trouble playing certain pixel formats such as 4:4:4 Planar and
4:2:2 Planar while 4:2:0 seems to work fine
-pix_fmt yuv420p
2 of 3 04/09/19, 6:33 am
Using ffmpeg to convert a set of images into a video http://hamelot.io/visualization/using-ffmpeg-to-...
-b 4M
you can use the -b flag to specify the target bitrate, in this case it is 4 megabits per second
-vpre normal
-vpre is the quality setting, better quality takes longer to encode, some alternatives are: default, normal,
hq, max. Note that the -vpre command only works if the corresponding setting file is available.
3 of 3 04/09/19, 6:33 am