VLC mosaic monitor – howto tile view of all IP camera feeds

Have some questions or having issues with your IP Camera(s), Post them here for the mods and other users to assist you with.
Post Reply
CronoBandit
Posts: 12
Joined: Tue Jan 14, 2020 6:38 am

VLC mosaic monitor – howto tile view of all IP camera feeds

Post by CronoBandit »

For those of you familiar with the VLC media player, with some effort authoring a custom config file, you can create a basic mosaic view of all camera feeds at once. For those of us without a NVR/DVR, this is a handy way of getting that view-all-at-a-glance feature back . . . perhaps mounting it somewhere in the house as a dedicated monitoring station.

Overview:

I’m only using VLC on a single Linux system (Ubuntu), to pull all the low-res streams from my cams, by creating a vlm.conf file to tell VLC where to fetch the feeds from, how to arrange them into a mosaic, and then present the output to the screen/monitor of that same linux system.
Note: since VLC also runs on Windows & Mac, theoretically this should work as well on those systems (although I have only attempted this on Linux so far).

Prerequisites:

Linux system having a graphical environment (aka xorg-server) and the latest VLC player installed.

Next, you will need to create one custom config file, and create one blank jpeg image file of specific height/width.

Details:

Creating the proper vlm.conf syntax really is the "secret sauce" here. It took me tons of googling, reading the docs, and various examples to finally figure it out enough to author this little gem . . .

Step 1 - Create a new text file called “mosaic-vlm.conf”, and put the following in it :

Code: Select all

### VLC (VLM) configuration: A 3x3 grid (9) tile mosaic of 8 IP Cam sources

## 1 ##
new IPC1 broadcast enabled
setup IPC1 option rtsp-tcp=enabled
setup IPC1 option rtsp-user=yourusername
setup IPC1 option rtsp-pwd=yourpassword
setup IPC1 input "rtsp://ipaddress1:554/cam/realmonitor?channel=1&subtype=1"
setup IPC1 output #duplicate{dst=mosaic-bridge{id=1},select=video}

## 2 ##
new IPC2 broadcast enabled
setup IPC2 option rtsp-tcp=enabled
setup IPC2 option rtsp-user=yourusername
setup IPC2 option rtsp-pwd=yourpassword
setup IPC2 input "rtsp://ipaddress2:554/cam/realmonitor?channel=1&subtype=1"
setup IPC2 output #duplicate{dst=mosaic-bridge{id=2},select=video}

## 3 ##
new IPC3 broadcast enabled
setup IPC3 option rtsp-tcp=enabled
setup IPC3 option rtsp-user=yourusername
setup IPC3 option rtsp-pwd=yourpassword
setup IPC3 input "rtsp://ipaddress3:554/cam/realmonitor?channel=1&subtype=1"
setup IPC3 output #duplicate{dst=mosaic-bridge{id=3},select=video}

## 4 ##
new IPC4 broadcast enabled
setup IPC4 option rtsp-tcp=enabled
setup IPC4 option rtsp-user=yourusername
setup IPC4 option rtsp-pwd=yourpassword
setup IPC4 input "rtsp://ipaddress4:554/cam/realmonitor?channel=1&subtype=1"
setup IPC4 output #duplicate{dst=mosaic-bridge{id=4},select=video}

## 5 ##
new IPC5 broadcast enabled
setup IPC5 option rtsp-tcp=enabled
setup IPC5 option rtsp-user=yourusername
setup IPC5 option rtsp-pwd=yourpassword
setup IPC5 input "rtsp://ipaddress5:554/cam/realmonitor?channel=1&subtype=1"
setup IPC5 output #duplicate{dst=mosaic-bridge{id=5},select=video}

## 6 ##
new IPC6 broadcast enabled
setup IPC6 option rtsp-tcp=enabled
setup IPC6 option rtsp-user=yourusername
setup IPC6 option rtsp-pwd=yourpassword
setup IPC6 input "rtsp://ipaddress6:554/cam/realmonitor?channel=1&subtype=1"
setup IPC6 output #duplicate{dst=mosaic-bridge{id=6},select=video}

## 7 ##
new IPC7 broadcast enabled
setup IPC7 option rtsp-tcp=enabled
setup IPC7 option rtsp-user=yourusername
setup IPC7 option rtsp-pwd=yourpassword
setup IPC7 input "rtsp://ipaddress7:554/cam/realmonitor?channel=1&subtype=1"
setup IPC7 output #duplicate{dst=mosaic-bridge{id=7},select=video}

## 8 ##
new IPC8 broadcast enabled
setup IPC8 option rtsp-tcp=enabled
setup IPC8 option rtsp-user=yourusername
setup IPC8 option rtsp-pwd=yourpassword
setup IPC8 input "rtsp://ipaddress8:554/cam/realmonitor?channel=1&subtype=1"
setup IPC8 output #duplicate{dst=mosaic-bridge{id=8},select=video}

