如何使用ffmpeg创建带有填充和图像背景的并排两个视频?

时间:2019-05-23 11:55:33

标签: android ffmpeg

使用ffmpeg使用CollageView同时播放两个视频。我有代码,但无法正常工作,请帮助我。

-ss " + getStartTime()  + durationTime_act_select +getVideoUrl() +
                       " -ss " + getStartTime() +
                       " -t " + this.durationTime_act_select +
                       " -i " + getVideoUrl() +
                       " -i " + "R.jpg" +
                       " -filter_complex nullsrc=size=720*720[base1];" +
                       "[0:v]setpts=PTS-STARTPTS,scale=345*700[upperleft];" +
                       "[1:v]setpts=PTS-STARTPTS,scale=345*700[upperright];" +
                       "[2:v]setpts=PTS-STARTPTS,scale=720*720[over];" +
                       "[base1][over]overlay=shortest=1:x=0:y=0[base];"+
                       "[base][upperleft]overlay=shortest=1:x=10:y=10[tmp1];" +
                       "[tmp1][upperright]overlay=shortest=1:x=366:y=10" +
                       " -c:a copy -strict experimental -ss 0 -t " + this.durationTime_act_select + " -preset ultrafast -an " +videoName_act_select

enter image description here

1 个答案:

答案 0 :(得分:4)

根据您的要求

array2 = (FileUtils.getFFmpeg(SelectedFrameVideos.this) +
                       " -y -ss " + ((Collage) Utils.collageData.get(0)).getStartTime() +
                       " -t " + String.valueOf(this.durationTime_act_select) +
                       " -i " + ((Collage) Utils.collageData.get(0)).getVideoUrl() +
                       " -ss " + ((Collage) Utils.collageData.get(1)).getStartTime()+
                       " -t " + String.valueOf(this.durationTime_act_select) +
                       " -i " + ((Collage) Utils.collageData.get(1)).getVideoUrl() +
                       " -i " + "/storage/emulated/0/R.jpg" +
                       " -filter_complex nullsrc=size=720*720[base];" +
                       "[base][2:v]overlay=1,format=yuv420p[base1];"
                       "[0:v]setpts=PTS-STARTPTS,scale=345*700[upperleft];" +
                       "[1:v]setpts=PTS-STARTPTS,scale=345*700[upperright];" +
                       "[base1][upperleft]overlay=shortest=1:x=10:y=10[tmp1];" +
                       "[tmp1][upperright]overlay=shortest=1:x=366:y=10" +
                       " -c:a copy -strict experimental -ss 0 -t " + String.valueOf(this.durationTime_act_select) + " -preset ultrafast -an " +
                       SelectedFrameVideos.this.videoName_act_select).split(" ");

并排添加两个视频,并添加在视频填充上显示的叠加图像您可以更改背景图像“ -i” +“ /storage/emulated/0/R.jpg”在这里设置您的bg图像路径

在此下方显示此视频,并通过此命令创建视频

enter image description here