obs-gstreamer

obs-gstreamer 0.4.0

0:00:01.446507400 4068 00000293B4398840 WARN nvdec gstnvdec.c:460:parser_sequence_callback: CUDA call failed: CUDA_ERROR_OUT_OF_MEMORY, out of memory
0:00:01.446821300 4068 00000293B4398840 ERROR nvdec gstnvdec.c:461:parser_sequence_callback:<nvh264dec5> failed to create decoder
0:00:01.449383000 4068 00000293B4398840 WARN nvdec gstnvdec.c:581:parser_decode_callback: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:01.449604200 4068 00000293B4398840 ERROR nvdec gstnvdec.c:582:parser_decode_callback:<nvh264dec5> failed to decode picture
0:00:01.492229600 4068 00000293B4B1D8C0 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc11> error: Internal data stream error.
0:00:01.492603600 4068 00000293B4B1D8C0 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc11> error: streaming stopped, reason error (-5)
0:00:01.512159700 4068 00000293AB1C36C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec2> failed to create OpenGL context
0:00:01.512268500 4068 00000293AB1C36C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec2> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.591695800 4068 00000293AB6DEE00 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec3> failed to create OpenGL context
0:00:01.591782600 4068 00000293AB6DEE00 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec3> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.609332400 4068 00000293B43987C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec1> failed to create OpenGL context
0:00:01.609456200 4068 00000293B43987C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec1> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.619577700 4068 00000293AB1C35C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec0> failed to create OpenGL context
0:00:01.619730000 4068 00000293AB1C35C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec0> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.685449600 4068 00000293B4398D80 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec4> failed to create OpenGL context
0:00:01.685561800 4068 00000293B4398D80 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec4> OpenGL context is not CUDA-compatible, fallback to system memory

above is the usual logging, 5 IP camera's on rtpsrc
when adding a 6 IP camera, it will not show up in OBS. This is the logging it delivers :

0:00:27.060738000 4068 00000293B4B1D9C0 WARN rtspsrc gstrtspsrc.c:3541:on_timeout_common:<rtspsrc5> source 00000000, stream 00000000 in session 0 timed out
0:00:31.480157900 4068 00000293B4916080 WARN default gstrtspconnection.c:1317:writev_bytes: Operation was cancelled
0:00:31.480232200 4068 00000293B4916080 WARN rtspsrc gstrtspsrc.c:6494:gst_rtspsrc_try_send:<rtspsrc5> send interrupted
0:00:31.480278400 4068 00000293B4916080 WARN rtspsrc gstrtspsrc.c:8905:gst_rtspsrc_pause:<rtspsrc5> PAUSE interrupted
0:00:31.946323100 4068 00000293B4398840 WARN nvdec gstnvdec.c:460:parser_sequence_callback: CUDA call failed: CUDA_ERROR_OUT_OF_MEMORY, out of memory
0:00:31.946412200 4068 00000293B4398840 ERROR nvdec gstnvdec.c:461:parser_sequence_callback:<nvh264dec6> failed to create decoder
0:00:31.946470600 4068 00000293B4398840 WARN nvdec gstnvdec.c:581:parser_decode_callback: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:31.946525400 4068 00000293B4398840 ERROR nvdec gstnvdec.c:582:parser_decode_callback:<nvh264dec6> failed to decode picture
0:00:32.011794200 4068 00000293B4B1D940 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc13> error: Internal data stream error.
0:00:32.011869900 4068 00000293B4B1D940 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc13> error: streaming stopped, reason error (-5)
0:00:37.577463700 4068 00000293B4398840 WARN nvdec gstnvdec.c:460:parser_sequence_callback: CUDA call failed: CUDA_ERROR_OUT_OF_MEMORY, out of memory
0:00:37.577544100 4068 00000293B4398840 ERROR nvdec gstnvdec.c:461:parser_sequence_callback:<nvh264dec7> failed to create decoder
0:00:37.577607600 4068 00000293B4398840 WARN nvdec gstnvdec.c:581:parser_decode_callback: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:37.577653100 4068 00000293B4398840 ERROR nvdec gstnvdec.c:582:parser_decode_callback:<nvh264dec7> failed to decode picture
0:00:37.642940200 4068 00000293B4B17A80 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc16> error: Internal data stream error.
0:00:37.643165600 4068 00000293B4B17A80 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc16> error: streaming stopped, reason error (-5)
0:00:50.894715600 4068 00000293AB1C36C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec8> failed to create OpenGL context
0:00:50.894813700 4068 00000293AB1C36C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec8> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:52.107400600 4068 00000293AB1C3540 WARN rtspsrc gstrtspsrc.c:6410:gst_rtsp_src_receive_response:<rtspsrc0> receive interrupted
0:00:52.107473400 4068 00000293AB1C3540 WARN rtspsrc gstrtspsrc.c:6508:gst_rtspsrc_try_send:<rtspsrc0> receive interrupted
0:00:52.107542800 4068 00000293AB1C3540 WARN rtspsrc gstrtspsrc.c:8905:gst_rtspsrc_pause:<rtspsrc0> PAUSE interrupted
0:00:52.147240500 4068 00000293B4916080 WARN default gstrtspconnection.c:1317:writev_bytes: Operation was cancelled
0:00:52.147315500 4068 00000293B4916080 WARN rtspsrc gstrtspsrc.c:6494:gst_rtspsrc_try_send:<rtspsrc7> send interrupted
0:00:52.147357900 4068 00000293B4916080 WARN rtspsrc gstrtspsrc.c:8905:gst_rtspsrc_pause:<rtspsrc7> PAUSE interrupted


