Search code examples
ffmpegconcatenationaspect-ratio

how to use ffmpeg to apply 1:1 SAR before concat on large complex filter


I use ffmpeg to concat videos in a fashion similar to this:

I ran into a weird error with my inputs

[Parsed_concat_0 @ 000000002a05bb80] Input link in10:v0 parameters (size 1280x720, SAR 2049:2048) 
do not match the corresponding output link in0:v0 parameters (1280x720, SAR 1:1)

From what I've researched I need to use setsar to force all the videos to be 1:1 before I concat, but I'm not sure how to do that in my filter.


Solution

  • Add the setsar filter:

    ffmpeg -i 0.mp4 -i 1.mp4 -i 2.mp4 -filter_complex "[0:v]setsar=1[v0];[v0][1:v][2:v]concat=n=3:v=1:a=0[v]" -map "[v]" out.mp4
    

    This example is assuming that 0.mp4 is the video with the wrong SAR.