In this tutorial, we will learn how to merge up to 10 images from a single folder to create a video using FFmpeg on a Linux Debian machine. We will start with simple iterations and gradually add more complex features to our video.

With this tutorial, you will be able to create a video from images of different resolutions and formats, add background music, and create videos in different resolutions.

Prerequisites to Create a Video from Images using FFmpeg

Iteration 1: Merging Images into a Video

Let’s start by merging our images into a video with the following specifications:

Here’s the command to achieve this:

$ ffmpeg -framerate 1/4 -i %03d.jpg -vf scale=1280:720 -c:v libx264 -crf 18 output.mp4

Let’s break down the command:

Iteration 2: Adding Text to the Images

Now, let’s add text to our images:

We’ll use FFmpeg’s drawtext filter to achieve this:

$ ffmpeg -framerate 1/4 -i %03d.jpg -vf "drawtext=text='Namaskar':x=w/2:y=24:fontsize=24:fontcolor=white,drawtext=text='Sample Text':x=w/2:y=h-24:fontsize=24:fontcolor=white[1-8],drawtext=text='Dhanyawaad':x=w/2:y=24:fontsize=24:fontcolor=white[9]" -vf scale=1280:720 -c:v libx264 -crf 18 output.mp4

Here’s what’s changed:

Iteration 3: Adding Background Music

Let’s add some background music to our video:

$ ffmpeg -framerate 1/4 -i %03d.jpg -vf "drawtext=text='Namaskar':x=w/2:y=24:fontsize=24:fontcolor=white,drawtext=text='Sample Text':x=w/2:y=h-24:fontsize=24:fontcolor=white[1-8],drawtext=text='Dhanyawaad':x=w/2:y=24:fontsize=24:fontcolor=white[9]" -vf scale=1280:720 -c:v libx264 -crf 18 -i background_music.mp3 -c:a aac -b:a 128k output.mp4

Here’s what’s changed:

Iteration 4: Handling Different Image Resolutions and Formats

Let’s modify our command to handle images of different resolutions and formats (e.g., .jpg, .png, .webp):

$ ffmpeg -framerate 1/4 -i %03d.* -vf scale=1280:720 -c:v libx264 -crf 18 output.mp4

Here’s what’s changed:

Creating a 1080p Video

To create a 1080p video, simply modify the scale filter:

$ ffmpeg -framerate 1/4 -i %03d.* -vf scale=1920:1080 -c:v libx264 -crf 18 output_1080p.mp4

Creating a 4K Video

To create a 4K video, modify the scale filter:

Creating a 4K Video

$ ffmpeg -framerate 1/4 -i %03d.* -vf scale=3840:2160 -c:v libx264 -crf 18 output_4k.mp4

That’s it! You should now be able to successfully create a video from images, add text to the images, and create videos in different resolutions using FFmpeg on a Linux Debian machine.


This post was originally published on my blog at amarvyas.in and has been updated and archived in May 2025