Would this suggest the video card is running out of resources ?

thanks !
Johnny
 

Attachments

  • obs2.jpg
    obs2.jpg
    47.4 KB · Views: 72

Tuna

Member
There are a lot of CUDA errors on the first half as well. Not sure if that is expected or not. On the second half there additional is something about a timed out RTSP session.
 
@Tuna, the videocard, it is one of the first Nvidia with nvenc. The messages above appear with 5 streams running flawlessly.

When i add the 6th stream, the below Messages appear as extra.
 

Gavin H

New Member
Is there a simple example of an equivalent 'send to RTMP server' pipeline for the encoder?

Having the test card and 'pips' is superb for the GST source, and it'd be amazing to have a pre-populated 'rtmp://x.x.x.x' example pipeline for comparison!

Amazing work! :D
 

Gavin H

New Member
Is there a simple example of an equivalent 'send to RTMP server' pipeline for the encoder?

Silly me I didn't realise that it would *already* work using the RTMP destination defined in the 'Stream' tab. In that case, my question is slightly different. Is there a way I can insert additional pipeline steps *before* the x264 encode + RTMP output?

I have a very specific need to crop the video that comes from the OBS canvas before being broadcast, and hoped this would fit the bill better than a bunch of ugly ffmpeg shell scripts :)
 

Gavin H

New Member
Ahhh I actually looked at the source and it's easy to understand - thank you :)

I was able to insert a videocrop right=424 just after the videoconvert , recompile, re-launch OBS and it works a treat - thank you so much =)
 
so I updated my Nvidia drivers and some errors disappeared.

still, witch camera 6, the CUDA_OUT_OF_MEMORY appears.

View the attached screenshot , the GPU and memory usage climbing.

0:00:00.810172500 4168 000001A420A826C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec0> failed to create OpenGL context
0:00:00.810487200 4168 000001A420A826C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec0> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:00.864351000 4168 000001A420A825C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec1> failed to create OpenGL context
0:00:00.864622800 4168 000001A420A825C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec1> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:00.899606700 4168 000001A420A82F80 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec2> failed to create OpenGL context
0:00:00.901378800 4168 000001A420A82F80 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec2> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.150614200 4168 000001A42A720AC0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec3> failed to create OpenGL context
0:00:01.150764100 4168 000001A42A720AC0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec3> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.204888900 4168 000001A42A8BC0C0 ERROR nvdec gstnvdec.c:1321:gst_nvdec_ensure_gl_context:<nvh264dec4> failed to create OpenGL context
0:00:01.205020700 4168 000001A42A8BC0C0 WARN nvdec gstnvdec.c:539:gst_nvdec_negotiate:<nvh264dec4> OpenGL context is not CUDA-compatible, fallback to system memory
0:00:01.434465300 4168 000001A433CDB900 WARN nvdec gstnvdec.c:460:parser_sequence_callback: CUDA call failed: CUDA_ERROR_OUT_OF_MEMORY, out of memory
0:00:01.434597900 4168 000001A433CDB900 ERROR nvdec gstnvdec.c:461:parser_sequence_callback:<nvh264dec5> failed to create decoder
0:00:01.434714300 4168 000001A433CDB900 WARN nvdec gstnvdec.c:581:parser_decode_callback: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:01.434806000 4168 000001A433CDB900 ERROR nvdec gstnvdec.c:582:parser_decode_callback:<nvh264dec5> failed to decode picture
0:00:01.438831600 4168 000001A433CDB440 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc11> error: Internal data stream error.
0:00:01.438972800 4168 000001A433CDB440 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc11> error: streaming stopped, reason error (-5)
0:00:30.430467500 4168 000001A42A8BC080 WARN nvdec gstnvdec.c:460:parser_sequence_callback: CUDA call failed: CUDA_ERROR_OUT_OF_MEMORY, out of memory
0:00:30.430563900 4168 000001A42A8BC080 ERROR nvdec gstnvdec.c:461:parser_sequence_callback:<nvh264dec6> failed to create decoder
0:00:30.430634800 4168 000001A42A8BC080 WARN nvdec gstnvdec.c:581:parser_decode_callback: CUDA call failed: CUDA_ERROR_INVALID_HANDLE, invalid resource handle
0:00:30.430687900 4168 000001A42A8BC080 ERROR nvdec gstnvdec.c:582:parser_decode_callback:<nvh264dec6> failed to decode picture
0:00:30.439191400 4168 000001A433CDB4C0 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc14> error: Internal data stream error.
0:00:30.439318200 4168 000001A433CDB4C0 WARN basesrc gstbasesrc.c:3127:gst_base_src_loop:<udpsrc14> error: streaming stopped, reason error (-5)
 

