Mosaic/grid view of RTSP streams with ffmpeg

Finally found a solution for grid/mosaic playback of RTSP streams.

ffmpeg -rtsp_transport tcp \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/101 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/201 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/301 \
-i rtsp://smartiptv:PASSWORD@192.168.2.3:6911/Streaming/Channels/401 \
-filter_complex "
nullsrc=size=1920×1080 [base];
[0:v] setpts=PTS-STARTPTS, scale=960×540 [upperleft];
[1:v] setpts=PTS-STARTPTS, scale=960×540 [upperright];
[2:v] setpts=PTS-STARTPTS, scale=960×540 [lowerleft];
[3:v] setpts=PTS-STARTPTS, scale=960×540 [lowerright];
[base][upperleft] overlay=shortest=1 [tmp1];
[tmp1][upperright] overlay=shortest=1:x=960 [tmp2];
[tmp2][lowerleft] overlay=shortest=1:y=540 [tmp3];
[tmp3][lowerright] overlay=shortest=1:x=960:y=540
" \
-c:v libx264 -preset superfast -crf 18 -f matroska – | ffplay –

Source: https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos

Author: Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s