Showing posts with label create png file to a video mp4. Show all posts
Showing posts with label create png file to a video mp4. Show all posts

Wednesday, June 23, 2021

ffmpeg - Create a Video from Images

To create a video from images, you must have used software like Kdenlive and Shotcut. Yeah it is quite easy and fast in Shotcut but you cannot use UI softwares everytime for your task.

If you need to automate this task, you must need scripting. ffmpeg is an excellent command line tool to perform audio and video jobs.

Suppose you have six-seven images which you want to convert in a video, you have to consider these two important points.

1) Images should not appear and disappear abruptly. They should have some effect. Fade in and Fade out is the best effect you can add for your video.

2) All images should have same size, you will find this important when you will see a video of images with different size.

Here I have used image names 1.jpg, 2.png, 3.png, 4.png, 5.png, 6.png and 7.png. You can use jpeg/jpg images also. I have used first image as a black image, it provides correct effect of fade in when second image (originally my first) appears. Resolution of my images are 1312 x 706

This is the command to generate video from images.

ffmpeg -loop 1 -t 5 -i 1.jpg -loop 1 -t 5 -i 2.png -loop 1 -t 5 -i 3.png -loop 1 -t 5 -i 4.png -loop 1 -t 5 -i 5.png -loop 1 -t 5 -i 6.png -loop 1 -t 5 -i 7.png -filter_complex "[0:v]fade=t=out:st=4:d=1[v0]; \
 [1:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
 [2:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
 [3:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v3]; \
 [4:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v4]; \
 [5:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v5]; \
 [6:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v6]; \
 [v0][v1][v2][v3][v4][v5][v6]concat=n=7:v=1:a=0,format=yuv420p[v]" -map "[v]" ouptput.mp4
First try with seven images for creating a video and make good understanding of command. Then you can reduce or increase number of images, you will find where exactly you have to make changes in the command.