[FFmpeg-user] mosaic video 2x2, 3x3 etc

Paul B Mahol onemda at gmail.com
Wed Dec 9 00:12:44 CET 2015


On 12/8/15, Schui1024 <ffmpeg at mattball.co.uk> wrote:
> Hi there all
>
>
>
> So I'm a newbie when it comes to ffmpeg, though I've got a script doing
> various things.
>
>
>
> Video feed comes in with 10 second clips from multiple cameras.
>
> (ie 4 cameras, 6 x 10 second clips for each camera) resulting in 24  h264
> files.
>
>
>
> I have scripted the automatic conversion from h264 to mp4 (client can only
> deal with mp4's), watermarking and such like,
>
> and the subsequent joining of these mp4s, giving me the final result of 4 x
> 60 second mp4 files.
>
> Resolutions of these files are 1280 x 720. No audio.
>
> System is running Windows 2012 - I'm using cli and it's all running in an
> automated bat file.
>
>
>
> I've found an article to mosaic these files into a single mp4 file, which is
> 2560x720
>
> (command is : ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex
> "nullsrc=size=2560x1440 [base]; [0:v] setpts=PTS-STARTPTS, scale=1280x720
> [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=1280x720 [upperright]; [2:v]
> setpts=PTS-STARTPTS, scale=1280x720 [lowerleft]; [3:v] setpts=PTS-STARTPTS,
> scale=1280x720 [lowerright]; [base][upperleft] overlay=shortest=1 [tmp1];
> [tmp1][upperright] overlay=shortest=1:x=1280 [tmp2]; [tmp2][lowerleft]
> overlay=shortest=1:y=720 [tmp3]; [tmp3][lowerright]
> overlay=shortest=1:x=1280:y=720" -c:v libx264 quadview.mp4)
>
>
>
> This works fine when it comes to 4 feeds,
>
> My question now is.. how do I do it for more than 4? (or indeed less than 4)
>
>
>
> ie
>
> [ ] [ ] [ ]
>
> [ ] [ ] [ ]
>
>
>
> Or
>
> [ ] [ ] [ ]
>
> [ ] [ ] [ ]
>
> [ ] [ ] [ ]
>
>
>
> Also if there are only 3, or 5 total feeds, how do I "blank" the remaining
> spare or is that automatic? Can I use a black jpg to fill any gaps?
>
> My first attempt was to create a Quad view from 4 of the files, then use
> that resulting file to create another but miss out the lowerleft and shift
> over all the x/y points but couldn't get that to work (it'd be easy if I
> could)

First hstack all rows, then vstack rows, for example case 3x3:

[r1c1] [r1c2] [r1c3]
[r2c1] [r2c2] [r2c3]
[r3c1] [r3c2] [r3c3]

[r1c1][r1c2][r1c3]hstack=3[r1];
[r1c1][r1c2][r1c3]hstack=3[r2];
[r1c1][r1c2][r1c3]hstack=3[r3];
[r1][r2][r3]vstack=3

For blank use: -f lavfi -i color=s=WxH:color=black

>
> Else is there another application (cli) that I can use to do this?  I don't
> see it ever being more than 9 in total.
>
>
>
> So apologies for asking what may seem to be a simple question, however it's
> above and beyond my current skillset!
>
>
>
> Thank you in advance..
>
>
>
> Schui1024
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>


More information about the ffmpeg-user mailing list