Question / Help RTSP stream from IP camera delay in input in preview

syahirz

New Member
Gstreamer works great for me. Not even a noticable delay comparing with the media source method. Been trying with multiple dahua camera models and works perfectly. Thanks Stephanvs.

I'm using Dahua (Imou) Ranger Camera with this gstreamer pipeline for video output.
Code:
uridecodebin uri=rtsp://{user}:{pass}@{ip address}/cam/realmonitor?channel=1&subtype=0 ! queue ! video.


However, i'm having trouble having the built-in mic of my camera to output audio on obs. Any suggested pipeline for that matter?
 
uridecodebin uri=rtsp://{user}:{pass}@{ip address}/cam/realmonitor?channel=1&subtype=0 ! name=bin ! queue ! video. bin. ! queue ! audio.

you should connect the audio sink to the stream with the audio.
 

Ussah

New Member
Maybe I need to test gStreamer solution. Currently having problem using Larix Broadcaster as SRT camera and OBS goes out of sync. Do you think setting up GStreamer will help?
I would love so much use either media or VLC sources out of box no need to hassle with third party plugins

 

nsbyrer

New Member
Found a reference to GStreamer on a VLC bugreport, tried it today. RTSP camera latency went from 1140ms (with built-in Media source) through 400ms (with VLC Video Source) to 60ms!!!!!!!!!! with GStreamer Source!!!! Just came here to spread the good news!

Project:

My steps:
Copy obs-gstreamer.dll from https://github.com/fzwoch/obs-gstreamer/releases/download/v0.1.0/obs-gstreamer.zip (\windows) to PathToOpenBroadcasterSoftware\obs-plugins\64bit\

Get https://gstreamer.freedesktop.org/d...0/mingw/gstreamer-1.0-mingw-x86_64-1.18.0.msi and install. Put PathTo\gstreamer\1.0\mingw_x86_64\bin\ into PATH (or copy libglib-2.0-0.dll, libgobject-2.0-0.dll, libgstapp-1.0-0.dll, libgstaudio-1.0-0.dll, libgstreamer-1.0-0.dll, libgstvideo-1.0-0.dll to PathToOpenBroadcasterSoftware\bin\64bit\, based on https://github.com/fzwoch/obs-gstreamer/issues/13#issuecomment-711106142 but this I have not tried yet...)

Start OBS and add GStreamer Source. We use HikVision IP cameras, my Pipeline looks like this:
Code:
uridecodebin uri=rtsp://username:password@ipaddress/Streaming/Channels/1 name=bin ! queue ! video.
Important to uncheck Sync appsinks to clock, and to my surprise the feed in OBS is lower latency than the feed in Internet Explorer.

Live test on Sunday.

I have been beating my head against the wall over latency from my RTSP streams for months. I spend an inordinate amount of time trying to sync audio, only to have my NDI cams be out of sync. If this works for me like it seems to be for everyone else. I will be estatic. Thank you.
 

LeeHockHin

New Member
A possible solution to try
1) Install Agent DVR from https://www.ispyconnect.com/
2) Add IP Cameras in Agent DVR (browser based UI at "localhost:8090")
3) Add/Create a View for each IP camera
4) Use the following url in the Browser source in OBS: "http://localhost:8090/?start=Live&viewIndex=0"
for the scene in View 0 of Agent DVR
5) Add additional Browser Sources for each extra view/camera

I have found this to give negligible lag in the video, and works with more IP Cameras than the Media Source type in OBS

I am requesting for a new OBS source type specifically for IP Cameras at
https://obsproject.com/forum/threads/features-request-of-obs-studio.52130/
Please give your support there so that this feature can be added to OBS as soon as possible
 

LeeHockHin

New Member
A possible solution to try
1) Install Agent DVR from https://www.ispyconnect.com/
2) Add IP Cameras in Agent DVR (browser based UI at "localhost:8090")
3) Add/Create a View for each IP camera
4) Use the following url in the Browser source in OBS: "http://localhost:8090/?start=Live&viewIndex=0"
for the scene in View 0 of Agent DVR
5) Add additional Browser Sources for each extra view/camera

I have found this to give negligible lag in the video, and works with more IP Cameras than the Media Source type in OBS

I am requesting for a new OBS source type specifically for IP Cameras at
https://obsproject.com/forum/threads/features-request-of-obs-studio.52130/
Please give your support there so that this feature can be added to OBS as soon as possible
After further testing, I found that Agent DVR drops frames. So it might not be an ideal situation
 

Fbosman

Member
I'm trying to get my Dahua rtsp feed into OBS with gstreamer but so far I haven't been able to figure out the correct pipeline. Anybody can provide an example code that works with Dahua?

