Ffmpeg

FFmpeg is a command line utility to do video/audio/image processing. It is commonly used to generate video from image frames.

Installation on Windows

Recent versions of M-Star CFD come with ffmpeg. You can add M-Star install directory to your PATH environment variable.

You can also install ffmpeg yourself from https://ffmpeg.org/

Installation on Linux

Whenever possible, always use your package manager to install ffmpeg. Some platforms such as Redhat might require additional setup steps.

Redhat

  1. Enable RPM Fusion repo (as recommended by ffmpeg ) – https://rpmfusion.org/Configuration

  2. In M-Star Post, be sure to specify the full path ffmpeg “/usr/bin/ffmpeg” and click the Save button in the lower left corner of the form

Animating image frames

The below command is used to animate a set of frames. The output produces an mp4 file called “top.mp4”

A quick explanation of each argument:

  • -r 1 : This is the rate of image frames in units (1/s). A value of 1 means 1 frame is used every second in the video. If your output interval was 0.1s, your image frame rate would be 10.

  • -i "ScalardyeVolumeFraction(-)_top_%05d.png" : The image filename patterm of the frames being used. Note the %05d will be used by ffmpeg to zero pad an integer with up to 5 zeros.

  • -vcodec libx264 : Selects the libx264 codec. A highly efficient video compression technology.

  • -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" : ffmpeg requires that each side of the frame is divisible by 2. Sometimes the frames coming out of paraview/post/vtk or whatever will not satisfy this requirement. You can use this argument to pad the images the necessary amount (single row or column of blank pixels).

  • -crf 20 : Video quality, lower is better. 15-25 is a good range.

  • -pix_fmt yuv420p : Color/picture format. This makes the video highly compatible across an array of video players.

  • top.mp4 : the last argument is simply the output filename you want.

ffmpeg -r 1 -i "ScalardyeVolumeFraction(-)_top_%05d.png" -vcodec libx264 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -crf 20 -pix_fmt yuv420p top.mp4