Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ffmpeg

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.

like image 806
Abhilash Avatar asked Mar 05 '23 03:03

Abhilash


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
like image 110
Gyan Avatar answered May 17 '23 08:05

Gyan