Attachments

  • gpu usage.jpg
    gpu usage.jpg
    130.9 KB · Views: 53
Hola !

I did a few more tests and found a few interesting things in connecting an RTSP camera to OBS.

So by now I know of 3 different routes to get an RTSP stream into OBS :

Media Source : can make use of hardware acceleration in decoding. Of course if the appropriate hardware is available.
Does have reported stability issues

VLC : Via the VLC plugin, also an RTSP stream can be connected. Whether or not hardware accelleration is enabled in VLC, libVLC does not seem to bother. So when using the VLC source, all decoding is done in the CPU and cannot be offloaded to the GPU. Seems to be by design from VLC. A tweak seams possible, maybe an interesting improvement on OBS. Also has stability issues.

gstreamer : can make use of hardware acceleration in decoding, of course if the appropriate hardware is available. Strange behaviour is that in my setup after adding 5 camera's, no more camera's can be added and gstreamer reports a CUDA_ERROR_OUT_OF_MEMORY. When I look at the task manager, the GPU decoder seems not fully loaded, cannot say something about memory. When adding 2 camera's via Media Source and with hardware acceleration, both get added, and the GPU decoder gets loaded close to 100%. Maybe gstreamer is a bit memory greedy here ? i do not know.

I now am looking for a more powerful video card, to push those limits a little. But also there seems to be room for improvement in settings and programming.

I welcome all your advice !
 

Tuna

Member
Does it work with using software decoder with gstreamer? Note that Nvidia artificially limits your maximum concurrent decoder instances on consumer grade GPUs. (or do they still?)
 
Last edited:
Hello Tuna,

thanks for the reply. I am struggling with the installation of the avdec_h264 . ticked all options in the windows 18.1 mingw install, but avdec_h264 still missing.

rtspsrc location=rtsp://192.168.172.71:554/user=xxx_password=xxx_channel=1_stream=0.sdp?real_stream latency=100 ! rtpjitterbuffer! rtph264depay ! h264parse ! decodebin ! videoconvert ! video.

when changing decodebin to avdec_264 the logging says not found. I am still working on this.

then, when I bring up 2 extra RTSP IP cams with the Media Source plugin, I can add both and tick "hardware accelleration". Both streams then appear in OBS and the GPU decoder load jumps.
 
@Tuna :

so I can switch from avdec_h264 to nvh264dec. seems to miss a frame every now and then, and a message I do not can get rid of.

still, after 5 streams, the 6th will not be accepted by the nvidia and gives the familiar CUDA_ERROR_OUT_OF_MEMORY
6th stream added with the avdec_h264, no problem.

rtspsrc location=rtsp://192.168.172.76:554/user=xxx_password=xxx_channel=1_stream=0.sdp?real_stream latency=100 ! rtpjitterbuffer! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! video.

0:00:01.164313100 872 0000018C11AF72C0 WARN GST_CAPS gstpad.c:5702:pre_eventfunc_check:<nvh264dec4:sink> caps video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, parsed=(boolean)true not accepted
0:00:01.164407500 872 0000018C11AF72C0 WARN GST_CAPS gstpad.c:5702:pre_eventfunc_check:<nvh264dec4:sink> caps video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, parsed=(boolean)true not accepted

apart from this message, the stream is shown in OBS. although seems to miss a frame every now and then.

thanks for helping !
 

STEPHANVS

Member
@Tuna :

so I can switch from avdec_h264 to nvh264dec. seems to miss a frame every now and then, and a message I do not can get rid of.

still, after 5 streams, the 6th will not be accepted by the nvidia and gives the familiar CUDA_ERROR_OUT_OF_MEMORY
6th stream added with the avdec_h264, no problem.

