FFmpeg Slideshow + Audio + Watermark + Maintain Aspect Ratio

对着背影说爱祢 提交于 2019-12-12 04:16:44

问题


I'm trying to make a slideshow from some pictures along with an existing mp3 (copied). Picture dimensions differ, but I want the video output to be 16:9 aspect ratio and 3840x2160. I also want a watermark. It is important that pictures are not stretched.

I tried this code...

ffmpeg -y -framerate 1/1.5 -i "pics/%03d.jpg" -i audio.mp3 -c:v libx264 -r 24 -preset veryfast -tune stillimage -c:a copy -pix_fmt yuv420p -aspect 16:9 -filter_complex "scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih),pad=3840:2160:(3840-iw)/2:(2160-ih)/2, movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" vid.mkv

But it is giving me this error:

[AVFilterGraph @ 0x2d21480] Too many inputs specified for the "movie" filter. Error initializing complex filters. Invalid argument

I am able to successfully make a slideshow with pictures, audio, and watermark; however, I am unable to factor in the aspect ratio without having pictures getting stretched.

If it makes a difference, the output video will be uploaded to YouTube.


回答1:


You can remove the aspect flag. Since your filter output is 3840x2160, which is 16:9, you don't need it. Your scale filter works for me with images of varying ratios.

Here's a full command for you to try:

ffmpeg -y -framerate 2/3 -i "pics/%03d.jpg" -i audio.mp3 -loop 1 -i watermark.png
-filter_complex
 "[0:v]scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih),
 pad=3840:2160:(3840-iw)/2:(2160-ih)/2[ss];
 [ss][2:v] overlay=main_w-overlay_w-10:main_h-overlay_h-10:shortest=1[out]"
 -map "[out]" -map 1:a
 -c:v libx264 -r 24 -preset veryfast -tune stillimage -pix_fmt yuv420p
 -c:a copy
vid.mkv


来源:https://stackoverflow.com/questions/34827238/ffmpeg-slideshow-audio-watermark-maintain-aspect-ratio

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