Using Ubiquiti RTSPS cameras with software that only supports RTSP

Originally posted on 2023-06-15

There is a lot of software out there that does not understand RTSPS and SRTP. Even the default installation of VLC can’t do it on my system. If you have a Ubiquiti camera it might seem initially like there’s not a lot you can do. Fortunately, there’s a way to unwrap the RTSPS stream, without re-encoding, and disable SRTP so that you can use your cameras with almost any software.

I originally had to sort this out because I wanted to test out Rekor Scout.

You’ll need the following:

  • Your camera’s RTSPS URL. This looks like rtsps://192.168.0.1:7441/xy1A2zaBCDefgh34?enableSrtp and you can get it from the Ubiquiti Protect UI in the device panel’s “Advanced” settings.
  • A system that can run stunnel. MacOS can install this with Homebrew. Linux can install this with apt or yum.

Steps:

  • Install stunnel
  • Create a configuration file called rtsps-stunnel.conf for stunnel like this
[rtsp]
client = yes
accept = 0.0.0.0:8554
connect = 192.168.0.1:7441

Just make sure that the IP address 192.168.0.1 matches the one in your RTSPS URL.

  • Run stunnel rtsps-stunnel.conf and if all goes well it will return you to the command prompt and it will run in the background.
  • Now if you’re on the same machine as stunnel you can connect to rtsp://127.0.0.1:8554/xy1A2zaBCDefgh34 with something like VLC and you should see the stream. It’s important that you don’t include the ?enableSrtp and that you change the port number to 8554. You can use whatever ports you want.

If this is set up properly and there are no firewalls blocking inbound connections you should be able to have other clients on the network connect to this system’s IP address and get the stream. If you don’t want this behavior and you only want to expose it on localhost then change 0.0.0.0 to 127.0.0.1 in the configuration file, kill stunnel, and restart it.

Some systems need to run stunnel as root. If that’s the case run it with sudo and you should be set.

Enjoy!