Using FFmpeg to join images with different timly distance [duplicate]

你。 提交于 2019-12-04 05:08:24

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/29729069/using-ffmpeg-to-join-images-with-different-timly-distance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!