Problems building Image slideshow with sliding transition using ffmpeg

我的梦境 提交于 2019-12-11 01:05:18

问题


I'm trying to create image slideshow with slide transition using ffmpeg and the following command:

ffmpeg -loop 1 -i img1.jpg -loop 1 -i img2.jpg -loop 1 -i img3.jpg ^
-filter_complex ^
"nullsrc=size=800x600[v0]; ^
[0:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS[v1]; ^
[1:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS[v2]; ^
[2:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS[v3]; ^
[v0][v1]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv0]; ^
[v1][v2]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv1]; ^
[v2][v3]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv2]; ^
[vv0][vv1][vv2]concat=n=3:v=1:a=0 [video]" -map "[video]" output.mp4

I want every image to slide in from left for 0.5 seconds and stay for further 4.5 seconds, before it's being overlapped by the next one and so on.

First problem is that it takes 2-3 minutes to build video with just 3 images and I want to add more images which will result in extremely long build time.

Second problem is that video should be 15 seconds long, but it's only 8 as first image is shown for 5 seconds, second is shown for 2 and the last one just for 1 second.

Your help will be greatly appreciated.


回答1:


An input pad generated inside a filter complex can be used only once. So, you should split those streams which will be reused.

ffmpeg -loop 1 -i img1.jpg -loop 1 -i img2.jpg -loop 1 -i img3.jpg ^
-filter_complex ^
"nullsrc=size=800x600[v0]; ^
[0:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS,split[v1a][v1b]; ^
[1:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS,split[v2a][v2b]; ^
[2:v]trim=duration=5,scale=800x600,setpts=PTS-STARTPTS[v3]; ^
[v0][v1a]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv0]; ^
[v1b][v2a]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv1]; ^
[v2b][v3]overlay=x='min(-w+(t*w/0.5)\,0)':shortest=1[vv2]; ^
[vv0][vv1][vv2]concat=n=3:v=1:a=0 [video]" -map "[video]" output.mp4


来源:https://stackoverflow.com/questions/37991201/problems-building-image-slideshow-with-sliding-transition-using-ffmpeg

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