How to create a FFmpeg video from images in just 5 easy steps?

Are you confused regarding how to make a photo sequence into a video easily? I will share with you how to convert image sequences into videos to make time-lapse with Ffmpeg.

 

FFmpeg is an outstanding command line tool that helps you do plenty of things with images and videos. By using ffmpeg, you can convert an image sequence into a video file. If you are here to learn how to create an ffmpeg video from images, let me help you.

 

It's an easy task to produce an FFmpeg output stream from a sequence of images. I'll detail how to do it easily, I'll simplify the process for your better understanding.

 

Shut down your worries and dive into how to create an ffmpeg video from images.

 

 

Install FFmpeg

 

First things come first. Install ffmpeg. The easiest way is to use a Mac package manager named Homebrew to install. However, if you don't have Homebrew, don’t worry, another option is to open up a terminal and then copy and paste the below text in the terminal window. Now press return.

 

"/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 

 

After that, Homebrew will start installing. Now you can easily install the ffmpeg file using Homebrew. Again, let's open up a terminal, copy and paste the below text, and then press return.

 

“brew install ffmpeg”

 

Everything is okay, and the ffmpeg file will install in no time!

 

Preparing the Images

 

If you want to get the ultimate output file how you desire, it's more significant to have the input files ready very accurately. To recognize and line up image files you input, ffmpeg does use order matching. That's because it's essential that your images stay in the right order.

 

FFmpeg implements support for almost nearly three diverse patterns. Let’s take a look at these patterns below. 

 

  • Filenames with preceding zeros, e.g. filename-%03d.png compare to images defined from filename-001.png to filename-999.png. 

 

  • File Names without preceding zeros, e.g. filename-%d.png compare to images defined from filename-1.png to filename-999.png. 

 

  • Prefixed without a regular pattern, e.g. filename-*.png compare to all images that start with the prefix filename- 

 

You don't need to follow a regular numbering order. If you use this option, you will need to have an extra parameter for the images to video conversion. We will explain this in the following section.

Remember, if any filename contains a ‘%’ character, it's not a problem at all. Just add “%%” at the positioning of the ‘%’ character to leave this problem! 

 

If all the image files are ready to create a ffmpeg video stream, let me show you how to create it.  



Create a Video From Images

 

Once you have prepared the source image files with the correct order and name, and placed them in the same directory, move ahead! You can run the below command at the command option :

 

"ffmpeg -i img-%02d.png video_name.avi"

 

FFmpeg looks for image files with file names with ‘img-‘ resulting in a two-digit number. In the command section, you will need to define a search pattern for the ffmpeg output file so that you can find the image sequence.

Basically, the search pattern will depend on what name you set for the image files when you prepare them.

Setting The Frame Rate

 

While creating a video stream from a sequence of image files, the frame rate is an important consideration. Frame rate means the number of frames per second. Keep in mind that the most suitable frame rate will rely on the source image files you input.

For example, if you're thinking of stop-motion animation, the best option will be the default of 25 fps.

 

On the other hand, if you think of a slow-moving slide show, of course, you will want a slower frame rate like 2 fps. Here is a reminder for you — if you do not set the right frame rate, the output video file will not be according to your expectation. You may find some strange results in the ultimate ffmpeg video file.

 

 

If you want to get an output video file with a 5 fps frame rate, you will need to paste the below command : 

 

"ffmpeg -framerate 5 -i img-%02d.png video.avi"



Changing the Video Format

 

In the above examples, I have shared avi video format as the final ffmpeg video output. For your better convenience, ffmpeg can support a wide range of different types of video formats. Also, you can change the output ffmpeg video format by changing the file expansion of the ultimate output ffmpeg video file. 

 

Here I share which output video setups are available you can operate : 

"ffmpeg -encoders" 

You've learned how to get an ffmpeg video from a sequence of image files. In the write-up, I've discussed some options that enable you to turn your image files into a video stream. The quality of the output file depends on the quality of your input files and their sequence!

You must follow all the options to get a sharp file ffmpeg or outstanding ffmpeg video stream.

Now let's go and create an ffmpeg video from your image sequence file!