我想创建一个小型幻灯片应用程序,它可以使用ffmpeg4android在多个视频之间执行淡入,淡出和交叉渐变等效果。
经过几个小时的研究,我仍然陷入了交叉淡化的困境。在suggestion之后,我可以创建一个交叉淡入淡出,但它不能很好地工作。
问题在于我想要将5个视频与它们之间的交叉渐变效果结合起来,每个视频的持续时间为5秒。因此,输出文件只有5秒而不是25秒,并且在输出文件的末尾有一个交叉渐变效果。
这是我的命令:
String commandStr = "ffmpeg " +
"-y " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/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] " +
"/sdcard/videokit/result.mp4";
Please download the log file here
如果我的命令出错了,请告诉我。任何帮助将不胜感激。
提前谢谢!
答案 0 :(得分:0)
我的命令错过了一句话:"color=black:1280x720:d=21[v0];"
。
d = 21是所有视频的总持续时间减去总交叉淡入淡出时间:
d = video1duration + ... video5duration - fadetime*(totalNumberOfVideo - 1)
。
在我的情况下,每个视频的持续时间是5秒,有5个视频,淡入淡出时间是1秒。
d = 5 + 5 + 5 + 5 + 5 - 1*(5-1) = 21
String commandStr = "ffmpeg " +
"-y " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-i /sdcard/videokit/big_buck.mp4 " +
"-filter_complex " +
"color=black:1280x720:d=21[v0];" +
"[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];" +
"[v0][v1]overlay[v01];[v01][v2]overlay[v012];[v012][v3]overlay[v0123];[v0123][v4]overlay[v01234];[v01234][v5]overlay,format=yuv420p[v] " +
"-map [v] " +
"/sdcard/videokit/result.mp4";
希望它有所帮助!