ffmpeg -i "a.mov" -i "b.mp4" -filter_complex "[0:v]setsar=sar=${SAR}[a]; [1:v]setsar=sar=${SAR}[b]; [a][0:a] [b][1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -preset veryfast -crf 18 "merged.mp4"

using the above code I am able to successfully merge a.mov(1920x816) with b.mov(1920x816). However, Youtube end screens require video to be 16:9 aspect ratio. Thus I tried scale filter and setting SAR to 16:9. however this leads to the output video stretching to fit the 16:9 ratio.

How can I output a video with 16:9 ratio with the actual video with resolution 1920x816. Essentially The remaining vertical space should just be black without stretching the 816 height video to fit the 1080 height.


Have you tried uploading it to Youtube? Their player window will be a fixed 16:9 ratio (on YT.com), but they should accept source videos of any ratio, and simply center it in their window during playback.

Anyway, here's the method:
ffmpeg -i "a.mov" -i "b.mp4" -filter_complex "[0:v]scale=iw*sar:ih,pad=if(gt(dar,16/9),iw,2*trunc(ih*16/9/2)):if(gt(dar,16/9),2*trunc(iw*9/16/2),ih):(ow-iw)/2:(oh-ih)/2,setsar=1[a]; [1:v]scale=iw*sar:ih,pad=if(gt(dar,16/9),iw,2*trunc(ih*16/9/2)):if(gt(dar,16/9),2*trunc(iw*9/16/2),ih):(ow-iw)/2:(oh-ih)/2,setsar=1[b]; [a][0:a] [b][1:a] concat=n=2:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" -preset veryfast -crf 18 "merged.mp4

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.