How to equalise heights of two videos to be used in hstack ffmpeg

Viewed 1087

I want to combine two videos using hstack in ffmpeg. The problem is that the two videos have different heights. And the heights can vary as the sources are dynamic. So how can I equalise the video heights to the maximum height of them and hstack them.

1 Answers

You'll need to run the scale2ref filter twice.

Basic template is

ffmpeg -i in1 -i in2 -filter_complex
       "[0][1]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[0s][1s];
        [1s][0s]scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)'[1s][0s];
        [0s][1s]hstack,setsar=1"   output
Related