1. APRIL 2021

Menu

Convert images to a single video

There are several approaches here. The order of the images is problematic. The easiest way would be by:

cat *.jpg | ffmpeg -f image2pipe -r 25 -vcodec mjpeg -i - test.mp4

A warning is issued here because the pipe is aborted and ffmpeg does not seem to be able to recognize this.

Another method would be via image names which contain a sequential counter in the file name. If this is not the case, the file names can be changed as follows:

#!/bin/bash

COUNTER=1
for i in *.jpg; do
        NEW_FILENAME=$(printf "%04d.jpg" "$COUNTER")
        mv -i -- "$i" "$NEW_FILENAME"
        let COUNTER=COUNTER+1
done

The video can be created using:

ffmpeg -start_number 1 -i %04d.jpg -vcodec mpeg4 test.avi

In this case, the 4 fixed numerical digits on the left are filled in with 0. If the number is higher, the mask %04d must be changed accordingly.




Document-ID: blog/47e63355-cbfa-4e29-b6d7-6613d6ed270c



Home - Keywords - Sitemap - Imprint