rtspsrc location=rtsp://192.168.172.76:554/user=xxx_password=xxx_channel=1_stream=0.sdp?real_stream latency=100 ! rtpjitterbuffer! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! video.

0:00:01.164313100 872 0000018C11AF72C0 WARN GST_CAPS gstpad.c:5702:pre_eventfunc_check:<nvh264dec4:sink> caps video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, parsed=(boolean)true not accepted
0:00:01.164407500 872 0000018C11AF72C0 WARN GST_CAPS gstpad.c:5702:pre_eventfunc_check:<nvh264dec4:sink> caps video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, parsed=(boolean)true not accepted

apart from this message, the stream is shown in OBS. although seems to miss a frame every now and then.

thanks for helping !
Hey johnny_bravo,

I was researching this topic a while ago, and found this gem. I know it is not OBS related, but might help you a bit. Also check out if this page helps you in any way.
 

STEPHANVS

Member
I there any difference between
Code:
 rtspsrc location=rtsp://url latency=100 ! rtpjitterbuffer ! ...
and
Code:
 rtspsrc location=rtsp://url ! rtpjitterbuffer latency=100 ! ...
?
I am testing with the latency values for rtpjitterbuffer, and still see some jitter now and then...
 
hello , stephanvs. Our church is named after the holy Stefanus. lol.

so we have a gtx650 card capable of 5 NVDEC streams. Maybe we have to look for a newer card. Thanks for this link !

So i set the rtpjitterbuffer just after the url, the first option you show. I did also some network analysis (wireshark, if you like to know).

All our camera's are on one dedicated gigabit switch. Each camera produces about 6 MBit/s data, so well within the capabilities of the switch. Actually I do not see any packet disorder, so the rtpjitterbuffer might even be omitted. The latency is good, because it takes care of the missing frames every now and then. In my setup, I installed the 2.0 gtstreamer.dll and tick both video sync options.

This works for me, smooth video at the price of about 800ms overall latency.
 

Tuna

Member
I there any difference between
Code:
 rtspsrc location=rtsp://url latency=100 ! rtpjitterbuffer ! ...
and
Code:
 rtspsrc location=rtsp://url ! rtpjitterbuffer latency=100 ! ...
?
I am testing with the latency values for rtpjitterbuffer, and still see some jitter now and then...
I would just try "rtspt://" as protocol if the camera supports it. Then the transmission will be switched to TCP instead of UDP. This way you can avoid all jitterbuffer headaches. I would assume the latency to not be much higher.
 

STEPHANVS

Member
I would just try "rtspt://" as protocol if the camera supports it. Then the transmission will be switched to TCP instead of UDP. This way you can avoid all jitterbuffer headaches. I would assume the latency to not be much higher.
Mind is blown. Latency=0 with rtspt works better than latency=100 with rtsp, and I omitted jitterbuffer. (rtspt, "learning all the way" rocks!)
To be fair, latency will increase over time, from faster than the audio from the USB sound source (!!!!!!! what?????) to what I noticed to be around 120ms over one hour period, and this is nothing, compared to the 1140ms original latency.
 

STEPHANVS

Member
Mind is blown. Latency=0 with rtspt works better than latency=100 with rtsp, and I omitted jitterbuffer. (rtspt, "learning all the way" rocks!)
To be fair, latency will increase over time, from faster than the audio from the USB sound source (!!!!!!! what?????) to what I noticed to be around 120ms over one hour period, and this is nothing, compared to the 1140ms original latency.
I have to correct myself, the latency increase over time is around 200ms with rtspt, from -80ms to 120ms according to the audio.
 
Tuna, Stephanvs, I also switched over to rtspt. Removed the jitterbuffer. Kept a 100ms latency to allow for Some buffering.

Then i ticked the two video sync options, and unticked the audio. My audio has a separate usb input on my pc.
500ms latency.

Another step to a stable solution!
 

polcape

New Member
Hi, I use this plugin with HTTP source (with Android IPWebcam app)
uridecodebin uri=http://192.168.1.120:8080/video name=bin ! queue ! video.

All works fine. But when for some reason the stream is disconnected (maybe phone loss wifi signal or something like that) in OBS the image still the same (like stream is paused) even if the WIFI signal is back and stream works again.
So, I have to open the setup of GStreamer source, press apply and stream come back.
I checked "try to restart after pipeline error"

Is there a way to restart the stream auomatically when source come back?
 

Tuna

Member
Check the README about the watchdog element. That one can help with scenarios where eos or errors are not propagated that obviously. Basically it will trigger an error in cases where no data is flowing through it at a configurable time.
 
Top