Hey there 👋
It’s Robin from CFD Engine & I found this question lurking in last week’s survey responses, so I thought I’d drop a quick answer in here.
“How do you make movies from static images?”
You know the scenario, ParaView has blessed you with a whole bunch PNG’s & you’d like to combine them into a single movie file.
If it could be done on the command-line, using open-source tools, then that would be great.
If it could be done without having to learn any complex commands, then that would be even better.
In turns out there’s an OpenFOAM utility for exactly this situation.
Say hello to foamCreateVideo
👋
Hang on…
Before I get to that, I need to say a massive thank you to everyone who took the time to complete last week’s survey 🙏 130+ responses was waaay more than I expected.
Let me dig through the data & get back to you with some “insights.”
Movie time
Firstly, ParaView can output movie files directly. If you’re on Linux or Mac you can write out AVI files. If you’re on Windows, you can also save MP4 files (h/t Matthieu).
But, if you’re doing your post-pro on a Linux machine & you want to take advantage of MP4 for it’s smaller file sizes, then you’ll need export your animation as a bunch of PNGs & assemble them yourself.
FFmpeg to the rescue
FFmpeg
is an open-source toolkit for recording, converting & streaming audio & video. It can do a lot of AV tasks, one of which is grabbing a collection of static images & combining them into a movie file.
Unfortunately, the ffmpeg
command to do it looks something like this…
No-one is going to remember (or want to type) that, just to convert some images into a video 🤯
We can do better…
foamCreateVideo
foamCreateVideo
has been shipping with OpenFOAM since 2015 & remains part of both the Foundation & OpenCFD releases.
You’ve probably had access to it for years & never knew it was there.
It’s a short(ish) shell script which transforms that cumbersome raw ffmpeg
command into something a bit more user friendly (& easier to remember)…
…essentially, find all of the image files in the current directory that start with the prefix inputFiles.
and assemble them into an .mp4
video called outputFile
.
You might need to install ffmpeg
(i.e. sudo apt-get install ffmpeg
on Ubuntu) but other than that, you should be good to go.
It’s worth noting that it only works with input files in .png
format & that it expects your sequence of images to be named consistently, image.0000.png
, image.0001.png
, etc, which is exactly how ParaView exports them 👍
Gotcha
You may (not) be surprised to discover that the Foundation & OpenCFD versions of this tool are different.
They do essentially the same thing, but they have slightly different syntax & feature sets.
I’d say the Foundation version has the edge, with slightly higher quality settings & a few more features.
Why not give them both a spin? You don’t need to have their parent (or any) OpenFOAM version installed to use them.
For example, if you use an OpenCFD OpenFOAM release you can grab the Foundation’s foamCreateVideo
from GitHub & give it a try.
Alternatively, if you have a Foundation release, you can grab OpenCFD’s foamCreateVideo
from their repository & give that a go.
For most of you, just use whatever you already have & go from there.
It’s movie time
This one’s for you, anonymous survey respondent, but also for anyone else who wants a quick, scriptable way to create high-quality, space-efficient movie files from a bunch of images 🎬
Thanks again for your help with the survey 🙏 I appreciate it.
P.S. it’s still up if you want to contribute.
Until next week, stay safe,