FFMPEG:在单个视频中叠加两个带有音频的视频

FFMPEG:在单个视频中叠加两个带有音频的视频

嘿,我正在尝试用这个命令将两个音频合并到单个视频中,但它只合并了,我需要叠加它。这是我的代码:

String[] complexCommand = {"ffmpeg", "-y", "-i", "/sdcard/videokit/in.mp4", "-i", "/sdcard/videokit/bb.m4a", "-strict", "experimental", "-filter_complex", "amix=inputs=2:duration=first:dropout_transition=2",/**/ "-shortest", "/sdcard/videokit/out_water.mp4"};

之后我也尝试了这个来叠加视频,但合并后的视频是叠加的,但只有视频的第一个音频出现。代码如下:

String[] complexCommands = {"ffmpeg", "-y", "-i", "/sdcard/videokit/in.mp4", "-i", "/sdcard/videokit/tttt.mp4", "-strict", "experimental", "-filter_complex", "[0:v:0]pad=iw*2:ih[bg];" + "[bg][1:v:1]overlay=w", "-s", "320x240", "-r", "30", "-b", "15496k", "-vcodec", "mpeg4", "-ab", "48000", "-ac", "2", "-ar", "22050", "/sdcard/videokit/partik.mp4"};

答案1

你必须将两者结合起来,就像这样

String[] complexCommands = {"ffmpeg", "-y", "-i", "/sdcard/videokit/in.mp4", "-i", "/sdcard/videokit/tttt.mp4", "-strict", "experimental", "-filter_complex", "[0:v:0]pad=iw*2:ih[bg];[bg][1:v:1]overlay=w,scale=320x240;[0][1]amix=inputs=2:duration=first:dropout_transition=2", "-r", "30", "-b", "15496k", "-vcodec", "mpeg4", "-ab", "48000", "-ac", "2", "-ar", "22050", "-shortest", "/sdcard/videokit/partik.mp4"};

根据您的 FFmpeg 版本,您可能必须分配输出垫并映射它们,但请先尝试此操作。

相关内容