## MOSAIC ##
new mosaic broadcast enabled
setup mosaic option image-fps=4/1
setup mosaic input /path/the/image/1600x1024.jpg
setup mosaic output #transcode{sfilter=mosaic{width=1600,height=1024,rows=3,cols=3,borderw=2,borderh=2,position=1,order="6,4,2,7,1,5,8,3"},vcodec=mp4v}:display

## Launch ##
control IPC1 play
control IPC2 play
control IPC3 play
control IPC4 play
control IPC5 play
control IPC6 play
control IPC7 play
control IPC8 play
control mosaic play
Of course, customize the above to your environment. In the rtsp URLs, please remember your cam IP addresses. Your cam's username & passwords.

Step 2 - Next, you will need to create a jpeg image file named “1600x1024.jpg”. Obviously, by the name, you need to make the image 1600px wide and 1024px tall. You can make it all one color, black, white, etc . . . (mine is dark gray). Save this file on your system, and make sure the path in the file above matches so VLC can find it.

At this point, you should now have your own custom “mosaic-vlm.conf” file, and one blank jpeg file called “1600x1024.jpg”. Now all that’s left is to launch VLC !!! But don’t do it from the GUI icon/menu.

Step 3 - Drop down to a terminal window, make sure you are in the same location of that conf file, and launch VLC from the CLI, using the following syntax :

Code: Select all

vlc -I dummy --image-duration -1 --vlm-conf mosaic-vlm.conf 
You should then see a new graphical window appear with all the cams you defined.

Side-notes:

Changing the screen size. You can try any height/width you like, as VLC will try to automatically resize each camera view. There are two key areas that need modification: Firstly, you need a new blank jpeg file to the new size. Next, you need to edit the values in the “sfilter=” line ( width=1600,height=1024 ).

Changing Number of camera’s. In the “sfilter=” line, the “row=3,cols=3,” is how you define the mosaic grid.

order="6,4,2,7,1,5,8,3" < - - you can define any order of your cams on the mosaic.

option rtsp-tcp=enabled < - - this was needed to make the rstp streams more reliable.

--image-duration -1 < - - this CLI arg is needed to keep the VLC screen open.

General bandwidth concerns < - - As not to draw too much traffic/resources and not saturate my my home LAN, I decided to employ two measures; a) pull only the low-resolution streams (aka subtype 1) from the cameras, and b) drop the frame-rate on subtype 1 all the cams to a slow 4 FPS.

Passwords < - - So “I” have created a basic user on all my cams just for viewing and playback. I set its password very plain-jane, just alphanumeric, no special characters that could potentially conflict with the config file.

FFMPEG < - - In addition to VLC, you may need to also install ffmpeg to gain all the popular codecs, etc...

What’s next?? Other ideas??

Well, now that I proved this works on my main linux system, I’m likely going to purchase a Raspberry Pi 4 and install Raspbian (linux) on it. At that point, the Pi system should be able handle the workload of driving this VLC display on a dedicated HDMI screen mounted in my hallway 24/7.
“omxplayer” you say ?? Yes ! That is (and would be) my 1st choice as this has native Pi hardware support - yet I think VLC has OpenMax support as well, now that I remember. Anyway, at the time of this write-up, I did not own a Pi, which is needed to actually run the omxplayer (as it does not support i386/x64 systems). Therefore, this VLC experiment was/is plan-B.

PLEX. If you run a local Plex server, you might even reconfigure the VLM to do an VOD to Plex, that way you could call this mosiac view from your TV streamer and phone(s) plex app.

Plan-C ?? Another option for the Pi, would be to install an Android OS with Google Play store. At that point, one could just load the default Amcrest Pro mobile app onto the Pi. With big a touch-screen HDMI monitor, you’d have the ultimate montage viewing terminal !!
User avatar
amcrest168
Posts: 470
Joined: Mon Jun 12, 2017 1:02 pm

Re: VLC mosaic monitor – howto tile view of all IP camera feeds

Post by amcrest168 »

@CronoBandit, how about for kodi media player on a raspberry pi? kodi itself can display rtsp streaming but wondering if there is an easy way to view a split screen of all the ip cameras' rtsp feeds?
CronoBandit
Posts: 12
Joined: Tue Jan 14, 2020 6:38 am

Re: VLC mosaic monitor – howto tile view of all IP camera feeds

Post by CronoBandit »