The following works fine in VLC, but cannot make it work with gstreamer.
rtsp://USERNAME:PW@IP:PORT/cam/realmonitor?channel=1&subtype=2
I managed to get it working by putting the complete url within double quotes.
 

superdiy

New Member
I managed to get it working by putting the complete url within double quotes.

I also have a dahua camera, but cannot get the rtspsrc pipeline working. If I use the following pipeline in the gstreamer plugin, it works:
uridecodebin uri=rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.

The following pipeline does not work:
rtspsrc location=rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0 latency=100 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! video.

If I use gst-launch-1.0 command line tool with both pipelines, BOTH fail with the same messages.

I'm pretty sure it is the & (ampersand) which causes the issue, but I've tried to escape it in all possible ways and combinations I could find on the net, all without success. I've tried single- and double quotes around rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0
I've tried %26, "%26", '%26', \&, ^& "&", '&', "\&", '\&', "^&", '^&', &&, '&&', "&&", \&& and various combinations thereof including single- and double quotes around rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0
I just always get either one of the following 2 "error messages" reported by gst-launch-1.0

Message 1:
WARNING: erroneous pipeline: No sink-element named "(NULL)" - omitting link

Message 2:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Pipeline is PREROLLED ...
Prerolled, waiting for progress to finish...
Progress: (connect) Connecting to rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Not found
Additional debug info:
../gst/rtsp/gstrtspsrc.c(6621): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Not Found (404)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
'"subtype=0"' is not recognized as an internal or external command,
operable program or batch file.


Any suggestions?
Thank you
 

camfix

New Member
First off, many thanks to all who contributed solutions here, I was trying to get some Dahua cameras going and landed here.

Here my little contribution

For Dahua Cameras instead of that "&" just use "**+**"

uridecodebin uri=rtsp://user:pw@ip or dyndns etc:554/cam/realmonitor?channel=1**+**subtype=0 ! queue ! video.

I had to use plain H264 (not H.264H or H.265) and no extras like Smart Codec etc to get it to work.
Good Luck with these
 

strauburn

New Member
I also have a dahua camera, but cannot get the rtspsrc pipeline working. If I use the following pipeline in the gstreamer plugin, it works:
uridecodebin uri=rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.

The following pipeline does not work:
rtspsrc location=rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0 latency=100 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! video.

If I use gst-launch-1.0 command line tool with both pipelines, BOTH fail with the same messages.

I'm pretty sure it is the & (ampersand) which causes the issue, but I've tried to escape it in all possible ways and combinations I could find on the net, all without success. I've tried single- and double quotes around rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0
I've tried %26, "%26", '%26', \&, ^& "&", '&', "\&", '\&', "^&", '^&', &&, '&&', "&&", \&& and various combinations thereof including single- and double quotes around rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0
I just always get either one of the following 2 "error messages" reported by gst-launch-1.0

Message 1:
WARNING: erroneous pipeline: No sink-element named "(NULL)" - omitting link

Message 2:
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Progress: (open) Opening Stream
Pipeline is PREROLLED ...
Prerolled, waiting for progress to finish...
Progress: (connect) Connecting to rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1
Progress: (open) Retrieving server options
Progress: (open) Retrieving media info
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Not found
Additional debug info:
../gst/rtsp/gstrtspsrc.c(6621): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Not Found (404)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
'"subtype=0"' is not recognized as an internal or external command,
operable program or batch file.


Any suggestions?
Thank you


The "video" sink and "audio" sink are only in OBS, they don't exist for using gst-launch-1.0 directly, and it also doesn't like the "." at the end of the sink. If you want to test with gst-launch-1.0, try replacing "video." with "fakevideosink" and see if that works for you.

It also looks like it's not escaping your ampersands and thinks it's a new command after the "&". I'm assuming you're on Windows. Try putting just the URI / location in double quotes. So all together, something like this:
Code:
gst-launch-1.0.exe rtspsrc location="rtspt://admin:<password>@<ipaddress>/cam/realmonitor?channel=1&subtype=0" latency=100 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! fakevideosink
 

strauburn

New Member
Since this thread has been immensely helpful (especially @STEPHANVS ), I'll contribute back what I've learned.

First, the parsing and decoding parts of your pipeline will depend on how your stream is encoded. I found the "gst-discoverer-1.0.exe" really helpful for telling you how the stream is encoded. For example, to look at my Reolink RLC-520 cam's RTSP feed, I ran:
Code:
gst-discoverer-1.0.exe "rtsp://admin:<password>@<ip-address>:554/h264Preview_01_main"
And got this response:
Code:
Analyzing rtsp://admin:<password>@<ip-address>:554/h264Preview_01_main
Done discovering rtsp://admin:<password>@<ip-address>:554/h264Preview_01_main

