Here a simple guide to convert any rtsp stream to a virtual device that you can use inside your favourite video chat.

Check your stream

Firstly check your input stream that is working correctly

A simple method could be using “VLC”, media, open network stream

rtsp://<username>:<password>@<ip>:<port>/<stream>
# example for tp-link security camera is
rtsp://<username>:<password>@<ip>:554/stream1

Create a new video device

Create a new video device using v4l2loopback

sudo apt-get update
sudo apt-get install v4l2loopback-dkms

Then check the existing once

ls /dev/video*

An output example can be /dev/video0 (integrated camera), /dev/video1 (hdmi)

# remove any v4l2loopback mount
sudo rmmod v4l2loopback
# if it gaves an error it's ok
# mount new loopback video
sudo modprobe v4l2loopback exclusive_caps=1 max_buffers=2
# check again
ls /dev/video*
# then you should have a new video device (ex: /dev/video2)

Mount the stream

Now using ffmpeg (install if you don’t have it) mount the rtsp stream to the video2 loopback device

ffmpeg -i "rtsp://<user>:<password>@<ip>:<port>/<stream>" -f v4l2 /dev/video2
#example for tplink c200 security camera
ffmpeg -i "rtsp://tplink:tplink@192.168.1.2:554/stream1" -r 60 -f v4l2 /dev/video2
# To minimize the delay in a live streaming you can
# use -flags low_delay
# use -fflags nobuffer

The new virtual webcam is ready to be used (cheese, skype, google chat, zoom… and so on)

You can test it using VLC, media, open capture device and then select as “video device name” the new loopback interface (/dev/video2)

Categories: BashServer

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published.