我正在使用Ffmpeg4Android库对视频进行编码。我想通过选择它们来合并视频。我遇到的问题是如果选择肖像视频,制作的视频有旋转的视频。要解决此问题,我将根据其旋转元数据旋转视频,然后执行merge命令。 10秒高清视频耗时太长约3-5分钟。请建议我更快的方式..
旋转命令:
String[] cmd= new String[]{"ffmpeg", "-y", "-i", orginalFilePath, "-strict", "experimental", "-vf", "transpose=" + transposeby, newFilePath};
// transposeby = 1表示90degree cw
合并命令:
String[] command = new String[]{"ffmpeg", "-y", "-i", files[0], "-i", files[1], "-strict", "experimental",
"-filter_complex", "[0:v]scale=640x480,setsar=1:1[v0];[1:v]scale=640x480,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "640x480", "-r", "30", "-vcodec", "mpeg4", "-b", "2097k", newFilePath};
答案 0 :(得分:1)
组合命令。如果0:v
是旋转的视频,则在合并命令中,将[0:v]transpose=1,scale=640x480,setsar=1[v0]
与原始视频一起使用。