I'm trying to stack/compose videos using xstack parameter to set my own custom layout like this:
All examples I've found are with a standard grid layout (2x2, 3x3). Is this possible or all videos needs to have the same size?
Regards
I was able to have it working.
Using the -filter_complex
parameter is quite simple:
ffmpeg -i source1.mp4 -i source2.mp4 -i panoramic.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[v01];[2:v]scale=1408:-1[v3];[v3][v01]vstack=inputs=2" -f flv output.mp4
[0:v][1:v]hstack=inputs=2[v01]
will create the horizontally stacked video that will be placed at the bottom and name it as v01 for future use.[2:v]scale=1408:-1[v3]
will scale the second video to fit the width of the video at top (in my case 704 * 2) and name it as v3[v3][v01]vstack=inputs=2
join [v3] and [v01] vertically with vstack parameter.If you wants to do it with left side stacking two of the videos vertically (as second option in the original question) and add another video to the right you can join first videos vertically and then stack it horizontally (opposite as previous one):
"[0:v][1:v]vstack=inputs=2[v01];[2:v]scale=-1:1152[v3];[v01][v3]hstack=inputs=2"
Hope it's helpful for others.
Regards