Home Linux Commandline Tools How to Create a Video From Images in Linux

How to Create a Video From Images in Linux

Before this article gives us a walkthrough on creating videos from images under a Linux operating system environment, it is important to understand the why before we engage the how.

Images Founded Videos

The concept of integrating images into videos is not rocket science as it logically takes a series of images to compose a video. Every video you watch; even your favorite YouTube videos are just a series of still images undergoing a very quick image-to-image transition. In-between these transitions is a black picture that enables the video being played to switch frames from one still image to the next one.

[ You might also like: How to Find Files Modified in Last 24 Hours in Linux ]

The image-to-image transition mechanism is too fast for the human eye to notice with optical illusion being one of the contributing factors. These images that define a created video are called frames. When you pause a playing video, you are actually looking at a frame (still image). It is the reason why a paused video might have blurry clarity in comparison to the one playing.

Measuring Videos Using Images

A frame rate depicts how many pictures transition in a single second. So if an image transitions after every 33 milliseconds, that video attributes to 30 frames per second which are somewhat 108,000 frames per hour. This concept should help you understand why 720p, 1080p, and 4K videos vary in size.

As exciting as this images-to-videos relationship is, this article guide needs to redirect its focus from advanced video editing concepts and help you transform your still images into videos.

Using ffmpeg for Images-to-Video Creation in Linux

This ffmpeg free software with its publicly available source code will help us achieve this article’s objective.

Choose one of the following installation options in relation to the Linux operating system distribution you are using.

Install FFmpeg in RHEL, CentOS, Rocky, and AlmaLinux

$ sudo dnf install epel-release 
$ sudo yum config-manager --set-enabled PowerTools 
$ sudo yum-config-manager --add-repo=https://negativo17.org/repos/epel-multimedia.repo
$ sudo dnf install ffmpeg

Install FFmpeg in Fedora Linux

$ sudo dnf install \
https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \
https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
$ sudo dnf update
$ sudo dnf install ffmpeg

Install FFmpeg in Debian, Ubuntu, and Mint

$ sudo apt-get install sshpass     [On ]

Install FFmpeg in Arch Linux

$ sudo pacman -S git
$ git clone https://aur.archlinux.org/snapd.git
$ cd snapd
$ makepkg -si
$ sudo systemctl enable --now snapd.socket
$ sudo ln -s /var/lib/snapd/snap /snap
$ sudo snap install ffmpeg

Install FFmpeg in OpenSUSE Linux

$ sudo zypper addrepo --refresh https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.2 snappy

Swap out openSUSE_Leap_15.2 with your openSUSE version e.g. openSUSE_Tumbleweed, openSUSE_Leap_15.0, or openSUSE_Leap_15.1.

Next, run the series of commands to install it.

$ sudo zypper --gpg-auto-import-keys refresh
$ sudo zypper dup --from snappy
$ sudo zypper install snapd
$ sudo systemctl enable snapd
$ sudo systemctl start snapd

The following additional commands apply to Tumbleweed users.

$ sudo systemctl enable snapd.apparmor
$ sudo systemctl start snapd.apparmor

Finally, install ffmpeg

$ sudo snap install ffmpeg    

How to Use FFmpeg for Images-to-Video Creation in Linux

Coming up with time-lapse movies and stop-motion photography are some key benefits of creating a video from a series of provided still images.

Video Images Preparation

The naming convention of your input images should be sequential since ffmpeg follows a string-matching rule to properly identify and line up these images.

Your image file-naming convention should adhere to either of the following three ffmpeg supported filename patterns.

  • With leading zeroes – The ffmpeg command segment ‘filename-%03d.png’ will look for image files with names ranging from filename-001.png to filename-999.png.
  • Without leading zeroes – The ffmpeg command segment ‘filename-%d.png’ will look for image files with names ranging from filename-1.png to filename-999.png.
  • Without a regular naming pattern – The ffmpeg command segment ‘filename-*.png’ will not follow any sequential order while looking for image files.

Creating Video from Images in Linux

The ffmpeg syntax for images-to-videos creation for image filenames with leading zeroes looks something like the following:

$ ffmpeg -framerate 10 -i filename-%03d.png output.mp4

From the above command syntax, you can set the frame rate to the desired figure and specify the output video file name.

Let us try to create a video from the following images.

$ ls
List of Images
List of Images

Since the naming convention of these image files is sequential but without leading zeroes, we will use the following ffmpeg command:

$ ffmpeg -framerate 25 -i image-%d.png output.mp4

We have set the frame rate to 25.

Create Video From Images in Linux
Create Video From Images in Linux

The expected output video file should be visible:

$ ls
Check Created Video File from Images in Linux
Check Created Video File from Images in Linux

When the images you are converting to videos do not need to follow a sequential stream; images with random names like image-00.png, image-10.png, and image-30.png, you can use the glob matching pattern as demonstrated by the following syntax:

$ ffmpeg -framerate 10 -pattern_type glob -i "image-*.png" output.mp4  
Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

3 thoughts on “How to Create a Video From Images in Linux”

  1. Thank you so much. Exactly what I needed, no less, no more.

    I had a bunch of photos named YYYY-MM-DDTHH_MM_SS.jpg in corresponding YYYY-M-DD directories ranging for almost one year. With your article, it was easy to create a timelapse of a given day or at a given time over the year.

    Reply

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.