Difference between revisions of "Low Latency RTSP Sources in OBS"
Line 31: | Line 31: | ||
* is-live=true | * is-live=true | ||
* live=true | * live=true | ||
+ | |||
+ | More info: https://github.com/ambianic/ambianic-edge/issues/94 | ||
== Sources == | == Sources == |
Latest revision as of 06:11, 11 January 2021
Low Latency RTSP Source in OBS
Introduction
Regular Media sources and VLC sources in OBS both suffer from latency, which is a challenge for real time streaming and audio sync. You can add an audio delay, or connect the audio to the camera and then bring it in with the camera feed, but an even better solution is to use the GStreamer OBS plugin to bring in the RTSP sources at much lower latency. It took quite a bit of research to learn the following steps as they don't seem to be very widely used, and I've included links to the most helpful sources that I used at the bottom.
Steps
- Install GStreamer
- Download the MinGW runtime installer package from https://gstreamer.freedesktop.org/download/
- Choose Complete installation; if you prefer Typical, then also add the libav wrapper.
- Add the bin folder to the system PATH (for me this was C:\gstreamer\1.0\mingw_x86_64\bin)
- On Windows 10 you can search for the Edit the system environment variables control panel widget
- After opening the widget click on Environment Variables
- Click on Path and then Edit
- Click new and then paste in the path to the GStreamer bin folder from above, and then click OK several times to save the changes
- Install obs-gstreamer plugin
- Download OBS-gStreamer plugin from https://github.com/fzwoch/obs-gstreamer/releases
- Copy obs-gstreamer.dll from the windows folder within the zip file to PathToOpenBroadcasterSoftware\obs-plugins\64bit\ (for me this was C:\Program Files\obs-studio\obs-plugins\64bit)
- Additional documentation on the plugin is here: https://github.com/fzwoch/obs-gstreamer
- Add the new source in OBS, and configure the URL for your camera
- Important to uncheck Sync appsinks to clock
- The exact URL will vary depending on what cameras you are using, but here are some video only examples with no buffering:
- Sunba with default credentials:
uridecodebin uri=rtsp://admin:Admin12345@ipaddress:554/h264/ch1/main/av_stream name=bin ! queue ! video.
- HikVision:
uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 name=bin ! queue ! video.
- Sunba with default credentials:
- It may be worth adding some buffering to prevent frame jitter (40ms per frame):
uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 latency=40 ! queue ! video.
If audio delay is still needed consider a VST (Virtual Studio Technology) plugin like this: https://www.reaper.fm/reaplugs/ (OBS Install instructions here: https://www.obs.live/articles/2019/7/23/the-best-3-add-ons-for-obs-studio)
Auto Reconnect
I ran into an issue where the gstreamer sources freeze if an ONVIF controller connects to the same camera. I tried to add the following options to the pipeline to auto reconnect, but so far they didn't seem to help:
- is-live=true
- live=true
More info: https://github.com/ambianic/ambianic-edge/issues/94