I am trying to created a video from the sequence of images. But i have to display each image with different numbers of seconds. How to do this with FFMPEG.
Thanks in advance.
There are some hints in the FFmpeg wiki. This one example (second-to-last in the wiki) in particular is likely suitable for your needs:
ffmpeg -loop 1 -f image2 -i img.png -c:v libx264 -t 30 out.mp4
where the number after -t
(30 in the example) is the duration of the video in seconds.
Simply execute that command several times like this:
ffmpeg -loop 1 -f image2 -i intro.png -c:v libx264 -t 5 out1.mp4
ffmpeg -loop 1 -f image2 -i someimage.png -c:v libx264 -t 15 out2.mp4
ffmpeg -loop 1 -f image2 -i someotherimage.png -c:v libx264 -t 25 out3.mp4
ffmpeg -loop 1 -f image2 -i outro.png -c:v libx264 -t 10 out4.mp4
And then merge the resulting videos (if you want):
Create a text file (example: videos.txt
) where the video filenames are listed.
file 'out1.mp4'
file 'out2.mp4'
file 'out3.mp4'
file 'out4.mp4'
Run this command (change filenames if needed)
ffmpeg -f concat -i videos.txt -c copy final_video.mp4
More information about video merging (concatenation) can be found in the wiki.
The ffmpeg
includes a section on exactly this: https://trac.ffmpeg.org/wiki/Slideshow
Here is an example:
Example content of input.txt
:
file '/path/to/dog.png'
duration 5
file '/path/to/cat.png'
duration 1
file '/path/to/rat.png'
duration 3
file '/path/to/tapeworm.png'
duration 2
file '/path/to/tapeworm.png'
Then run:
ffmpeg -f concat -i input.txt -vsync vfr -pix_fmt yuv420p -framerate 30 output.mp4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With