Merge multiple videos to a split-screen video with FFMPEG

974 Views Asked by At

I am new to ffmpeg, and I need some help:

I am writing an App that merges multiple videos to a single split-screen video. The user can set the size and position of each video. I implemented the merging by using a video.js stream merger. This works great on my notebook, but it won't work on older devices, so I decided to do the merging server-side with ffmpeg. I am struggling to achieve this. I tried it using the xstack, but how can I set the position of each video?`And how can i tell ffmpeg to enable the audio of each video? Is it possible to use the xstack in ffmpeg.js? It would be nice, because it is easier for me to deploy(as a firebase function) By now i tried it with a fixed amount of input files :

.\ffmpeg -i .\input0.webm -i input1.webm -i .\input2.webm -i .\input3.webm -filte
r_complex "[0:v][1:v][2:v][3:v]xstack=inputs=4:layout=0_0|w0_0|0_h0|w0_h0[v]" -map "[v]"   -map 0:a -map 1:a  -map 2:a -
map 3:a output2.webm

But I need to automate the call based on the user input. This works, but there is no audio, and I can't set the position of each video like I want to.

Update:

This is a snapshot of a possible user input I just don't know how/If I can use the layout option to make something like this.

0

There are 0 best solutions below