2

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

  • 2
    See answer here. – Gyan Jun 1 '17 at 11:11
  • Sir I have refer that command but I am not able to implement it in my command, I am not that good at making command Can you tell please guide me where and what should be changed in my command – Akash Dubey Jun 1 '17 at 11:14
  • Replace the scale=1920x1080 with 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 – Gyan Jun 1 '17 at 11:16
  • after the second video or at the output? – Akash Dubey Jun 1 '17 at 11:21
  • 2
    before setsar, there should be a comma. – Gyan Jun 1 '17 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.