Skip to content

RTSP Stream

Merlin edited this page Nov 6, 2022 · 5 revisions

RTSP Streaming

RTSP is a streaming protocol that allows very low latency (usually 1 second or less) video and audio streaming into VRChat. RTSP is not to be mistaken for RTMP which can also stream into VRC, but has a much higher latency of usually >10 seconds. Which is not acceptable for many use cases.

Using a preset RTSP stream with low latency

There are services that provide an already-setup server for RTSP streaming already such as VRCDN and Topazchat. It is recommended that you use the video player setups that they provide, but it is possible to input the RTSP link they provide into the stream player and use them the same though USharpVideo if you wish.

The only thing that you need to do in these cases is make sure that the Low Latency Stream check box is enabled on the U# video player.

Spinning up your own RTSP server

You can fairly quickly start an RTSP server for sharing your screen or hosting your own stream. For this guide I will use DigitalOcean as the server host, but any host works. The software you will need for this is Putty and OBS.

If you already have a server setup with docker, you can skip the digitalocean server setup.

Setting up a DigitalOcean server

  1. Create an account at https://www.digitalocean.com/

  2. Create a droplet

    a. Reference the how to create a droplet guide for more detail https://docs.digitalocean.com/products/droplets/how-to/create/

    b. Under the Choose an image section, choose the Marketplace tab and select the Docker on Ubuntu option. If that option does not exist search for the "Docker" keyword.

    c. Under Choose a plan you will need to choose appropriate specs for the PC. If you're just streaming to a couple of people, a basic shared CPU can work. If you're streaming to more people I'd recommend choosing the cheapest CPU Optimized instance.

    d. Choose a datacenter that is close to your location

    e. For authentication you can use a SSH key, but I will not explain that here since it requires additional setup. If you are not familiar with SSH keys just select password for authentication and create a password.

    f. Click create droplet and you're done creating the droplet

  3. Connect using Putty

    a. Follow https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/putty/ and skip the SSH key section if you're using a password. Your username is root by default.

    b. Click Open to connect and put your password in

    c. You should now be connected to your server

Setting up RtspSimpleServer

RtspSimpleServer is one of the few servers I've found that actually has functional RTSP support.

You should be connected to your server through Putty at this point and it should be setup for Docker. The docker setup is done if you used the Docker marketplace selection on DigitalOcean.

  1. Enter the following in the command line:
docker run --rm -it -e RTSP_PROTOCOLS=tcp -p 8554:8554 -p 1935:1935 aler9/rtsp-simple-server
  1. After entering the command the RTSP server should be setup.

Streaming to your server with OBS

  1. Open OBS's settings menu
  2. Go to the stream options and select Custom... for the service
  3. For the server, put rtmp://<your server IP> for example if your droplet's IP were 123.123.123.123 you'd put rtmp://123.123.123.123
  4. For the stream key put a key of your choice, it can me anything alphanumeric. For instance mylivestream would work. Multiple people can stream through the same server if they use different stream keys.
  5. Apply and exit the settings and setup your screen capture on OBS, then click Start Streaming. Your stream should connect and you should see output on the server's console that says an RTMP connection was opened.

Testing your stream

If you want to test your stream outside of VRChat you can connect to it in VLC. To connect in VLC, open VLC go to the Media menu and click Open Network Stream.... For the network URL put in the following rtsp://<your server IP>:8554/<your stream key>. For the prior examples this would be rtspt://123.123.123.123:8554/mylivestream.

Streaming in VRChat

  1. If you want the low latency that RTSP provides, you may enable the Low Latency Stream option on the USharpVideo player settings.
  2. Upload your world with USharpVideo
  3. Go to your world and select the stream player.
  4. Make sure untrusted URLs are allowed and put the same URL you used for VLC above into the video player.
  5. You should now be streaming and people should be able to watch your stream in VRC.

Clean up your server after you're done streaming

Digitalocean will still charge you for server time as long as the server exists. Shutting down the server will still charge you for server time. So make sure you destroy your droplet after you are done streaming if you do not want to accrue server costs.