I am using Ffmpeg4Android library to encode videos. I want to merge videos by selecting them. The problem I faced is if a select portrait videos, the produced video has the rotated videos. To resolve this issue I am rotating the video based on its rotation metadata then I am executing merge command. It is taking too long approx 3-5 minutes for 10 sec HD video. Please suggest me the faster way..
Rotation command:
String[] cmd= new String[]{"ffmpeg", "-y", "-i", orginalFilePath, "-strict", "experimental", "-vf", "transpose=" + transposeby, newFilePath};
//transposeby=1 for 90degree cw
Merge Command:
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};
Combine the commands. If 0:v
is the rotated video, then in the merge command, use [0:v]transpose=1,scale=640x480,setsar=1[v0]
with original video.