brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: ffmpeg -framerate 10 -i 'img-%03d.jpeg' turns numbered pictures into a video

Ffmpeg
~/tips/tip-ffmpeg-image-sequence-to-video

ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv

Builds a video from a folder of numbered images, with the frame rate you pick.

A folder of numbered photos is basically a video that has not been assembled yet. ffmpeg can read such a sequence directly, so a slideshow or time-lapse is one command.

The image2 demuxer takes a pattern. The docs say the pattern may contain %d or %0Nd, where N is the number of digits. A name like img-001.jpeg matches img-%03d.jpeg. The manual’s own example is:

ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv

Here -framerate 10 means ten pictures per second, so 300 pictures give a 30 second film. Leave it out and the docs say the frame rate defaults to 25. The quotes matter in a shell, so the pattern reaches ffmpeg instead of being expanded.

If your numbering does not begin at the default index, -start_number sets the first file to read. The docs example starts at 100:

ffmpeg -framerate 10 -start_number 100 -i 'img-%03d.jpeg' out.mkv

The default start is 0, and the sequence has to be gapless: this is a pattern, not a list. If one number is missing, the video ends there or skips, so look at the folder first.

-start_number and -framerate are both written before the input in the manual’s examples.

This pairs well with a camera that saves numbered stills, and it is where I would start for any time-lapse. The pictures need the same size. I would also check what the default output encoder gives you for the extension you choose, since an .mkv or .mp4 can come out with different codecs and settings, and a quick ffprobe shows it.

Further reading: ffmpeg formats documentation: image2 demuxer

More Ffmpeg tips ffmpeg -stream_loop 2 -i in.mp4 -c copy out.mp4 ffmpeg -i in.mp4 \ ffmpeg -i video.mp4 -i video.en.srt -map 0 -map 1 -c copy -c:s mov_text -metadata:s:s:0 language=eng video-subs.mp4 ffmpeg -i film.mkv -map 0:v -map 0:a:0 -c:v copy -c:a aac -b:a 192k -ac 2 film-stereo.mkv ffmpeg -i talk.mp4 -vn -c:a copy talk.m4a All Ffmpeg tips (38) All topics

Link