Java 如何使用长度超过2分钟的Ffmpeg并排合并视频

Java 如何使用长度超过2分钟的Ffmpeg并排合并视频,java,android,merge,video-processing,Java,Android,Merge,Video Processing,我想合并两个长度为2分钟的mp4视频,我正在使用FFMPEG命令来合并视频。这需要太多的处理时间。是否有其他方法或命令来加快速度?我也在使用-preset ultrafast,但它不起作用 这里我使用这个命令 ffmpegcommand=new String[]{“-y”,“-i”,recordedvideo,“-i”,file.toString(), “-过滤器\u复合体”, “[0:v:0]pad=iw*2:ih[bg];”+ “[bg][1:v:0]覆盖=w;”+ “[1:a]体积=0.9

我想合并两个长度为2分钟的mp4视频,我正在使用FFMPEG命令来合并视频。这需要太多的处理时间。是否有其他方法或命令来加快速度?我也在使用
-preset ultrafast
,但它不起作用

这里我使用这个命令

ffmpegcommand=new String[]{“-y”,“-i”,recordedvideo,“-i”,file.toString(),
“-过滤器\u复合体”,
“[0:v:0]pad=iw*2:ih[bg];”+
“[bg][1:v:0]覆盖=w;”+
“[1:a]体积=0.9[a];[0:a]aecho=1:0.1:“+Constant.DELAY+”:“+Constant.DECAY+”[B];[B]体积=70[C];[C][a]amix=inputs=2[a]”,
“-map”、“[a]”,
“-c:v”、“libx264”、“最短”、“预设”,
“超快”,路径+时间+“.mp4”};

您的命令的输出是什么

您是否有与ffmpeg相关的错误消息

我之所以编写这段代码,是因为偶尔我想快速连接多个视频,而不必担心每个大小和格式

具有相同和不同编解码器/格式/大小/纵横比的文件串联。

(确保每个视频都有音频!(必要时添加静音音频))


我对它进行了多次测试,效果很好。

@Dark7需要多少处理时间?我有2分钟的视频,几乎需要2分钟来合并你呢?@Muhammed Haroon我连接了两个~15分钟的视频(1920x1080,AVC)。它是以2.6倍的速度处理的,大约12分钟。@Dark同样是我的情况,它花费了太多的时间我有2分钟的视频,几乎需要1到2分钟来并排合并。我只想在12到20秒内合并它们,就像smule应用程序在smule应用程序中所做的那样,需要几秒钟才能完成merge@MuhammedHaroon你需要在“video1”之后加上“video2”吗?或者你需要左边的“video1”和右边的“video2”吗?@Dark是的,我想要两个并排的视频,一个在左边,另一个在右边不,只是需要太多的时间来减少处理时间?
    # set video size of the output
targetWidth=1024
targetHeight=576

#this scaler preserves the aspect ratio of the input video and adds padding if needed.
#a video with a size of 720x576 will be upscaled to 1350x1080 to preserve the aspect ratio and padded left and right to achieve 1920x1080.
smartScale="scale=iw*min($targetWidth/iw\,$targetHeight/ih):ih*min($targetWidth/iw\,$targetHeight/ih), pad=$targetWidth:$targetHeight:($targetWidth-iw*min($targetWidth/iw\,$targetHeight/ih))/2:($targetHeight-ih*min($targetWidth/iw\,$targetHeight/ih))/2:color=black, setdar=ratio=16/9, setfield=tff"

# inputs are scaled to the same size and given a label
# then they are concatenated
ffmpeg \
-i "01 video 1280x720.mov" \
-i "02 video 720x576.mkv" \
-i "03 video 1920x1080.mp4" \
-filter_complex "\
[0:v]${smartScale}[scaled_v0]; \
[1:v]${smartScale}[scaled_v1]; \
[2:v]${smartScale}[scaled_v2]; \
[scaled_v0][0:a][scaled_v1][1:a][scaled_v2][2:a]\
concat=n=3:v=1:a=1[v][a]" \
-map "[v]" -map "[a]" -c:v libx264 -crf 23 -c:a aac concatenated.mkv