FFmpeg幻灯片+音频+水印+保持长宽比 [英] FFmpeg Slideshow + Audio + Watermark + Maintain Aspect Ratio

查看:1111
本文介绍了FFmpeg幻灯片+音频+水印+保持长宽比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从一些图片和现有的mp3(复制)进行幻灯片放映。图片尺寸不同,但我希望视频输出为16:9宽高比和3840x2160。我也想要一个水印。重要的是图片不会拉伸。

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

但是它给我这个错误:


[AVFilterGraph @ 0x2d21480]为电影
过滤器指定的输入太多。初始化复杂过滤器时出错。无效的参数

[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.

如果有所作为,输出视频将被上传到YouTube。

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

推荐答案

您可以删除aspect标志。由于您的过滤器输出为3840x2160,为16:9,因此您不需要它。您的缩放过滤器适用于我,具有不同比例的图像。

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

这篇关于FFmpeg幻灯片+音频+水印+保持长宽比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