I know what Kodi is, but beyond that, don't know much about the player's config options.
That said, when it come to Raspberry Pi (SBC's), we have to appreciate they have limited power/resources - especially when it comes to video. That's why the omxplayer has long been the defacto on Pi systems.
Personally, I'd like to try a Pi 4 system with 4GB RAM. I'd like to test it with omx and again with vlc while monitoring CPU % & temps.

Also, remember . . . the main catalyst of this thread is to address the 24/7 mosaic-view appliance capability many of us lost when going DVR/NVR-less. While apps on the phone and apps on my android TV stream can do mosaic views... going this VLC method is a much "lighter" approach to a single-purpose function.

Truth-be-told, I really like the idea of going full Andriod OS on a Pi with HDMI big touch-screen, and side loading Amcrest Pro or some other popular IP cam app.
jack7
Posts: 904
Joined: Tue May 29, 2018 7:46 pm

Re: VLC mosaic monitor – howto tile view of all IP camera feeds

Post by jack7 »

Regarding your android PI option, you may find some interesting reading with a google search on tinycam raspberry pi.
CronoBandit
Posts: 12
Joined: Tue Jan 14, 2020 6:38 am

Re: VLC mosaic monitor – howto tile view of all IP camera feeds

Post by CronoBandit »

Small update here - a bit of bad-news and good-news . . .

So I got my Pi4 in the other day, and the above vlm configuration will not run, sadly. The VLC errors are:

Code: Select all

mmal_xsplitter vout display error: Failed to open Xsplitter:xcb_x11 module
chain filter error: Too high level of recursion (3)
main filter error: Failed to create video converter
Both my Ubuntu PC and the Pi have the same versions of VLC, however, my PC has nvidia hardware acceleration, while the Pi has OpenMax (mmal). Googling the above errors does not yield a definitive issue, as the online chatter ranges from a deliberate break in VLC due to an on-going security issue, to this being a lack of mosaic driver support in vlc for OpenMax in Pi. (Yes I increased the GPU ram split for the Pi - no help)
So I threw my hands in the air and gave up on VLC for the Pi. For my Ubuntu system, this VLC voodoo will remain. In-fact, I put a shortcut on my desktop so I can quickly call up the cam views on-demand.

So for the Pi . . . back to “Plan A” - - > omxplayer.
This is the player-of-choice for the Pi / Raspbian OS, and has been optimized as such for the OpenMax hardware accl. The only issue, is that there is no clever mosaic overly like in VLC to run it from a single player instance. Instead, you need to call multiple instances of the omxplayer, and target each instance for a specific region of the screen. If you know a bit of bash scripting, one can easily batch this up to launch all camera feeds conveniently --- and, someone already has done such ! Since this thread's topic is VLC, I’ll simply say to those wanting to go with Pi/Raspbian, simply google “displaycameras Pi GitHub” and download the latest tarball. There’s also a how-to page out there too to help with the layout.config.default file setup. Right now, I can report success with Pi4 & omxplayer & displaycameras service scripts :) as I have all 8 of my low-res streams going at once on a 22” HDMI screen at 1920x1080, and the Pi isn’t even breaking a sweat !!
CronoBandit
Posts: 12
Joined: Tue Jan 14, 2020 6:38 am

Re: VLC mosaic monitor – howto tile view of all IP camera feeds

Post by CronoBandit »

Update is due:

So my 9 feed monitoring station driven by Pi 4 and omxplayer has been working flawlessly all this time. I had wrote a small python driver script which did the math to divide my 1920v1080 hdmi screen into 9 tiles (3x3 grid), then call 9 instances of omxplay pulling the low-def streams on each camera.
"has been", because when I've upgrade from Raspian OS Buster (debian linux for the pi) to Bullseye (11.2) omxplayer supprt was official discontinued. So I revisited using vlc player as an alternative. Got it working (good-news) - yet it took some trial-n-error, so I'll post up here to save someone the time:

First - vlc's mosiac function is not supported, or at least it's broken. My guess is that the mmal driver (the API which talks to the pi's GPU hardware) doesn't like the overlay filters, to overlay multiple feeds into one vlc instance. However, single instances of multiple vlc players is supported (like omxplayer). Furthermore, while vlc itself cannot output video to specific regions of the screen, the mmal driver can, thus vlc can.

Next, if your pi 4 is still on Buster, this works fine now.
However, if you installed/upgraded to the newest OS (as of this writing) Bullseye, you'll need to change the graphical overlay back to using the "Fake" KMS driver. Here's how:

# Edit /boot/config.txt
sudo nano /boot/config.txt

# Change the line:
dtoverlay=vc4-kms-v3d
# To:
dtoverlay=vc4-fkms-v3d

# Save/reboot


Note: be sure you've increased "gpu_mem" respectively - there are plenty of guides for that online.

Finally, here's how you would run multiple instances of vlc:

/usr/bin/vlc -I dummy --aspect-ratio=640:360 --vout mmal_vout --network-caching 3000 --no-video-title-show --mmal-display=hdmi-1 --input-timeshift-granularity=0 --repeat --mmal-vout-transparent --mmal-vout-window 640x360+640+0 --mmal-layer 2000000000 --no-audio rtsp://username:[email protected]:554/cam/realmonitor\?channel=1\&subtype=1

Note the backslashes for "?" & "&" - these are need if running from the shell terminal or bash script.
The --mmal-vout-window argument is what places the video at a specific region of the screen - this you'll need to figure out for your needs. Search what the 4 number mean - it's easy.

I have 9 feeds running and the pi4 isn't even cracking a sweat!

Good-luck with your project !
Post Reply