![Ffmpeg filter complex scale](https://cdn2.cdnme.se/5447227/9-3/screenshot_1_64e629469606ee7f889a24a7.jpg)
The full command to stack both videos using the filter is: ffmpeg -i. The second video stream will be scaled to match the main video. scale2ref also supports the following additional constants for the 'w' and 'h' options:įor the main input video's sample aspect ratio: scale2ref supports the same but uses the reference video instead of the main input as the basis. The scale2ref method scales or resizes the input video based on a reference video. The custom filter will be: scale2ref='oh*mdar':'if(lt(main_h,ih),ih,main_h)' The command will receive the 2 videos as input and will use a complex filter that needs to be replaced. right-side-video.mp4 -filter_complex "" -map "" -ac 2. The command to do the trick will be the following one: ffmpeg -i. The first option to stack the videos horizontally will be through a complex filter. In this article, I will explain to you how to stack 2 videos with different resolution horizontally using FFmpeg. The idea is to place them in a single video stacked horizontally, while the final video keeps the audio of both as well.
![ffmpeg filter complex scale ffmpeg filter complex scale](https://i.stack.imgur.com/bRg4z.jpg)
As both of them have different cameras that record at a different resolution, both videos have different dimensions:
![ffmpeg filter complex scale ffmpeg filter complex scale](https://i.imgur.com/qcHvAz0.jpg)
For this article, we will work with these 2 videos recorded from a web camera stream, one from a teacher and the other from a student. However, in practice, there will be cases where the videos won't have the same dimensions. This filter allows you to create easily build a mosaic from many videos as long as they have the same resolution. Stacking videos horizontally is easy according to the documentation of FFmpeg using the hstack filter.
![Ffmpeg filter complex scale](https://cdn2.cdnme.se/5447227/9-3/screenshot_1_64e629469606ee7f889a24a7.jpg)