Setting up a RTSP Relay with Live555 Proxy

In this brief how-to, I will show you how you can set up a RTSP relay/proxy server using the Live555 Proxy.

Essentially what the Live555 proxy server allows you to do is to connect to a backend video feed and relay it to your RTSP clients via unicast. The number of clients you can relay to depends on the hardware of your proxy server as well as the network. Bandwidth usage can easily be calculated by multiplying the backend feed in KB/s by the number of clients connected to your relay server.

My set-up

  • Ubuntu Server 14.04 LTS x64
  • VLC client running the latest version – you can also use something like OpenRTSP

Let’s get started

  1. First let’s install the essential components required to compile and build the Live555 proxy.
  2. Let’s grab the package and unzip it
  3. Now cd to the new directory (it should be called live)
  4. Run the following to generate the Makefiles – this will allow you to use the make command later to compile the source code

    If you’re using another dsitro (i.e., not Ubuntu 64bit) then you’ll need to substitute linux-64bit with something else – these are the ones that start with config.* where * is your architecture.
  5. Now you may want to take at the look at the source code for the proxy server as not only will it help you understand how it works but you can also make some adjustments to suit your environment.
    I made three tweaks here for our environment. One was to increase the OutPacketBuffer::maxSize to a larger number (this is the maximum frame size – our Panosonic HE-130’s exceeded the default of 100,000 bytes).
    The other was to change the default frontend stream URLs from the default of rtsp://relay/proxyStream-{n} to a more simple rtsp://relay/stream{n} where n is the stream number if > 1 input streams.
    The final adjustment I made was to change the secondary port number from 8554 to 554 (yes this is the same as the primary port). The reason I did this is to prevent user error in case someone forgets to run the proxy server as sudo. In a scenario where someone forgets to run the server as sudo then the proxy server will attempt to open port 8554 which we don’t want.The source code can be found in the /live/proxyServer folder. The file name is live555ProxyServer.cpp. Don’t forget to make a backup first! (copy live555ProxyServer.cpp live555ProxyServer.cpp.bak)

  6. Now we can compile the code by running the make command in the /live directory. This will take a short while to compile but it should succeed without issues.
  7. That’s it! You’re ready to relay now.

RTSP relay example

Imagine a scenario where you have two cameras which can spit out a RTSP feed. The RTSP url is as follows: rtsp://camera1/MediaInput/h264/stream_1 and rtsp://camera2/MediaInput/h264/stream_1

Now to relay these feeds, simply run the following:

Note: it is important to run this as sudo otherwise you won’t be able to open port 554 which is the default for RTSP. You can open a port higher than 1024 but it means your clients will have to enter the port number after the URL which can be ugly (the proxy server will try 8554 by default if it cannot open 554)

The output will automatically spit out the RTSP feeds for the relay server. For example you will get something like this: rtsp://relay-server/proxyStream-1 and rtsp://relay-server/proxyStream-2

Bonus: Monitor your bandwidth utilisation

There are many tools out there which you can use to monitor network utilisation but I like slurm.

This assumes your NIC is on eth0.

If there is a stream running, you will see that the current RX speed is the bandwidth utilisation of the feed from the relay server to the camera. The TX speed will be the RX speed * number of clients.

I hope this helps someone out there!

2 thoughts on “Setting up a RTSP Relay with Live555 Proxy”

  1. Hello,
    Thanks for the great tutorial.
    I am currently trying to encrypt the stream between server and client.
    The live555 proxy server does not support tls natively from what I understand.
    However rtsp over tls is possible using stunnel, just proxy through stunnel.
    http://comments.gmane.org/gmane.comp.multimedia.live555.devel/13567
    I am currently trying to implement this between live555 and vlc client using stunnel however as of yet I have not got it working. Just wondering if you have any knowledge in this area.
    Any help would be appreciated.
    Thanks!

    1. Hello Sean,
      It’s a coincidence you ask me about stunnel because even though I’ve never used it before, I’ve been looking in to it to use in another project of mine.
      My other project involves tunnelling SSH over HTTPS and stunnel seems to be the best way to do it.
      Hopefully I’ll blog about it in the next month or so. It may or may not help you achieve your goal.

Comments are closed.