Ep 92 – May 14 – Creating Stop-Motion movies with ffmpeg

Martin Uncut
Martin Uncut
Ep 92 - May 14 - Creating Stop-Motion movies with ffmpeg

Yesterday it was a red-day here in Sweden. That was the reason you didn’t get an episode. It was fantastic summer weather and we also had a bit of thunder just as you should when it is.. ehh… summer.

A year ago I wrote a blog post “How I used ffmpeg to create time-laps videos on my Mac“. The resulting video I hosted on a free video sharing site called PeerTube. PeerTube looks very much like YouTube. It is distributed and you can setup your own PeerTube server if you want to. I talked about a social media network called Mastdon back in “Ep 11 – Dec 22 – Mastodon” that is using the same technology to be a non centralised social media network. Take a quick listen to that episode if you’d like to know more about how this works. But any how, back to the video, the PeerTube server where I hosted my stop-motion video was taken down och the person running it lost interest.

I needed to update the post and link to the video elsewhere. That was when I realised I didn’t save the resulting file – e.g. the stop motion. I had to regenerate the file – good thing I still had all the source images. Good thing I wrote that blog post that explained how it works.

But essentially there are a few steps to it. You need to gather all the images you have that you want to create to stop-motion from in one place. You then need to name them in sequence. If you have a small number of files you can simple do it manual. But if you, like me, have a lot of files, you want to automate that. There are many ways of doing it. A simple way is to write a small shell script that will do that for you. I created that (and you can find it in the blog post) and thus I renamed all my 1800+ files in sequence.

The next thing is to ask ffmpeg to stitch them together and produce a video for me. I didn’t want to install a ton of applications on my system so I opted for Docker. I created a docker image and mounted the directory with all the images to a folder inside the container. I ran the ffmpeg command and 2 minutes later I had the stop-motion file back. It is quite interesting that when I wrote the blog post I took more than 10minutes to generate the movie – but now I have a newer computer and it did it in 2min. Quite big change in time.

I noticed that the mpeg4 file wasn’t readable by my browser (it is from QuickTime) so I used handbreak, a small movie tool, to convert it to an mpeg4 that was readable my browser. After that I could update my blog post with the new movie.

Yes, you could have uploaded the movie to YouTube and embedded that into the site. But I have made a bit of a point to respect peoples privacy and thus not linking in any Google (or other suppliers) code. I don’t want my visitors to be tracked. There is a post about that too on the blog called “Ungoogeling the blog“.

Back to the video again. To create the images you can use a regular camera and set it to continuously taking a new image of the subject you want to create the stop motion from. You can do it with fixed time. If your are doing something more creatively you could ofcourse manually snap the frames as you need. The reason I am proposing a normal camera / DSLR is that you have better control over the result. You can control shutter and aperture and focus settings too. That way you can get better quality images – especially over time – and that will give you a better end result with a better looking stop-motion. You can of course also experiment with resolutions and fram rates to get different smoothness to the video.

Good luck and I hope you will be able to create some cool stop-motions.