Properties:
  Duration: 99:99:99.999999999
  Seekable: no
  Live: yes
  container: application/rtsp
    unknown: application/x-rtp
      video: H.264 (Baseline Profile)
        Stream ID: <long hex string>/video:0:0:RTP:AVP:96
        Width: 2560
        Height: 1440
        Depth: 24
        Frame rate: 0/1
        Pixel aspect ratio: 1/1
        Interlaced: false
        Bitrate: 0
        Max bitrate: 0
    unknown: application/x-rtp
      audio: MPEG-4 AAC
        Stream ID: <long hex string>/audio:0:0:RTP:AVP:97
        Language: <unknown>
        Channels: 1 (unknown layout)
        Sample rate: 16000
        Depth: 32
        Bitrate: 0
        Max bitrate: 0

My SUNBA 601-D25X reported similar video info but the audio said audio: A-Law instead of audio: MPEG-4 AAC, so it needed different audio decoding than my RLC-520.

For those looking to get audio, here's what my pipelines with audio looked like for my cameras:
Reolink RLC-520 (has MPEG-4 AAC audio):
Code:
rtspsrc location=rtsp://admin:<password>@<ip-address>:554/h264Preview_01_main latency=120 name=bin ! rtpjitterbuffer latency=0 !  rtph264depay ! h264parse ! d3d11h264dec ! video. bin. ! queue ! rtpmp4gdepay ! aacparse ! avdec_aac ! audio.

SUNBA 601-D25X (has A-Law audio):
Code:
rtspsrc location=rtsp://<ip-address>:554/user=admin&password=<password>&channel=1&stream=0.sdp?real_stream latency=120 name=bin ! rtpjitterbuffer latency=0 ! rtph264depay ! h264parse ! d3d11h264dec ! video. bin. ! queue ! rtppcmadepay ! alawdec ! audio.

In terms of the video decoding, I found that on my system (with an RX 580 graphics card) that the "d3d11h264dec" used less CPU by using the gfx card's decoder as compared to "avdec_h264", which didn't seem to use the gfx card. That was with baseline profile h264 encoding, but YMMV depending on your card and the compression / encoding profile.

Hope this helps someone!
 

martinjohn

New Member
I need my IP camera RTSP stream to display in real time in preview, but I have like 3 sec latency. Although I don't have this problem while using vMix.
Is there any possible way to fix it?

log: https://obsproject.com/logs/WRPte077xbXOpGm_

If you have already tried all the usual remedies - setting CPU priority to "real-time", minimizing other programs running in the background, etc., and still can't seem to reduce latency for your RTSP stream, then try V-EZ 4.1 which was released today.
 

Bertus OH

New Member
I do not know if this is still an actual problem but we were facing also different audio delay's for IP camara's in our church. Also everytime the computer was swiched on the audio delay was different for the camera. I use "Mediasource" for the IP camera. I also tried GStreamer, the audio delay was perfect, almost no delay and constant every time the system was started up. But.... the video signal was stuttering, not fluwend . After installing the latest VCL player on the computer I switched for the videosource to "VCL Source" and now everything works perfect, short audio delay, same audio delay for all the camera's and a fluend video signal.
 

camfix

New Member
@Shween
It was very difficult since * is a placeholder in searches and thus gets ignored with most search engines.
Depending on language, there are different "escape" characters, and this finally worked.
Happy New Year to you, too
 

vurol

New Member
Gstreamer works great for me. Not even a noticable delay comparing with the media source method. Been trying with multiple dahua camera models and works perfectly. Thanks Stephanvs.

I'm using Dahua (Imou) Ranger Camera with this gstreamer pipeline for video output.
Code:
uridecodebin uri=rtsp://{user}:{pass}@{ip address}/cam/realmonitor?channel=1&subtype=0 ! queue ! video.

https://www.androhile.club/the-godfather-1-indir-full-pc-turkce/
However, i'm having trouble having the built-in mic of my camera to output audio on obs. Any suggested pipeline for that matter?
thanks
 

Sibzor

New Member
STEPHANVS, you sir are my new HERO!!! For over a year now I have had an issue with RTSP streaming my IP camera whereby the video part of the stream slowly falls behind and gets further and further away from being 'live' while the audio stays live. It was so bad that if I left it streaming overnight then the next day it would be like 30 minutes delayed from the live image. Where all that 30 minutes of footage got stored I have no idea but I must have tried every single settings of ffmpeg to try and fix it will no luck. Turns out that its ffmpeg itself that is the problem and switching to GStreamer has complete fixed the issue for me and I can now finally stream my video with no sync issues.

It took me a while to figure out how to get both the video and audio working with GStreamer so if it helps anyone else then here is the pipeline I used:

Code:
uridecodebin uri=rtsp://usernane:password@ipaddress:554/Streaming/Channels/101/?transportmode=unicast.sdp name=bin ! queue ! video. bin. ! queue ! audio.
 
Top