如何在 ffmpeg 中添加黑色淡入淡出过渡时连接文件列表中的视频

发布于 2025-01-19 10:06:04 字数 667 浏览 1 评论 0原文

我有一段代码可以连接文件列表中的视频。它工作完美。

ffmpeg -f concat -safe 0 -i file_list.txt -c copy mergedVideo.avi

但是,我想在每个视频之间添加黑色淡入淡出过渡。我发现这个代码片段显然可以做到这一点,但它要求您手动输入每个文件。

ffmpeg -i in.mp4 -i main.mp4 -i out.mp4 -filter_complex \
  "[0:v]fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v0]; \
   [1:v]fade=type=in:duration=2,fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v1]; \
   [2:v]fade=type=in:duration=2,setpts=PTS-STARTPTS[v2]; \
   [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" output.mp4

我希望能够从 txt 文件读取所有视频文件,因为我有数百个视频。如何组合这两个片段,或者是否有更好的方法来完成淡入淡出过渡的连接?

I have a piece of code that concats videos from a file list. It works perfectly.

ffmpeg -f concat -safe 0 -i file_list.txt -c copy mergedVideo.avi

However, I want to add a black fade transition between each video. I found this code snippet that apparently does this, but it requires you to input each file by hand.

ffmpeg -i in.mp4 -i main.mp4 -i out.mp4 -filter_complex \
  "[0:v]fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v0]; \
   [1:v]fade=type=in:duration=2,fade=type=out:duration=2:start_time=28,setpts=PTS-STARTPTS[v1]; \
   [2:v]fade=type=in:duration=2,setpts=PTS-STARTPTS[v2]; \
   [v0][0:a][v1][1:a][v2][2:a]concat=n=3:v=1:a=1[v][a]" \
  -map "[v]" -map "[a]" output.mp4

I want to be able to read all the video files from a txt file as I have hundreds of videos. How do I combine these two snippets, or is there a better way to accomplish the concat with fade transitions?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文