<p>I am using below command to merge two videos </p>

<pre><code>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"};
</code></pre>

<p>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</p>

<p>Changed my Command as below </p>

<pre><code>  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"};
</code></pre>

<p>getting below error</p>

<pre><code> [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.
</code></pre>

<p>Updated my command as per this</p>

<pre><code> 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"};
</code></pre>

<p>and get it working</p>

CC BY-SA 3.0
2017-06-01T11:11:01.387Z
See answer [here](https://video.stackexchange.com/q/16015/1871).
Gyan
CC BY-SA 3.0
2017-06-01T11:14:15.877Z
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
CC BY-SA 3.0
2017-06-01T11:16:33.963Z
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
CC BY-SA 3.0
2017-06-01T11:21:12.177Z
after the second video or at the output?
Akash Dubey
CC BY-SA 3.0
2017-06-01T11:31:15.507Z
@Mulvya  I have made the changes and updated my questoin
Akash Dubey
CC BY-SA 3.0
2017-06-01T11:36:11.453Z
before setsar, there should be a comma.
Gyan
CC BY-SA 3.0
2017-06-01T11:36:18.873Z
Thank you so much Sir ji you made my day
I have added that appropriately and got the expected result
Akash Dubey
CC BY-SA 3.0
2017-07-13T05:32:37.890Z
This command is not working in Nexus 5  only!!
Error Says : [Parsed_setsar_2 @ 0xb3c29360] num:den syntax is deprecated, please use num/den or named options instead
Akash Dubey
CC BY-SA 3.0
2018-01-22T09:32:20.097Z
@Mulvya
https://ffmpeg.org/pipermail/ffmpeg-user/2014-February/020004.html,
Kindly help me with it, am getting this error while merging video sometimes only, like when video is big i think
Akash Dubey
<ffmpeg><video-editor><android>
How to Merge video files having different aspect ratio and make the narrow one padded
Akash Dubey
# How to Merge video files having different aspect ratio and make the narrow one padded

(Asked by: username_0 on 2017-06-01)

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

**Tags:** ffmpeg, video-editor, android

> **Comments:**
> **username_1**: See answer [here](https://video.stackexchange.com/q/16015/1871).  
> **username_0**: 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  
> **username_1**: 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`  
> **username_0**: after the second video or at the output?  
> **username_0**: @Mulvya  I have made the changes and updated my questoin  
> **username_1**: before setsar, there should be a comma.  
> **username_0**: Thank you so much Sir ji you made my day I have added that appropriately and got the expected result  
> **username_0**: This command is not working in Nexus 5  only!! Error Says : [Parsed_setsar_2 @ 0xb3c29360] num:den syntax is deprecated, please use num/den or named options instead  
> **username_0**: @Mulvya https://ffmpeg.org/pipermail/ffmpeg-user/2014-February/020004.html, Kindly help me with it, am getting this error while merging video sometimes only, like when video is big i think  

---

## 0 answers

