Using FFmpeg to join images with different timly d

2020-04-22 01:43发布

I have a set of images from which I try to create a slide show. On this website I found the following command to do so:

ffmpeg -framerate 1/5 -start_number 126 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4

I got it working fine. But in my case I need to have each images to be displayed a different period of time. How can I achieve this?

2条回答
老娘就宠你
2楼-- · 2020-04-22 02:11

So it is some time ago I asked this question an there is no answer yet. I also did not find one by myself. I solved the task in my case by creating simbolic links for each frame pointing to the correct image. Then I set the framerate to 1. So for each second I want to display an image I have a symbolic link pointing to it.

One can of course also just copy the files accordingly. Depending on the total number of frames of the video this can result in a lot of disk space used. So I went with the links.

查看更多
叛逆
3楼-- · 2020-04-22 02:12

You can try the concat demuxer and provide the duration for each frame.

  1. Make text file containing the path to your inputs and the duration for each:

    file '/path/to/image0.png'
    duration 2
    file '/path/to/image1.png'
    duration 5
    file '/path/to/image2.png'
    duration 1.5
    file '/path/to/image3.png'
    duration 4
    
  2. Then run ffmpeg:

    ffmpeg -f concat -i input.txt -pix_fmt yuv420p -movflags +faststart output.mp4
    

Notes:

  • See the concat demuxer documentation for more info.

  • The example won't work with an old ffmpeg, so make sure to download a recent build first since FFmpeg development is so active.

查看更多
登录 后发表回答