When modeling a physical phenomenon, the most informative way of visualization is video.
In this article, we will describe how to turn a sequence of images into a video clip.
Creating a sequence of images
FlowVision allows users to create a sequence of images where each of them matches to specific point in time. Here is a short instruction how to do it:
- Select the desired time step to start capturing a sequence using the Navigation of the Toolbars
- Click on the "Begin capture" button on the Capture of the Toolbars. Then you need to define the location of saving images (it should be a separate folder) and give them a name (for example, pressure.png). Images will be saving in chosen folder and having the name like pressure00001.png.
- Click on the "Start playback" button on the Navigation of the Toolbars
After end of the playback you will have a sequence of images and then you need to create a video using them.
You can use a popular software – FFmpeg, which allows to work on pictures and video including creating a video using images.
Main advantages of FFmpeg:
- The program is free and compatible with all operating systems (Linux, Windows, Mac OS)
- A console interface that allows to convert images, video and audio files into various formats quickly as well as create new ones.
To start work with FFmpeg you need to:
- Install FFmpeg on computer
- Work with FFmpeg is carried out from the command line so open it
- Prepare a script or use the ready one for automation the process of creating video.
This article describes how to create such a script.
Creating a script
To prepare a script you need to create a text file consisting of sequential commands. To make this file executable rename it by changing the extension from .txt to .bat. You can also use program BatToExe to reformat script into executable format .exe.
Full text of script:
SET /P FolderPic="Path to folder with pictures:"
if ["%FolderPic%"]==[""] SET /P FolderPic="Path to folder with pictures (can't be empty):"
if ["%FolderPic%"]==[""] SET /P FolderPic="Path to folder with pictures (CAN'T BE EMPTY):"
if ["%FolderPic%"]==[""] exit
SET /P PictureName="Picture's name:"
if ["%PictureName%"]==[""] SET /P PictureName="Picture's name (can't be empty):"
if ["%PictureName%"]==[""] SET /P PictureName="Picture's name (CAN'T BE EMPTY):"
if ["%PictureName%"]==[""] exit
SET /P PictureExt=Picture's extension [default = .png]: %PictureName%_00000.
if [%pictureExt%]== set pictureExt=png
SET /P FolderVid="Path to folder with video [default = folder with pictures]:"
if ["%FolderVid%"]==[""] set FolderVid=%FolderPic%
SET /P VideoName="Video's name [default = video_%PictureName%]:"
if ["%VideoName%"]==[""] SET VideoName=video_%PictureName%
SET /P VideoExt=Video's extension [default - .avi]: %VideoName%.
if [%VideoExt%]== set VideoExt=avi
SET /P Rate=Frame rate of video (fps) [default = 60]:
if [%Rate%]== set Rate=60
ffmpeg -r %Rate% -y -i "%PictureName%_%%05d.%PictureExt%" -c:v libx264 -vf "fps=60,format=yuv420p" -q:v 1 "%VideoName%".%VideoExt%
move "%FolderPic%\%VideoName%.%VideoExt%" "%FolderVid%"
Run the executable file. After starting a command window will appear in which you will need to enter sequentially:
- Path to folder with pictures: specify the path to the folder where the sequence of images is stored (variable FolderPic);
- Picture's name: the name of the files that correspond to the images (here you need to enter the same name which you entered while saving images in FlowVision – for example, pressure; variable PictureName);
- Picture's extension [default - .png]: PictureName_00000. : images extension (default - .png, variable PictureExt);
- Path to folder with video [default = folder with pictures]: specify the path to the folder where you want to save a creating video (default – the folder with origin images, variable FolderVid);
- Video's name [default = video_PictureName]: the name of the video (default – video_PictureName, variable VideoName);
- Video's extension [default - .avi]:VideoName. : video extension (default - .avi, variable VideoExt);
- Frame rate of video (fps) [default = 60]: video frame rate – fps (default is 60, variable Rate). This number is equal to the number of frames played in 1 second.
If there are no errors in the process the console window will close automatically and after execution the video will be pasted from the specified images in the specified folder.
FFmpeg supports a huge number of formats. To get a list of all using formats open the command line and enter: ffmpeg -formats