Difference between revisions of "Low Latency RTSP Sources in OBS"

From HeadBackup
Jump to navigationJump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
= 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.
 
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
 
# Install GStreamer
 
## Download the MinGW runtime installer package from https://gstreamer.freedesktop.org/download/
 
## Download the MinGW runtime installer package from https://gstreamer.freedesktop.org/download/
Line 21: Line 24:
 
### <pre>uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 latency=40 ! queue ! video.</pre>
 
### <pre>uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 latency=40 ! queue ! video.</pre>
  
If audio delay is still needed consider a VST 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)
+
If audio delay is still needed consider a VST ([https://en.wikipedia.org/wiki/Virtual_Studio_Technology 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)
  
Sources:
+
== 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
 +
 
 +
== Sources ==
 
* https://obsproject.com/forum/threads/rtsp-stream-from-ip-camera-delay-in-input-in-preview.112518/#post-488456
 
* https://obsproject.com/forum/threads/rtsp-stream-from-ip-camera-delay-in-input-in-preview.112518/#post-488456
 
* https://camonlivestreaming.jimdofree.com/2020/04/14/using-gstreamer/
 
* https://camonlivestreaming.jimdofree.com/2020/04/14/using-gstreamer/
 
* https://sunbatech.com/faq/what-is-the-rtsp-stream-url-for-sunba-ip-cameras/
 
* https://sunbatech.com/faq/what-is-the-rtsp-stream-url-for-sunba-ip-cameras/

Latest revision as of 05: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

  1. Install GStreamer
    1. Download the MinGW runtime installer package from https://gstreamer.freedesktop.org/download/
    2. Choose Complete installation; if you prefer Typical, then also add the libav wrapper.
    3. Add the bin folder to the system PATH (for me this was C:\gstreamer\1.0\mingw_x86_64\bin)
      1. On Windows 10 you can search for the Edit the system environment variables control panel widget
      2. After opening the widget click on Environment Variables
      3. Click on Path and then Edit
      4. 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
  2. Install obs-gstreamer plugin
    1. Download OBS-gStreamer plugin from https://github.com/fzwoch/obs-gstreamer/releases
    2. 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)
    3. Additional documentation on the plugin is here: https://github.com/fzwoch/obs-gstreamer
  3. Add the new source in OBS, and configure the URL for your camera
    1. Important to uncheck Sync appsinks to clock
    2. The exact URL will vary depending on what cameras you are using, but here are some video only examples with no buffering:
      1. Sunba with default credentials:
        uridecodebin uri=rtsp://admin:Admin12345@ipaddress:554/h264/ch1/main/av_stream name=bin ! queue ! video.
      2. HikVision:
        uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 name=bin ! queue ! video.
    3. It may be worth adding some buffering to prevent frame jitter (40ms per frame):
      1. 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

Sources