合并音频和视频,并在其顶部与ffmpeg添加覆盖层

发布于 2025-02-13 20:30:49 字数 705 浏览 2 评论 0原文

我正在为Python编程一个简单的脚本,以通过MP3从静态图像中制作视频,并在其顶部添加覆盖层。 此覆盖层是视频,透明或黑色(屏幕),例如移动的徽标。

覆盖持续时间为5分钟。 我所有的MP3都在5分钟以下(通常为2-3分钟),因此视频应具有音频的持续时间,而不是覆盖层。 覆盖尺寸始终是1920x1080,以及我的图像,因此我不必处理决议。

我正在使用RAW FFMPEG命令来实现它,但是我坚持使用filter_complex,以添加覆盖层。文档似乎很复杂,我无法理解。 这是我所拥有的:

ffmpeg -r 25 -loop 1 -i nature.jpg -i nature_sound.mp3 -acodec copy \
       -shortest -pix_fmt yuv420p nature_video.mp4

如何在自然上添加mp4视频覆盖层。我想学习那些过滤室,如果有人能帮助我一些细节,那就太好了!谢谢。

[更新命令]

ffmpeg -r 25 -loop 1 -i ./nature.jpg -i ./overlay.mp4 -i nature_sound.mp3 \
  -filter_complex "[1]setsar=sar=1,format=rgba [video]; [0][video]blend=all_mode=screen[out]" \
  -map [out] output.mp4

I'm programming a simple script in Python to make a video from a static image with an mp3, and add an overlay on top of it.
This overlay is a video, transparent or black (Screen) for example a logo that moves.

The overlay duration is 5minutes.
All my mp3 are under 5min (generally 2-3min), so the video should have the duration of the audio, not the overlay.
The overlay size is always 1920x1080, as well as my image so I don't have to deal with resolutions.

I'm using raw FFMpeg command to achieve it, but I'm stuck to filter_complex things, in order to add the overlay. The docs seems so complicated, I can't get it.
Here is what I have:

ffmpeg -r 25 -loop 1 -i nature.jpg -i nature_sound.mp3 -acodec copy \
       -shortest -pix_fmt yuv420p nature_video.mp4

How to add an MP4 video overlay on top of the nature.jpg, and the whole video having only the sound of nature_sound.mp3? I would like to learn those filter complex, if anyone can help me with some details it would be great! Thank you.

[updated command]

ffmpeg -r 25 -loop 1 -i ./nature.jpg -i ./overlay.mp4 -i nature_sound.mp3 \
  -filter_complex "[1]setsar=sar=1,format=rgba [video]; [0][video]blend=all_mode=screen[out]" \
  -map [out] output.mp4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

牛↙奶布丁 2025-02-20 20:30:50

它应该像:

ffmpeg ... -i nature.jpg -i nature_sound.mp3 -i overlay.mp4 \
  -filter_complex [0:v][2:v]overlay ...

It should be as simple as:

ffmpeg ... -i nature.jpg -i nature_sound.mp3 -i overlay.mp4 \
  -filter_complex [0:v][2:v]overlay ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文