个视频之间淡入淡出的

个视频之间淡入淡出的

本文介绍了用于在 5 个视频之间淡入淡出的 FFmpeg 命令.如何管理 setpts=PTS-STARTPTS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,FFmpeg 中的新功能.我在 FFmpeg 的控制台中使用和测试.

Here, New in FFmpeg . I am using and testing in console in FFmpeg .

我已经完成了 2 个带有交叉淡入淡出的视频加入这个问题:我正在为 5 个视频合并淡入淡出我刚刚完成了 90% 的合并我只需要管理 setpts=PTS-STARTPTS 看看这个请.

ffmpeg -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i
big_buck.mp4 -filter_complex "[0:v]trim=0:4,setpts=PTS-
STARTPTS,fade=out:st=4:d=1:alpha=1[1]; [1:v]trim=1:4,setpts=PTS-
STARTPTS,format=yuva420p,fade=in:st=0:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[2];
[2:v]trim=1:4,setpts=PTS-
STARTPTS,format=yuva420p,fade=in:st=0:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[3];
[3:v]trim=1:4,setpts=PTS-
STARTPTS,format=yuva420p,fade=in:st=0:d=1:alpha=1,fade=out:st=4:d=1:alpha=1[4];
[4:v]trim=1:4,setpts=PTS-STARTPTS,format=yuva420p,fade=in:st=0:d=1:alpha=1[5];
[1][2]overlay,format=yuv420p[12]; [12][3]overlay,format=yuv420p[123]; [4]
[5]overlay,format=yuv420p[45]; [123][45]concat=n=2 [v]" -map [v]  result.mp4

****注意每个输入视频 big_buck.mp4 长度为 5 秒 ****.现在在代码中看到 setpts=PTS-STARTPTS 如何在每个视频输入中管理它???

****Note that every input video big_buck.mp4 length is 5 sec ****. now see setpts=PTS-STARTPTS in code How to Manage that in every video Input????

我也在各种论坛上看到过,但我没有找到!!!谢谢

I also see in variuos forums about that but i didnt find!!!Thank you

推荐答案

使用

ffmpeg -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i
big_buck.mp4 -filter_complex
"[0:v]setpts=PTS-STARTPTS[v1];
 [1:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(4/TB)[v2];
[2:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(8/TB)[v3];
[3:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(12/TB)[v4];
[4:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(16/TB)[v5];
[v1][v2]overlay[v12]; [v12][v3]overlay[v123]; [v123][v4]overlay[v1234]; [v1234][v5]overlay,format=yuv420p[v]"
-map [v]  result.mp4

必须修改 PTS,以便每个新剪辑在当前剪辑组合结束前 1 秒开始,即第 3 个剪辑应在 8 秒开始淡入,因为前两个剪辑的组合是 9 秒(4 秒)第一个剪辑 + 1 秒过渡 + 第二个剪辑的 4 秒).

The PTS has to be modified so that each new clip starts 1 second before the current combination of clips ends i.e. the 3rd clip should start fading in at 8 seconds, since the combination of the first two clips is 9 seconds (4 seconds of first clip + 1 second transition + 4 seconds of 2nd clip).

您不需要淡出,因为下一个剪辑在顶部淡入.仅当您想要剪切时才需要连接.

You don't need the fade out as the next clip is fading in on top. The concat is only required if you want a cut.

使用音频交叉淡入淡出:

With audio crossfades:

ffmpeg -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i big_buck.mp4 -i
big_buck.mp4 -filter_complex
"[0:v]setpts=PTS-STARTPTS[v1];
 [1:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(4/TB)[v2];
[2:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(8/TB)[v3];
[3:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(12/TB)[v4];
[4:v]format=yuva420p,fade=in:st=0:d=1:alpha=1,setpts=PTS-STARTPTS+(16/TB)[v5];
[v1][v2]overlay[12]; [12][v3]overlay[123]; [123][v4]overlay[1234]; [1234][v5]overlay,format=yuv420p[v];
[1][2]acrossfade=d=1[a12]; [a12][3]acrossfade=d=1[a123]; [a123][4]acrossfade=d=1[a];"
-map [v] -map [a] result.mp4

这篇关于用于在 5 个视频之间淡入淡出的 FFmpeg 命令.如何管理 setpts=PTS-STARTPTS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 14:56