I am using below command to merge two videos
complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-strict", "experimental", "-filter_complex",
"[0:v]scale=1920x1080,setsar=1:1[v0];[1:v]scale=1920x1080,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264","-crf","27","-q","4","-preset", "ultrafast", rootPath + "/output.mp4"};
this command works well for merging but me second file is in portrait having black portion at both side and ratio of 1920*1080 and first video file is in landscape having ratio of 1920*1080. now the resulting video has been made by stretching the second video maintaining the ratio of 1920*1080 Now My issue is I want to add padding two second video but i could't found any suitable command to edit my command Any help appreciated
Changed my Command as below
complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-strict", "experimental", "-filter_complex",
"[0:v]scale=1920x1080,setsar=1:1[v0];[1:v] scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2 setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264","-crf","27","-q","4","-preset", "ultrafast", rootPath + "/output.mp4"};
getting below error
[Parsed_setsar_1 @ 0xb4f29b80] num:den syntax is deprecated, please use num/den or named options instead
[pad @ 0xb4f762a0] Invalid 0xRRGGBB[AA] color string: '1'
[pad @ 0xb4f762a0] Unable to parse option value "1" as color
[pad @ 0xb4f762a0] Invalid 0xRRGGBB[AA] color string: '1'
[pad @ 0xb4f762a0] Unable to parse option value "1" as color
[pad @ 0xb4f762a0] Error setting option color to value 1.
[Parsed_pad_3 @ 0xb4f29c20] Error applying options to the filter.
[AVFilterGraph @ 0xb4f17040] Error initializing filter 'pad' with args '1920:1080:(1920-iw*min(1920/iw,1080/ih))/2:(1080-ih*min(1920/iw,1080/ih))/2 setsar=1:1'
Error initializing complex filters.
Updated my command as per this
complexCommand = new String[]{"-y", "-i", file1.toString(), "-i", file2.toString(), "-strict", "experimental", "-filter_complex",
"[0:v]scale=1920x1080,setsar=1:1[v0];[1:v] scale=iw*min(1920/iw\\,1080/ih):ih*min(1920/iw\\,1080/ih), pad=1920:1080:(1920-iw*min(1920/iw\\,1080/ih))/2:(1080-ih*min(1920/iw\\,1080/ih))/2,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1",
"-ab", "48000", "-ac", "2", "-ar", "22050", "-s", "1920x1080", "-vcodec", "libx264","-crf","27","-q","4","-preset", "ultrafast", rootPath + "/output.mp4"};
and get it working
scale=1920x1080
withscale=iw*min(1920/iw\,1080/ih):ih*min(1920/iw\,1080/ih),pad=1920:1080:(1920-iw*min(1920/iw\,1080/ih))/2:(1080-ih*min(1920/iw\,1080/ih))/2
– Gyan Jun 1 '17 at 11:16