FFmpeg命令用于在5个视频之间进行交叉淡化。如何管理setpts = PTS-STARTPTS? [英] FFmpeg command for crossfading between 5 videos .How to manage setpts=PTS-STARTPTS?

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

问题描述

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


我已经完成了2个视频加入与这个问题的交叉衰落:
我正在为5个视频合并交叉淡入淡出我刚刚完成90%的合并
i只需要管理setpts = PTS-STARTPTS只需查看这个pls。




  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: = 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]覆盖,格式= YUV420P [12]; [12] [3]覆盖,格式= 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 在代码中如何管理每个视频输入??? ?



我也在variuos论坛上看到,但我没有找到!!!
谢谢

解决方案

使用

  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]覆盖[V123]; [V123] [V4]覆盖[V1234]; [v1234] [v5] overlay,format = yuv420p [v]\
-map [v] result.mp4

PTS必须进行修改,以便每个新剪辑在剪辑的当前组合结束之前开始1秒,即第3个剪辑应该在8秒钟开始衰落,因为前两个剪辑的组合是9秒(第一个剪辑的4秒+第二个剪辑+ 4秒的转换)。



您不需要淡出,因为下一个剪辑正在淡入淡出






带有音频交叉淡入淡出:

  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]覆盖[123]; [123] [V4]覆盖[1234]; [1234] [V5]覆盖,格式= YUV420P [V]; \
[1] [2] acrossfade = d = 1 [a12]; [A12] [3] = acrossfade d = 1的[A123]; [A123] [4] = acrossfade d = 1的[A1234]; [a1234] [5] acrossfade = d = 1 [a];\
-map [v] -map [a] result.mp4


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

I already done with 2 video join with cross fading with this question : I am doing for 5 videos merging with cross fade I just done 90% in merging i just need to manage setpts=PTS-STARTPTS Just look into this pls.

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

****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

解决方案

Use

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

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[a1234]; [a1234][5]acrossfade=d=1[a];" \
-map [v] -map [a] result.mp4

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

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