gpt4 book ai didi

android - ffmpeg - 在 5 个视频之间进行淡入淡出

转载 作者:行者123 更新时间:2023-12-04 23:27:36 25 4
gpt4 key购买 nike

我想制作一个小型幻灯片应用程序,它能够通过使用 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";

更新 1:添加日志

Please download the log file here

如果我在命令中做错了什么,请告诉我。任何帮助,将不胜感激。

先感谢您!

最佳答案

我的命令少了一句话:"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";

希望它可以帮助!

关于android - ffmpeg - 在 5 个视频之间进行淡入淡出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37983758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com