Stream Desktop to Multiple Screens
There are two options discussed here to stream to multiple displays
- ImageZeroMQ
- VideoLan
Urs Utzinger, 2020
ImageZMQ
Please find the code using imagezmq at https://github.com/uutzinger/ScreenCast
ScreenZMQ.py
captures the desktop and sends it to receiver. You can adjust desired framrate and resolution.
CameraZMQ.py
captures default video camera and sends it to receiver. You can adjust desired framerate and resolution.
ReceiveZMQ.py
is run on the computer attached to the display. It can receive multiple streams and will tile them.
The programs are in Python and depend on OpenCV, imutils, pyzmq, imagezmq, numy, pyautogui, pillow. Please note installation instructions in the header of the programs. You will need to have Python3 installed on sender and receiver computer. The sender needs to create a connection to each receiving computer.
The latency for 4k streaming is in the 2 seconds range. Image quality is excellent.
VideoLAN
We stream our desktop computer to multiple displays using VLC and Raspberry Pi computers attached to the displays with HDMI. The desktop computer and the client computer need to be connected to the same network.
Desktop Computer Command
Option 1 and 2 are using h264 encoding. Option 3 and 4 mpeg2. For MPEG the desired maximum bit rate can be set (vb). All options below use mpeg audio encoding. You can change port number (8080/8554) and the streaming name (bme310)
Codec Options:
ht264
mp1v
mp2v
mp3v
mp4v
Stream Options:
:rtp{sdp=rtsp://:8554/},
-
:http{mux=ts,dst=:8080/}
General Command
vlc screen:// --screen-fps=15 --live-caching=100 --screen-follow-mouse --sout "#transcode{vcodec=CODEC_OPTION,scale=Auto,height=1080,acodec=mpga,ab=128,channels=2,samplerate=8000,scodec=none}STREAM_OPTION" --no-sout-all --sout-keep
Examples
- mpeg4 encoding using rtsp stream
vlc screen:// --screen-fps=15 --live-caching=100 --screen-follow-mouse --sout "#transcode{vcodec=mp4v,vb=100000,scale=0.5,acodec=None,scodec=none}:rtp{sdp=rtsp://:8554/} --no-sout-all --sout-keep
- h264 enconding using http stream
vlc screen:// --screen-fps=15 --live-caching=100 --screen-follow-mouse --sout "#transcode{vcodec=h264,scale=0.5,acodec=none,scodec=none}:http{mux=ts,dst=:8080/} --no-sout-all --sout-keep
In general the above configuration results in blotches on the receiver. I have not yet found settings for higher quality. Given that there are networked cameras with better image quality and latency, there will need to be similar solutions with higher fidelity.
Client Command
The server_ip address needs to be replace with the desktop address or for testing the local ip address (127.0.0.1). You can find your ip address with ipconfig
command on Windows CMD shell. The first 3 octets need to match for client and server.
- http
vlc http://server_ip:8080/ --network-caching=100
- rtsp
vlc rtsp://server_ip:8554/ --network-caching=100
We connect to the raspberry pi using its built in VNC and start the client as shown above.
Desktop Computer Firewall Exception
You will need to open the streaming protocol ports on your server/desktop. Usually for http that is the port 8080 and for rtsp 8554. Open Windows Defender Firewall
and select advanced settings, then inbound rules. Select Action menu and New Rule. Select Port, Next, Select TCP, Enter 8080 or 8554, Next, Allow the Connection, Enable Domain, Private and Public, Give it a name, Save. Open it again by double clicking the name, select Protocols and Ports, switch to Any protocol (enables both UDP and TCP).