< Back

Use FFmpeg to create videos from PNGs


Problem:

I want to create a movie file from a series of images that I export from Tecplot.

Solution: 

Tecplot 360 2018 R2.1 introduced the ability to export animations to a series of images. FFmpeg, which is bundled with Tecplot 360, has commands to convert a set of images into a video format.

Here is an example command:

ffmpeg.exe -framerate 40 -i image%9d.png -s:v 1024x910 -c:v libx264 -profile:v high -crf 20 -pix_fmt yuv420p movie.mp4

Explanation of command arguments:

  • -framerate 40 – The framerate of the movie file.
  • -i image%9d.png – This is a place holder for the pattern of files you’re compiling.  %9d means that you’re looking for files named image000000000.png (‘image’ followed by nine digits).
  • -s:v 1024×910 – The width and height.  Be sure to match the aspect ratio of the image file otherwise, the video will be stretched.  Only even numbers are allowed.
  • -c:v libx264 – The type of encoding.  This is h.264, one of the most popular encodings today.
  • -profile:v high – The H.264 profile output. See https://trac.ffmpeg.org/wiki/Encode/H.264 for more details.
  • -crf 20 – The Constant Rate Factor: A lower value generally leads to higher quality, and a subjectively sane range is 17–28. CRF of 0 is considered lossless.
  • -pix_fmt yuv420p – The YUV planar color space with 4:2:0 chroma subsampling. Used for compatibility with video players.
  • movie.mp4 – The output file name. Be sure the extension matches the type of encoding used.

For more information on other command-line arguments, see the FFmpeg documentation at https://ffmpeg.org/ffmpeg.html