# obs-gstreamer



## Tuna (Jul 3, 2018)

Tuna submitted a new resource:

obs-gstreamer - Feed GStreamer launch pipelines to OBS Studio



> An OBS Studio source plugin to feed GStreamer launch pipelines into OBS Studio.
> 
> This plugin has interesting use cases but may be difficult to understand and is clunky use if you are _not_ familiar with GStreamer.
> 
> No binaries provided due to too many platforms potentially being supported plus the plugin needs to be compiled against the major version of the GStreamer installation on the target system anyway.



Read more about this resource...


----------



## sneaky4oe (Jul 11, 2018)

Can you please describe some usecases?


----------



## Dregu (Jul 11, 2018)

Cool! VLC source latency sucks with network streams. Now you can pipe video from a raspberry pi camera straight to obs with just a few ms latency.

Here's the command and pipeline I'm using (raspi archlinux arm -> obs archlinux):

```
/opt/vc/bin/raspivid -n -t 0 -w 1280 -h 720 -g 60 -fps 30 -b 2500000 -mm average -ex fixedfps -ih -pf high -o udp://10.0.0.176:5000

udpsrc port=5000 ! h264parse ! avdec_h264 ! video.
```


----------



## Dregu (Jul 11, 2018)

Also video+audio from OBS (windows) to OBS (linux) over the internet works great (<1s delay.) Just "Custom Output (FFmpeg)" to url udp://my-ip:5000, (options: mux mpegts, video h264, audio aac) and this pipeline:


```
udpsrc port=5000 ! queue ! decodebin name=bin ! queue ! video. bin. ! queue ! audio.
```


----------



## Tuna (Jul 11, 2018)

Glad you guys like it. There is another example on the Github issue page where someone streams over TCP as well. The use cases depend very much on your imagination. Basically this plugin is a bridge to the GStreamer SDK. So you can use it to do all sorts of things, streaming from other devices is one thing - but you may also try to access hardware devices (or capture screens) directly which may not be covered by the default plugin set of OBS.


----------



## Tuna (Jul 11, 2018)

Tuna updated obs-gstreamer with a new update entry:

0.0.3



> added option to set sinks to sync=false
> added option to restart pipeline after error
> clear data when pipeline not running (fixes freeze frame)



Read the rest of this update entry...


----------



## Tuna (Jul 16, 2018)

Tuna updated obs-gstreamer with a new update entry:

0.0.4



> - fix video stride when row bytes are greater than width



Read the rest of this update entry...


----------



## FabianS (Jul 18, 2018)

Thanks Tuna.

I have build the version for Windows and included some instructions how I got it working. If somebody just wants to test it.

https://github.com/Fabian-Schmidt/obs-gstreamer/releases/tag/v0.0.4-w


----------



## Tuna (Jul 18, 2018)

FabianS said:


> Thanks Tuna.
> 
> I have build the version for Windows and included some instructions how I got it working. If somebody just wants to test it.
> 
> https://github.com/Fabian-Schmidt/obs-gstreamer/releases/tag/v0.0.4-w


Thanks, thats awesome. I haven't gotten around to setup binary releases. I felt if I didn't set it up automatically I keep running updating all the time - either if I release something new or GStreamer versions are released. But hopefully it is API compatible with future GStreamer release and I will slow down at updating stuff too..


----------



## Tuna (Aug 13, 2018)

Tuna updated obs-gstreamer with a new update entry:

0.0.5



> - Add option to keep pipeline running when hidden



Read the rest of this update entry...


----------



## singleballplay (Sep 17, 2018)

Awesome. This is just what I've been looking for and very excited to play with it tonight. I'm messing around with webcams running on Raspberry Pi's using GStreamer RTSPServer and the MediaSource plugin just isn't cutting it for latency so I'm hoping this does the trick.


----------



## Ochi (Oct 20, 2018)

This is an astonishing piece of code, thank you for this! I've been searching everywhere for solutions to two problems that I'm trying to solve. I'm not yet sure if this will deliver solutions for both issues, but either way, it's a great addition to the options that I have.

I thought maybe this is a good place to ask you guys if you have any creative ideas regarding my use case.

My situation is as follows: I have a Magewell HDMI capture card and a Logitech Brio webcam under Arch Linux which I use for recording Let's Plays (sometimes I also use a second Magewell and another Logitech Cam, but let's restrict ourselves to the simpler case). Up until now, I've used two ffmpeg instances to record both V4L2 input devices (plus audio stuff) to disk for later editing. This worked great so far, with NVENC for fast encoding, and smooth 60 FPS for both the cam and game capture.

The problems began with me getting more into streaming. In principle, OBS is great for that, however, I have two problems:

1. I tried (almost?) everything to get the Logitech Brio webcam to give me smooth 60 FPS playback in OBS. The cam parameters are (I think) carefully tuned using qv4l2, I always reduce latency using the /dev/cpu_dma_latency, set the GPU to max performance, tried the V4L2, ffmpeg and VLC inputs in OBS, ... The video is sometimes butter smooth but then starts to stutter ever so slightly, and this goes back and forth over time. I don't even think that this is a problem specific to OBS, but rather that it might be an issue of the cam providing framerates (or timestamps) that are slightly off, and that this is a problem in combination with displaying/rendering the video at 60 FPS, since OBS has to synchronize the input with what it renders. I tried adding the source using obs-gstreamer in the most straight forward way:

v4l2src device=/dev/video6 ! image/jpeg,framerate=60/1,width=1280,height=720 ! jpegdec ! video.

(I need to use image/jpeg to set the cam to mjpeg so I get 60 or even 90 FPS, but that has always been the case.) The input works great, but it has exactly the same stuttering issues like e.g. the normal V4L2 source. Do you have any idea or hint what I could attempt in the gstreamer pipeline to mitigate this issue? Somehow I wish that it would just pull frames as fast as it can, and if it has to correct for discrepancies in the framerate, then it should do so as seldom as possible instead of making the video stutter for a prolonged time.

2. The second, more general, challenge that I have is that I would like to record the different input sources (i.e. the two or more V4L2 devices) separately to disk like I did before for later editing, and at the same time compose them in OBS for streaming. Now the general problem with this is that each of the V4L2 devices can only be opened once. The "go-to" idea is to use the v4l2loopback module to make "copies" of the V4L2 devices and use those in two separate programs. But if you dig a bit deeper into that direction, your sanity may suffer. For example, ffmpeg V4L2 output only supports the write() method instead of mmap which drops all timestamps and does not allow for smooth playback. Furthermore, I believe after really trying and digging into the code that v4l2loopback itself has bugs which lead to race conditions especially with relatively high framerates. While gstreamer-launch is able to push video to v4l2loopback devices better than ffmpeg does, frames read from the v4l2loopback devices are sometimes corrupted. Therefore I am looking for other possibilities to split the input devices in some way in order to record them and use them as sources in OBS at the same time.

My vague ideas up to this point include capturing the V4L2 devices and streaming them using local streaming via UDP or TCP, however latency and reliability really was an issue in my experiments, but maybe you have some hints for making this possible. Another idea was to use FIFO pseudo-files and maybe a buffering program in between to forward video between processes. All in all, I'm looking for ideas on how to share a V4L2 device either between two OBS instances, or OBS and some external program. Or maybe the recording of the source could even be done as part of the gstreamer pipeline in OBS, but I'm not sure if this is very convenient.

Okay, this posting has become much longer than I expected, sorry about that. :D But like I said, I have a feeling that maybe you guys are the right persons to ask about these challenges, and maybe obs-gstreamer can help in some way. Thanks again for this plugin!


----------



## Tuna (Oct 20, 2018)

1. I would at least try to add some queue elements to the pipeline so you will get some buffering in case downstream is blocking. If may not help with the stuttering though. You can try to use pipeline timestamps from the options and the samples will get synced to the system clock potentially helping in playback smoothness. It may add latency though - especially you may encounter sync issues after recording longer periods of time. But ultimately it depends on how smooth and consistent v4l2 and the camera are delivering frames. It can be further improved, but it requires all components synced to the same clock - which is not trivial to achieve.


```
v4l2src device=/dev/video6 ! image/jpeg,framerate=60/1,width=1280,height=720 ! queue ! jpegdec ! video.
```

2. You can share the memory/image data the camera delivers. Use tee elements and shm elements. For example, make an external app (or use gst-launch-1.0) that runs a similar pipeline:


```
v4l2src ! image/jpeg ! tee name=tee \
  tee. ! queue ! jpegdec ! gdppay ! shmsink \
  tee. ! queue ! matroskamux ! filesink
```

And you can pick up the image from the shm socket with this plugin from OBS. (there is another linux plugin here that captures GNOME screens which basically uses the same idea if you need a reference)


```
shmsrc ! gdpdepay! video.
```

Or of course you can directly save it to disk too directly in the plugin pipeline:


```
v4l2src ! image/jpeg ! tee name=tee \
  tee. ! queue ! jpegdec ! video. \
  tee. ! queue ! matroskamux ! filesink
```


----------



## Ochi (Oct 21, 2018)

Thank you very much for your response! I wasn't aware of the shmsrc/sink and the gdppay/depay elements, I guess it doesn't get much closer than that to what I'm trying to achieve. I was able to show the sources tiled next to each other in one OBS instance for recording, and at the same time forward them to another OBS instance for composing the sources for streaming. It seems to be quite reliable, also when I change something in the master instance and the slave needs to reconnect. I had to disable "Sync appsinks to clock" in the slave's settings though, otherwise both ends become incredibly laggy.

(Also the two OBS instances with one recording in 4K 60 FPS on the GPU and one encoding for streaming on the CPU are borderline intense on system resources when much is happening on screen, but that's another issue. ;) )

What I also did was to compile the gstreamer "entrans" family of plugins in an attempt to fix the stuttering using the "stamp" plugin, but not really successfully yet. And I (re)compiled gst-plugins-bad to include NVENC capabilities since I'm playing around with the possibility to record outside of OBS on the command line and forwarding the video to the streaming OBS instance.

I saw that there are also other "inter process" sinks/sources like "ipcpipeline", however I'm not sure how to connect the fdin/fdout properties in a pipeline on the command line... just out of curiosity, is there a way to do this? I really like the possibilities of gstreamer, but I'm just getting started to understand them. :)

Thank you for your help, much appreciated!


----------



## Tuna (Oct 22, 2018)

GStreamer can do a lot. Feel to enter the adventurous path down the line. But all this plugin does is to offer you a way to feed some audio and video data into OBS ;-)

The more complex you go you may it also find it helpful to modify the plugin altogether - it really does the absolute minimal thing for what it does..


----------



## Denton (Nov 11, 2018)

Hi, I'd very much like to use GStreamer into Windows OBS with a Raspberry PI. My initial try with the 0.0.4 binaries kindly compiled resulted in a BSOD. 
I thought I'd have a go compiling it - and saw that it needs latest Gstreamer. After some uphill, I got GStreamer 1.14.4 compiled and installed using Visual Studio 2017 and MinGW.

However, I'm missing something since when I try to build obs-gstreamer - I get:

$ meson --buildtype=release build
The Meson build system
Version: 0.48.1
Source dir: C:\MinGW\msys\1.0\home\admin\obs-gstreamer-master
Build dir: C:\MinGW\msys\1.0\home\admin\obs-gstreamer-master\build
Build type: native build
Project name: obs-gstreamer-source
Project version: undefined
Native C compiler: gcc (gcc 6.3.0 "gcc (MinGW.org GCC-6.3.0-1) 6.3.0")
Build machine cpu family: x86
Build machine cpu: x86
Compiler for C supports link arguments -static-libgcc: YES

meson.build:30:0: ERROR:  C library 'obs' not found

A full log can be found at C:\MinGW\msys\1.0\home\admin\obs-gstreamer-master\build\meson-logs\meson-log.txt

Do you have any instructions how to compile for Windows please?

Regards


----------



## Tuna (Nov 12, 2018)

First of all you could have just installed the binary release of GStreamer from their site. That gets a lot of hassle compiling GStreamer  yourself out of the way ;-)

You are currently stuck at finding the the OBS required development files. I rely on meson's pkg-config search combination to do that. That may be a little more tricky on the Windows side, because well Windows does not support this system.

To be honest. I think your best bet is to create a Visual Studio project or Makefile by hand and add the locations by hand , libraries and header files etc.. Sorry if thats a little inconvenient.. but Windows is just too annoying in that regard - I'm open for suggestions.

P.S. Since this is all in userspace a BSOD should never happen..


----------



## Tuna (Jan 27, 2019)

Tuna updated obs-gstreamer with a new update entry:

0.0.6



> - Fixed some small bugs I think
> - Accept RGBx and BGRx color formats
> - Experimental prebuilt plugins
> 
> The prebuilt libraries are untested. If they don't work for you, please try to figure out why and report. I suspect there may be problems with dependency libraries to be found on the target system as they may be located on different ones as on the build machine..



Read the rest of this update entry...


----------



## Burgs (Feb 21, 2019)

Greetings,

  I am brand new to OBS and I saw this plugin that got my attention.  I would like to ask how to use it to feed a Gstreamer pipeline into OBS?  I assume the pipeline is used as a source however I'm not sure how to go about configuring OBS to mount it...something simple such as "gst-launch-1.0.exe videotestsrc ! autovideosink" I suppose is a good place to start.  I thank you in advance for any advice.  Regards.


----------



## Tuna (Feb 21, 2019)

If you check out the README.md there is one example for that. Actually it is the default pipeline when you add the source to a scene.

A little more simplified/adjusted to your video only example this would be something like that:


```
videotestsrc is-live=true ! video.
```


----------



## Burgs (Feb 22, 2019)

Thank you for the reply.  I will have a look at the README.md file.


----------



## Burgs (Feb 22, 2019)

OK I guess I have an additional question...I'm not sure where to place the Gstreamer pipeline code in order to feed it into OBS?  I gather it must be used as a 'source'.  Inspection of the 'source' panel in OBS leads me to believe perhaps I would need to select the 'Media Source' tab...and then paste the Gstreamer pipeline code into there (under 'add existing')...?  Or perhaps the 'text (GDI)' selection...?
  Is it also necessary to open up a console and type the Gstreamer pipeline there as well, as if running Gstreamer in a 'standalone' mode...or is that not necessary in this case (as perhaps OBS serves as an 'emulator')?  I thank you in advance for any suggestions.  Regards.


----------



## Tuna (Feb 23, 2019)

The plugin should show in the sources as "GStreamer source". It will only do so if the installation is successful. That means the plugin is installed and the GStreamer SDK is installed. This varies from platform to platform (the documentation on how to do that is lacking). If you have figured that out you will set the pipeline in its property page.

See https://github.com/fzwoch/obs-gstreamer/issues/3 for an Image of the plugin properties.

https://github.com/fzwoch/obs-gstreamer/issues/13#issuecomment-464958004 in brief tells how to install on Windows.


----------



## Burgs (Feb 24, 2019)

OK thank you for that information sir...!


----------



## Tuna (Jul 11, 2019)

Tuna updated obs-gstreamer with a new update entry:

0.0.7



> added option whether to clear the last frame on end-of-stream or error or not.
> added option to set retry timeout.
> changed macOS suffix from .dylib to .so to be actually picked up by OBS.



Read the rest of this update entry...


----------



## sebastinus (Aug 15, 2019)

Hello everybody,

First of all many thanks to Tuna for developing this plugin,  I hope it will solve my issues when recording rtsp-streams over a longer period of time (2-3 hours) without getting errors.

Recording rtsp-streams by selecting the mediasoucre of obs, isnt´t working properly.
But I have a problem to get the rtsp-stream working with the gstreamer-plugin. Maybe there is somebody out there, who could give me a hint why.

The gstreamer command which is working via the commandline would be this:

gst-launch-1.0 -e rtspsrc location=rtsp://10.200.7.130/axis-media/media.amp protocols=udp ! rtph264depay ! h264parse ! mp4mux ! filesink location=test.mp4

In the github readme-file  of the plugin is an example for a rtsp-stream included:

uridecodebin uri=rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov name=bin ! queue ! video. bin. ! queue ! audio.

This is not working for me in obs and my idea of getting my commad working would be:

uridecodebin uri=rtsp://10.200.7.130/axis-media/media.amp name=bin ! queue ! video. bin. ! queue ! audio.

Sadly, this is also not working.

Any help is welcome, maybe somebody could post his working rtsp-command for the gstreamer-plugin.

thanks in advance for your help,
sebastinus


----------



## Tuna (Aug 15, 2019)

Hi,

1) The RTSP stream URL may have changed or is currently down? Even with gst-play-1.0 I could not get to play at the moment.

2) Do these Axis cameras provide audio? You are connecting the audio path too which you haven't in your working example. When you also connect the audio path it may actually expect and wait for it indefinitely. Try removing it.

> uridecodebin uri=rtsp://10.200.7.130/axis-media/media.amp name=bin ! queue ! video.

3) Make sure you actually have a H.264 decoder installed. Try "gst-play-1.0 rtsp://10.200.7.130/axis-media/media.amp". The ffmpeg decoders for GStreamer usually are in an extra package names "gstreamer1.0-libav" or similar.

4) Start OBS from a terminal like "GST_DEBUG=3 obs" and you will get some more messages on the console on what may be wrong.


----------



## adalbert (Aug 23, 2019)

Hello,

i already have a working setup with Raspberry Pi 4 (+ USB3 HDMI capture card) transmitter and VLC Video Source (OBS) receiver. It provides good quality and smooth video, but there is over 1 second of latency, which is not constant, even though i am using UDP protocol. So i would like to replace VLC Video Source with GStreamer source, but i have some problems.

My current, known good setup:
*RPi 4 transmitter: *
gst-launch-1.0 -vv -e v4l2src device=/dev/video0 ! videoconvert ! "video/x-raw,width=1280,height=720,framerate=60/1" ! omxh264enc target-bitrate=2000000 control-rate=1 ! "video/x-h264,profile=high" ! h264parse ! queue max-size-bytes=10000000  ! mpegtsmux ! rtpmp2tpay ! udpsink host=192.168.1.230 port=5000 

*OBS VLC Video Source: *
Playlist: rtp://@:5000
Network Caching: 100ms

*Media Source *also works: udp://0.0.0.0:5000

I like that setup because it always resumes the connection when it's interrupted*,* even after I reboot the RPi or turn the wifi off/on. I would like to achieve the same result, but with lower latency, ideally with a constant latency.

I tried this command with* GStreamer source* in OBS:
udpsrc port=5000 ! rtpmp2tdepay ! tsdemux ! h264parse ! decodebin ! video.

But it doesn't output anything. Tried various other commands, but with no success. I only managed it to work with TCP connection on both sides, but that causes latency problems. I would really appreciate any help on this issue.

----
BTW currently i am having good results with a small workaround... *Game Capture source*, capturing output of *mpv *player running in background with such parameters:

mpv --no-cache --untimed --no-demuxer-thread --no-border --window-scale=1 --keepaspect --no-window-dragging --video-unscaled=yes --video-sync=audio --no-osc --vd-lavc-threads=1 udp://0.0.0.0:5000


----------



## Tuna (Aug 24, 2019)

You wrap an MPEG TS stream into RTP. 

1. You should be able to remove the RTP layer completely and send MPEG TS over UDP. (RTP may be a good idea if you want to use RTP specific features like re-sending packets etc. which your current example does not)

2. If you use RTP you need to tell the receiving side some more info - which is usually transferred via SDP:

udpsrc port=5000 ! application/x-rtp, clock-rate=90000, encoding-name=MP2T-ES ! rtpmp2tdepay ! ..

Or something similar (just came up with that from memory)


----------



## adalbert (Sep 5, 2019)

Thanks for the suggestion, I tried that pipeline, i also tried various other modification, but had no success. Anyway i found obs-gstreamer useful, because the way I work now is to run two separate gstreamer instances on Raspberry Pi: first one transmits the video only, and second one transmits PCM audio over UDP. I can receive the video with Game Source + screencap of MPV player, and receive audio only in OBS Gstreamer Source without problems.

audio transmit with RPi:
gst-launch-1.0 -v alsasrc "device=hw:1,0" ! audioconvert ! rtpL24pay ! udpsink host=192.168.4.9 port=6000
OBS: udpsrc uri=udp://0.0.0.0:6000 caps="application/x-rtp,channels=(int)2,format=(string)S16LE,media=(string)audio,payload=(int)96,clock-rate=(int)44100,encoding-name=(string)L24" ! rtpL24depay ! audioconvert ! audioresample ! audio.

By the way MPV allows me to save raw copy of the UDP video stream in .ts container.


----------



## adalbert (Oct 6, 2019)

Hello, I've been doing some exercises with gstreamer recently to understand it better, I found out that bad-plugins package wasn't installed and I didn't have tsdemux. Now the video works fine with this pipeline:

Receiver (OBS):
udpsrc port=5000 caps=application/x-rtp ! rtpjitterbuffer latency=50 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert ! video.

Transmitter:
gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! videorate ! "video/x-raw,width=1280,height=720,framerate=60/1" ! omxh264enc target-bitrate=5000000 control-rate=1 periodicty-idr=15 ! "video/x-h264,profile=high" ! mpegtsmux ! rtpmp2tpay ! udpsink host=192.168.0.1 port=5000 sync=true


With parameters: unchecked _Use pipeline time stamps_, unchecked _Sync appsinks to clock_ I have very low latency, around 100msec.
But there is a problem: video is not buttery smooth - I am transmitting 60 fps, but it feels like 20-30 fps in OBS.

I can fix stuttering video by checking the option: _Sync appsinks to clock_. I am getting perfect 60fps then, but there is a second or two of delay added.

I also noticed some weird behavior with _Use pipeline time stamps_ checked. Video plays smooth with fairly low latency, but every ~8 seconds it skips half a second of video (it looks like the video is playing a tiny bit too slow and resynchronizing every x seconds).

Do you know if it is possible to keep both the low latency and stutter-free video?

---update:
udpsrc port=5000 caps=application/x-rtp ! rtpjitterbuffer latency=20 ! rtpmp2tdepay ! tsdemux ! h264parse ! avdec_h264 ! videoconvert  ! videorate ! video/x-raw,framerate=60/1 ! video.

This and _Use pipeline time stamps_ checked causes latency of 200 to 500ms (it is different every time you restart the pipeline), but outputs smooth video. Ideally the latency should stay consistent.


----------



## Tuna (Oct 7, 2019)

Latency and smoothness is a general video codec / transmission thing. I recommend to read something on VBV buffer model to understand why things happen in certain ways and why it requires some manual tuning depending on your use case for optimal results.


----------



## Tuna (Oct 14, 2019)

Tuna updated obs-gstreamer with a new update entry:

v0.1.0



> - added encoder plugin (experimental)
> 
> This is high experimental as it is not yet well tested. Basically this update adds an encoder plugin to OBS. That means you can make use of GStreamer supported H.264 encoders for streaming and recording.
> 
> ...



Read the rest of this update entry...


----------



## Farango (May 20, 2020)

Hello everyone !

I tried for 2 hours to install the plugin in OBS Studio but i can't manage to have the "gstream" source.

I've installed gstream 1.0 and have tried to put the "obs-gstreamer.dll" everywhere, without success. 

What Am i suppose to do to make it appear ?

Thanks for the help!


----------



## Tuna (May 20, 2020)

My bet is on that you need to add the directory of the GStreamer binaries to you $PATH variable. I don't think the GStreamer installer is doing that for you.


----------



## ancer (May 25, 2020)

Hello and thank you for very useful plugin.

I'm consuming RTMP source and it works for video without any problem. But I have problems with audio.

rtmpsrc location="rtmp://---:1935/obs/wbc live=1" ! decodebin name=src src. ! audioconvert ! audio. src. ! videoconvert ! video.

I have both video and audio. But audio is incorrectly sampled. I hear high pitch voice instead of normal.

If instead of "audio." I use "directsoundsink" the sound is as expected. But in this case obs-gstreamer produces audio directly to output and OBS cannot control that audio source.

Please help what I need additionally to tell obs-gstreamer so it generates audio correctly.

Thanks in advance.


----------



## Tuna (May 25, 2020)

Maybe you can save the audio into .wav file to check tthe audio properties. Perhaps open a github issue in that case. This sounds like a bug where I send wrong audio propertied to OBS.


----------



## Farango (May 28, 2020)

Tuna said:


> My bet is on that you need to add the directory of the GStreamer binaries to you $PATH variable. I don't think the GStreamer installer is doing that for you.


Gstream variables are already installed in PATH.


----------



## Tuna (May 28, 2020)

Farango said:


> Gstream variables are already installed in PATH.


That screenshot does not show that..


----------



## gmesmer (Jul 28, 2020)

Hello, I'm using the gstreamer plugin as both a source and as an encoder using the OpenMAX(Tegra). Could anyone explain what the extra encoder options are? I'm wordering if its possible to change between h264 and h265 for the future.


----------



## Tuna (Jul 28, 2020)

gmesmer said:


> Hello, I'm using the gstreamer plugin as both a source and as an encoder using the OpenMAX(Tegra). Could anyone explain what the extra encoder options are? I'm wordering if its possible to change between h264 and h265 for the future.


H.265 is not handled as I don't know any ingestion points that support it. I never even considered looking at that yet.

The extra options are parameters that your encoder element may support. Try "gst-inspect-1.0 omxh264enc" or so (depending on the exact name, don't quote me on that). And it lists available options. You can add key=value pairs separated by spaces there.


----------



## gmesmer (Jul 28, 2020)

Tuna said:


> H.265 is not handled as I don't know any ingestion points that support it. I never even considered looking at that yet.
> 
> The extra options are parameters that your encoder element may support. Try "gst-inspect-1.0 omxh264enc" or so (depending on the exact name, don't quote me on that). And it lists available options. You can add key=value pairs separated by spaces there.



Thanks for the reply, I was thinking the extra options had to do with the plugin and not the encoder being used by the plugin (which you confirmed is the omxh264enc at least for OpenMAX (Tegra)). Not sure exactly what you mean by ingestion points. omxh265enc omxvp8enc and omxvp9enc were what I was referring to as possible other OpenMAX encoders.


----------



## Tuna (Jul 28, 2020)

With ingestions points i mean streaming services. H.265 will work for recording only. I think the interface for encoding only supports H.264 in OBS now (not sure as of writing). If you want to something else I believe the only option is to use the custom FFMPEG output of OBS.


----------



## gmesmer (Jul 28, 2020)

Tuna said:


> With ingestions points i mean streaming services. H.265 will work for recording only. I think the interface for encoding only supports H.264 in OBS now (not sure as of writing). If you want to something else I believe the only option is to use the custom FFMPEG output of OBS.


That is correct, OBS doesn't support sending h265, vp9, etc to streaming services. So no way to implement a different gstreamer encoding menu for recordings which allows for h.265?


----------



## dreamer (Aug 2, 2020)

I just compiled this plugin against latest obs-studio master `478f1de8468223524f92aafd194675c89947c544` and honestly I don't know how it's supposed to work.

Should there be a new input-type to choose as a source? because I don't see it


----------



## dreamer (Aug 2, 2020)

dreamer said:


> Should there be a new input-type to choose as a source? because I don't see it


Sorry, it's been a while. I don't see the plugin being loaded at all. It was installed to `/usr/local/lib/x86_64-linux-gnu/obs-plugins`
Will investigate what's up with obs not finding it.


----------



## Tuna (Aug 2, 2020)

dreamer said:


> Sorry, it's been a while. I don't see the plugin being loaded at all. It was installed to `/usr/local/lib/x86_64-linux-gnu/obs-plugins`
> Will investigate what's up with obs not finding it.



The GStreamer DLLs need to be found (assuming Windows which you didn't state). Usually this is done by adding the GStreamer bin path to the Windows PATH variable.

EDIT: Oh its Linux judging from the path. That path seems okay if you have installed/compiled OBS from source. May be different if you have PPA or some other install source.


----------



## dreamer (Aug 2, 2020)

Tuna said:


> EDIT: Oh its Linux judging from the path. That path seems okay if you have installed/compiled OBS from source. May be different if you have PPA or some other install source.


Yeah sorry for not explicitly stating :)

I ended up manually making a `~/.config/obs-studio/plugins/obs-gstreamer/bin/64bit/` and putting `obs-gstreamer.so` in there and then it did work! Wich is a bit odd I guess.

Now to get the rtsp example to work, seems my rtsp cam does not want to be opened this way.


----------



## thejamo (Aug 8, 2020)

Hi Tuna!

I have been reading gstreamer stuff for a few weeks now and while I have managed to get it working in a few configurations, there are some things I simply cannot work out... or rather I haven't worked out yet and I'm not sure if it's because I don't understand something and am continuously doing something wrong.

The good news is that I am able to get good quality video from an RPi camera across ethernet and into OBS on Windows without a problem using the following pipelines:

On RPi
raspivid -t 0 -w 800 -h 480 -fps 30 -b 10000000 -o udp://<IP>:5000

On OBS (Windows 10)
udpsrc port=5000 ! h264parse ! avdec_h264 ! video.

In fact these are pipelines that another use posted earlier in this thread, and they work well, with minimal latency. The problem is when I try to increase the resolution to anything greater than 800x480. When I do, the frames arriving in OBS are corrupted, though not always the whole frame; it's mostly just the bottom half of the frame.

I have gathered that a possible solution is to include 'rtpjitterbuffer' in the OBS pipeline to sort out packet order, but try as I might I cannot make it work.

Is it possible to make this work with the above pipelines? If so, can you shed some light on how? Or would it be better to send the video using gstreamer on the RPi side as well? Please let me know, and if I'm ever in your neck of the woods, I'll buy you a beer! Thank you!


----------



## Tuna (Aug 9, 2020)

UDP transfer by design is subject to packet loss. You either analyze it thoroughly and tune it to your use case or switch to a TCP based protocol. I believe someone did it with pi before. Either in this thread or in some closed issue on github.









						Example: RaspberryPi Zero --[wifi]--> OBS · Issue #3 · fzwoch/obs-gstreamer
					

Not exactly an "issue," but an example. On Raspberry Pi Zero: gst-launch-1.0 rpicamsrc name=videosrc keyframe-interval=10 shutter-speed=0 iso=200 drc=0 exposure-mode=1 metering-mode=1 awb...




					github.com


----------



## johnny_bravo (Sep 29, 2020)

Hello, 

I managed to get gstreamer source set up for obs on win10k . So far much more stable and less CPU intensive than connecting an rtsp camera to obs via VLC source. Also latency is smaller, 300ms compared to 800ms  compared to Vlc source, 

A few issues i notice :

1. After a power off and on  of the camera, picture freezes and stays frozen. Whatever settings i try for restart or Error. Changing And saving any setting in gstreamer source gets iT going again. 
2. Adding 5 ip rtsp camera’s works great. No 6th camera is accepted though. Not via rtspsrc nor via uridecodebin.
It seems no limitation to obs, as i can add a 6th camera via vlc source.

You have any advice?


----------



## Tuna (Sep 29, 2020)

1. I guess there was a fix in my code that was not released yet. So you may want to try to build master by yourself, or wait as I may make another release soon (no schedule though) as v26 was recently released.

2. I cannot tell. There should not be a technical limitation to my knowledge to prevent this. Probably would require some debugging whats happening in this particular case.


----------



## johnny_bravo (Oct 6, 2020)

hello,
1. i will await your release before upgrading. 
2. ok. not  big problem for now but i will do some extra testing. 

thanks for now, my setup with cheap ip cameras is very stable and low latency now. Als processor load dropped considerably. 

thanks!!


----------



## Yiays (Oct 30, 2020)

I've tried on multiple devices, but I've been unable to get the source to show up in OBS, this is with a complete install of gstreamer to the root of the C: drive and the path to bin added in %path%. (And the plugin is in the x64 plugins folder, of course)


----------



## Tuna (Oct 30, 2020)

Assuming you are trying to use the prebuilt binary, I think you need to install the MINGW version of the GStreamer runtime. MSVC and MINGW differ in their file names as MINGW ones are prefixed with "lib" while MSVC aren't. So I suspect the plugin now looks for DLL file names that are not present. If you want to use the MSVC version you will have to build the plugin yourself.


----------



## Elijahkato (Nov 3, 2020)

Hello Tuna,

I have read about the success stories when using the gstreamer for rtsp streaming in OBS. I have followed all the steps below;

- Download and installed gstreamer-1.0-mingw-x86_64-1.18.0.msi - I noticed it didnt install in the C: drive instead it went to my E: drive.
- I followed one of the instructions on adding environment variables both for system and user. - see screenshot
- I copied the obs-gstreamer.dll file downloaded from github to my obs-plugin folder x64
- I currently use OBS version 26.0.2.

Please, I need to know if I am missing any step.. I am new to this kind of life saving stuff.. Please help.


----------



## Elijahkato (Nov 3, 2020)

Elijahkato said:


> Hello Tuna,
> 
> I have read about the success stories when using the gstreamer for rtsp streaming in OBS. I have followed all the steps below;
> 
> ...


Its funny i am answering myself, after much trial and error...

I copied all the dll files that starts with the lib- prefix from the bin folder of the  mingw installation and pasted it in the OBS plugin folder.. this worked as i am able to see the gstream source in OBS. 


But i cant seem to know the particular dependency files that is working currently. Maybe i will just keep with the trial and error.. but if you have a heads up for me, please share and i would also like to know if there is a particular format for entering the rtsp URL. the url for my PTZ cam is rtsp://admin:@192.168.1.110/1/h264major.. i am yet to try this out as the camera is installed in church.

Thank you


----------



## Tuna (Nov 3, 2020)

Instead of copying incomplete things into that folder you should add the GStreamer bin directory to your PATH variable. See actually two posts above yours.


----------



## STEPHANVS (Nov 5, 2020)

Just came here to thank you for this amazing plugin. Now we are able to show live (~60-140ms latency instead of 1140ms) video feed on a projector. No latency video has some occasional jitter to it, but adding 1-2 frame buffer looks very promising! Thanks again!


----------



## Yeahish (Nov 5, 2020)

Hi,

Is there a way to identify which Capabilities the (video) sink accepts? (Like running gst-inspect-1.0 video)

I'm trying to use the plugin to grab a rtsp stream with low latency, but for some reason whatever pipeline I try (for example rtspsrc) other then the provided sample doesn't work. If I would be able to see the accepted capabilities I can  try to find a converter.

Sample command that doesn't work
`rtspsrc location="rtsp://user:pass@192.168.1.64:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1" ! autovideoconvert ! video.`


----------



## Yeahish (Nov 5, 2020)

Yeahish said:


> `rtspsrc location="rtsp://user:pass@192.168.1.64:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1" ! autovideoconvert ! video.`


I understand that the above code is wrong by itself. But my question is still how can I see what Capabilities these sinks have?

On another note, how can I convert the following pipeline it should be compatible with the plugin?
`playbin uri=rtsp://localhost:8554/test uridecodebin0::source::latency=300`


----------



## Tuna (Nov 5, 2020)

It supports many formats. Check the code if you want more details. Also there is video converter element internally too.

Problem with that peipleine is that it does not have and depacketizers nor decoders. That's why the examples use uridecodebin. Else you will have to insert these elements yourself which requires also some knowledge about used formats in the stream.


----------



## seriousplay (Nov 11, 2020)

Okay, I'm struggling to get it to fully work, streaming from a Raspberry Pi to Windows 10. I'm so very close, but can't quite get over the last hurdle. 
On the Pi:
raspivid -t 0 -w 1280 -h 720 -rot 180 -fps 30 -b 1700000 -o - | gst-launch-1.0 -v fdsrc ! h264parse config-interval=1 ! rtph264pay ! udpsink host = <Win10-IP> port=5000
OBS:
udpsrc port=5000 ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! fpsdisplaysink sync=false text-overlay=false ! video.

This doesn't produce anything as is, but if I strip out the "! video." part of it, it will pop up a Direct3D11 Renderer window with the video stream. So, clearly, the stream is working. It just isn't pulling it into OBS. 
I've tried a few differing strings, as well, to no avail.
udpsrc port=5000 ! h264parse ! avdec_h264 ! video.
This will lock the stream, so I can't run gst-launch from the command line. I'm pretty new to gstreamer, so I'm just learning the different possibilities. I've seen several different conversations on the issue, with several different strings to enter, none of which worked for me. 

Any tips, or full strings to put into OBS, would be extremely helpful. TIA.


----------



## STEPHANVS (Nov 11, 2020)

seriousplay said:


> Okay, I'm struggling to get it to fully work, streaming from a Raspberry Pi to Windows 10. I'm so very close, but can't quite get over the last hurdle.
> On the Pi:
> raspivid -t 0 -w 1280 -h 720 -rot 180 -fps 30 -b 1700000 -o - | gst-launch-1.0 -v fdsrc ! h264parse config-interval=1 ! rtph264pay ! udpsink host = <Win10-IP> port=5000
> OBS:
> ...


Maybe you need a queue?

I moved from uridecodebin to

```
rtspsrc location=url ! rtpjitterbuffer ! rtph264depay ! h264parse ! avdec_h264 ! queue ! video.
```
as I wanted to test `rtpjitterbuffer`.


----------



## Tuna (Nov 11, 2020)

seriousplay said:


> fpsdisplaysink sync=false text-overlay=false ! video.


fpsdisplaysink is as its name says a sink. You cannot connect anything downstream from it.


----------



## seriousplay (Nov 12, 2020)

Okay, I removed the fpsdisplaysink and the rtpjitterbuffer pieces of the OBS side:
udpsrc port=5000 ! application/x-rtp, payload=96 ! rtph264depay ! avdec_h264 ! video.

...and it WORKED!!! Whoop whoop! Thank you guys, so much. I've been trying to get this going for a week and I knew I was close, but it took you getting me over that last hurdle. Sweet! Thank you thank you. And thank you for making such an awesome plugin for gstreamer. I can't tell you how excited I am to start using it in my church service.


----------



## STEPHANVS (Nov 15, 2020)

Trying to extract soundful information out of an Allen & Heath SQ5 connected via USB. Of course OBS cannot interpret the signal coming from the board so at the moment we are using ASIO plugin, which I am trying to substitute with gstreamer. I was able to get it to monitor with:

```
directsoundsrc device="deviceid" ! audio.
```
but it did not register any sound when video was recorded.

I would like to connect via `wasapisrc` but this I cannot get it to work.

gst-device-monitor-1.0.exe gives:

```
Device found:

        name  : Line (SQ)
        class : Audio/Source
        caps  : audio/x-raw, format=F32LE, layout=interleaved, rate=48000, channels=32
        properties:
                device.api = wasapi
                device.strid = "\{0.0.1.00000000\}.\{26eacefd-7d3b-4c83-8aa9-4d43572937ae\}"
                wasapi.device.description = "Line\ \(SQ\)"
        gst-launch-1.0 wasapisrc device="\{0.0.1.00000000\}.\{26eacefd-7d3b-4c83-8aa9-4d43572937ae\}" ! ...
```

Do you have any idea how to capture channel 1 and 2?


----------



## Tuna (Nov 15, 2020)

Sound not in the recording is probably due to a bug with timestamps. You can tick "use pipeline timestamps" as a workaround. Or set the sound source to monitor.. can be another workaround.

No idea about wasapisrc source.


----------



## johnny_bravo (Nov 16, 2020)

Tuna said:


> 1. I guess there was a fix in my code that was not released yet. So you may want to try to build master by yourself, or wait as I may make another release soon (no schedule though) as v26 was recently released.
> 
> 2. I cannot tell. There should not be a technical limitation to my knowledge to prevent this. Probably would require some debugging whats happening in this particular case.




ad 2. : Each stream needs some queue. Could it be that gstreamer supports no more than 5 queue's ? I read something like that in the multiqueue documentation, but not in the queue documentation. I will do some testing with queue2 as (extra) queue's.


----------



## johnny_bravo (Nov 17, 2020)

So i did some additional testing. When I define 5 different streams within gstreamer, the 6th will not show up. After closing and restarting OBS, 5 of 6 streams show up, missing one at random. No matter if I use rtspsrc or uridecodebin, limit is 5 streams. Any ideas  ? Thanks !


----------



## Tuna (Nov 17, 2020)

Took me a while to find an RTSP source on the internet. 6 streams don't seem to be a problem. Maybe it is a congestion problem with you network or something else limiting. I guess you will have to do some debugging why it fails.


----------



## johnny_bravo (Nov 17, 2020)

Hello Tuna

Thanks for the prompt reply. Gstreamer in OBS gets increasingly popular, it fills up a gap... .

So I need to be more specific. i have 6 streams from 6 different camera’s.

A new scène with an existing 'working' stream works perfectly. I have 3 scenes with 1 same camera, no problem.

As long as i do not add the 6th camera. This last one will just not show up.  

thanks !


----------



## Tuna (Nov 17, 2020)

As I said you need to debug a bit with the GST_DEBUG variable and examine the resulting logs. The example above makes 6 independen sources. They are not copied/reused, so logically they are 6 Independent ones, like your use case. Then again of course you haven't even posted a pipeline yet? Perhaps try rtspt:// as protocol - maybe your firewall's maximum port forwarding handles are exceeded. The reasons it may fail seem infinite..


----------



## Tuna (Nov 19, 2020)

Tuna updated obs-gstreamer with a new update entry:

0.2.0



> pipeline property only updates when you click new "apply" button or "ok"
> split options to be configurable for audio and video path independently
> calculated audio timestamps for audio only sources
> better error recovery (stream restarting)
> ...



Read the rest of this update entry...


----------



## johnny_bravo (Nov 23, 2020)

Hello Tuna, so i did Some reading about gst_debug. But i am a bit confused. 

Just add GST_DEBUG=2 at the beginning of the pipe line ? And where will the log show up? In the obs log ?

Sorry for asking but it really is a steep learning curve here ;-)


----------



## Tuna (Nov 23, 2020)

You set this on your terminal and run OBS from there. E.g. "GST_DEBUG=3 obs"


----------



## johnny_bravo (Nov 24, 2020)

thanks Tuna !

one step further. I am running on win10. Found the following :

i have to set the following environment variables 

set GST_DEBUG=5
set GST_DEBUG_FILE=c:\log\log.txt

directory c:\log exists and is writeable.  But nothing shows up . No file at all. 

Any hints ? Thnx again !


----------



## johnny_bravo (Nov 24, 2020)

one step further.
- open the windows shell ( cmd.exe )
- make sure the folder "c:\log"   exists and is writeable
- then type on the command prompt  :

set GST_DEBUG=5
set GST_DEBUG_FILE=c:\log\log.txt

then

FROM THE SAME SHELL (this is important, because the environment variable just set, only exist here in this shell )

then

change path to folder where obs64.exe is found  (   typical c:\program files\obs-studio\bin\64bit\    ) 

then

obs64 ENTER  (start obs64.exe, from the command line)

OBS will start up and the logging starts flowing.

move on to the next level ;-)


----------



## GodFollower (Nov 25, 2020)

Made an account just so I could chime in and say thanks a ton for the GStreamer plugin for OBS. Reduced our latency(both the consistent and the fluctuating) from our IP cams down to sub 100ms, much more manageable and easier to mix real-time.

Still tinkering with the jittering frames, but reading through this thread I have some ideas. It is not very noticeable, so we are functional as it stands. Just trying to fine tune it to get it as close to a full 30fps as possible.

Thanks again!


----------



## johnny_bravo (Nov 25, 2020)

GodFollower said:


> Made an account just so I could chime in and say thanks a ton for the GStreamer plugin for OBS. Reduced our latency(both the consistent and the fluctuating) from our IP cams down to sub 100ms, much more manageable and easier to mix real-time.
> 
> Still tinkering with the jittering frames, but reading through this thread I have some ideas. It is not very noticeable, so we are functional as it stands. Just trying to fine tune it to get it as close to a full 30fps as possible.
> 
> Thanks again!




Hello GodFollower, i am in the same fase as you describe.  After adding 100ms latency and the rtpjitterbuffer and ticking ‘sync to source’  the slight stuttering disappears. At a price of a delay , now running on 750 ms audio delay.


----------



## johnny_bravo (Nov 25, 2020)

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


----------



## Tuna (Nov 25, 2020)

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.


----------



## johnny_bravo (Nov 25, 2020)

@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 (Nov 26, 2020)

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 (Nov 26, 2020)

Gavin H said:


> 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 (Nov 26, 2020)

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 =)


----------



## johnny_bravo (Nov 27, 2020)

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)


----------



## johnny_bravo (Nov 28, 2020)

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 (Nov 28, 2020)

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?)


----------



## johnny_bravo (Nov 28, 2020)

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.


----------



## johnny_bravo (Nov 30, 2020)

@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 (Dec 5, 2020)

johnny_bravo said:


> @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.
> 
> ...


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 (Dec 5, 2020)

I there any difference between

```
rtspsrc location=rtsp://url latency=100 ! rtpjitterbuffer ! ...
```
and

```
rtspsrc location=rtsp://url ! rtpjitterbuffer latency=100 ! ...
```
?
I am testing with the latency values for rtpjitterbuffer, and still see some jitter now and then...


----------



## johnny_bravo (Dec 5, 2020)

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 (Dec 5, 2020)

STEPHANVS said:


> I there any difference between
> 
> ```
> rtspsrc location=rtsp://url latency=100 ! rtpjitterbuffer ! ...
> ...


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 (Dec 6, 2020)

Tuna said:


> 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 (Dec 6, 2020)

STEPHANVS said:


> 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.


----------



## johnny_bravo (Dec 7, 2020)

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 (Dec 26, 2020)

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 (Dec 26, 2020)

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.


----------



## polcape (Dec 26, 2020)

Thank @Tuna. I try with many configuration but not work

uridecodebin uri=http://192.168.1.120:8080/video name=bin ! queue ! watchdog ! video. 
uridecodebin uri=http://192.168.1.120:8080/video name=bin ! watchdog ! queue ! video.
uridecodebin uri=http://192.168.1.120:8080/video name=bin ! queue ! video ! watchdog.

How do I use watchdog?


----------



## STEPHANVS (Jan 2, 2021)

OBS weird GPU usage spikes
					

I am currently troubleshooting lagging frames. Running OBS with 3 rtspt sources via gstreamer for OBS (does not really matter, with built-in rtsp sources GPU usage is always on the peak level...) on a secondary monitor.  Since I am usually not at OBS when these happen live, I can only suspect...




					obsproject.com
				




I am posting this here, to concurrently check whether this is an obs-gstreamer issue...

Does anyone have any idea?


----------



## Tuna (Jan 9, 2021)

Tuna updated obs-gstreamer with a new update entry:

small bugfix release



> properly convert planar audio formats to interleaved
> experimental use of pipeline for audio/video filters



Read the rest of this update entry...


----------



## CathStreamer (Jan 12, 2021)

I'm very new to this Gstreamer and I wanted it very badly to work with my OBS because of the issues I'm running into with my low cost PTZ IP cam which I am using via VLC Video Source. On my Windows 10 computer I was able to install the gstreamer-1.0-mingw-x86_64-1.18.2.msi then updated the environment variables (path) copied the .dll files on to my OBS Plugin folder likewise downloaded and copied the obs-gstreamer.dll on the same folder. After that I was able to see the Gstreamer Source on my OBS. Tried adding a Gstreamer Source an IP camera and copied a recommended pipeline:

rtspsrc location="rtsp://<user>:<password>@<cam-ip-address>" latency=0 buffer-mode=auto ! rtph264depay ! h264parse ! d3d11h264dec ! video.

but the OBS logs show:

Cannot start GStreamer: no element "videoconvert"

What else do i need to fix to make it work? I searched around but find no answers. Appreciate any help. Thanks!


----------



## johnny_bravo (Jan 12, 2021)

so we have at least two different pipelines here :






						OBS weird GPU usage spikes
					

I am currently troubleshooting lagging frames. Running OBS with 3 rtspt sources via gstreamer for OBS (does not really matter, with built-in rtsp sources GPU usage is always on the peak level...) on a secondary monitor.  Since I am usually not at OBS when these happen live, I can only suspect...




					obsproject.com
				




1 (credits Stephanvs) 

rtspsrc location=rtspt://url latency=100 ! rtpjitterbuffer latency=0 ! rtph264depay ! h264parse ! d3d11h264dec ! video.

2 (my attempt)

rtspsrc location=rtspt://url latency=100 ! rtph264depay ! h264parse ! nvh264dec ! videoconvert ! video.

I have no special installation or so, and never had your message. I do use video convert as you see. What happens if you try one of our pipelines ? My camera's are 20 dollar AliExpress surveillance cams 1080p IP , no PTZ.


----------



## Tuna (Jan 12, 2021)

CathStreamer said:


> Cannot start GStreamer: no element "videoconvert"



"videoconvert" is part of the GStreamer Base plugins. If that cannot be found (what does "gst-inspect-1.0 videoconvert" from a console tell you?) then there is something wrong with your GStreamer installation.


----------



## CathStreamer (Jan 13, 2021)

Tuna said:


> "videoconvert" is part of the GStreamer Base plugins. If that cannot be found (what does "gst-inspect-1.0 videoconvert" from a console tell you?) then there is something wrong with your GStreamer installation.




Thanks for responding Tuna. Appreciate it.

Showed a lot of text when i run that command. Here are the beginning response. Hope this gives us an idea what going on...


----------



## Tuna (Jan 13, 2021)

So it seems installed. I have no idea why it would throw this error from OBS then..


----------



## robertiii (Jan 13, 2021)

I'm using Mac OS Catalina. I'm unable to get the Gstreamer Source to show up.


----------



## robertiii (Jan 14, 2021)

I have installed streamer both the developer files and the runtime. I have added the .so file to the obs app. I might just be missing something?


----------



## Tuna (Jan 14, 2021)

The prebuild binary is build via a macports installation. Depending on how you have installed GStreamer it probably won't find the correct locations. I recommend building the plugin yourself. There may be more to it by now. I have only tested it once years ago, I haven't followed up with recent macOS changes as I don't have a Mac.


----------



## robertiii (Jan 14, 2021)

I'll be completely honest not sure about how to build the plugin myself. Kinda new with all this. So sorry for the ignorance!


----------



## Tuna (Jan 14, 2021)

Don't feel bad about it. It is not trivial. Unfortunately that is the reason why it may not work out of the box. Best effort is to install GStreamer via the macports packet manager, not homebrew or the official releases. That was the way I chose to create these kind of automatically without having a Mac. For everything else you most likely need some development experience :(


----------



## robertiii (Jan 14, 2021)

I did install from macports now still nothing. Thanks though!


----------



## robertiii (Jan 14, 2021)

Ok now it randomly decided to show.


----------



## robertiii (Jan 14, 2021)

Probably not the right place but when I run gstreamer through terminal I get no mpeg-4 aac decoder. So obviously same stream won't work on obs.


----------



## Tuna (Jan 14, 2021)

Iirc when installing with macports there exist these variants where features can be enabled/disabled. Maybe AAC decoder is not part of the default install.


----------



## robertiii (Jan 14, 2021)

Ok. I have somehow stumbled my way through and have a stream...and it's only with a 3 second delay...Doing something wrong lol


----------



## CathStreamer (Jan 19, 2021)

Tuna said:


> So it seems installed. I have no idea why it would throw this error from OBS then..



I figured out the problem. The previous obs-gstreamer.dll was 128kb in size and I could no longer find the link where it came from. I found one from https://github.com/Fabian-Schmidt/obs-gstreamer/releases/tag/v0.0.4-w which is 16kb. Honestly, I can't tell the difference except for the size. It is working now however I have another issue this time with regards to plugins-bad installation on Windows. I couldn't find downloadable pre-compiled plugins for Windows that supports  H265 IP cameras including libde265dec. I would appreciate if you can point me to it.

Here's the sample video I'm getting with this sort of default pipeline,
rtspsrc location=rtsp://<ip_address>:554/user=admin_password=<password>_channel=1_stream=0.sdp?real_stream latency=0 ! decodebin ! videoconvert ! video.


----------



## Tuna (Jan 19, 2021)

CathStreamer said:


> I found one from https://github.com/Fabian-Schmidt/obs-gstreamer/releases/tag/v0.0.4-w which is 16kb. Honestly, I can't tell the difference except for the size.


Looks like he provided a version linked top the Visual Studio studio release of GStreamer instead of the MinGW one.



CathStreamer said:


> It is working now however I have another issue this time with regards to plugins-bad installation on Windows. I couldn't find downloadable pre-compiled plugins for Windows that supports  H265 IP cameras including libde265dec. I would appreciate if you can point me to it.


I would think they don't even made a dedicated decoder plugin. Usually the FFMPEG wrapper element exposes a H.265 decoder. But I guess that depends on the feature set of the FFMPEG library and how it has been compiled.

(EDIT: there seem indeed exist a de265 element for decoding, in doubt you have to build it yourself though)


----------



## cibc-redding (Jan 22, 2021)

I've read through all the posts here as well as documentation I could find on gstreamer.  We're running OBS in Mac OS 10.15 (Catalina).  I've installed gstream runtime using Homebrew, and I've copied the obs-gstreamer.so file to plugins folder of OBS.

The gstream source still doesn't show in OBS, and I think it's because my path isn't set.

This is from OBS log: 


```
os_dlopen(/Applications/OBS.app/Contents/PlugIns/obs-gstreamer.so->/Applications/OBS.app/Contents/PlugIns/obs-gstreamer.so): dlopen(/Applications/OBS.app/Contents/PlugIns/obs-gstreamer.so, 257): Library not loaded: /opt/local/lib/libgstreamer-1.0.0.dylib
11:47:43.177:   Referenced from: /Applications/OBS.app/Contents/PlugIns/obs-gstreamer.so
11:47:43.177:   Reason: image not found
11:47:43.177:
11:47:43.177: Module '/Applications/OBS.app/Contents/PlugIns/obs-gstreamer.so' not loaded
```

For the life of me I can't figure out how to set the PATH that several refer to.  It seems that everything I see posted relates to a Windows installation.  How do I set the path in Mac OS?


----------



## Tuna (Jan 22, 2021)

Try installing GStreamer via macports. Latest versions of homebrew changed install locations and therefore are not found by the pre-built binary. Or, as always, build and link the plugin yourself to the GStreamer libraries you have installed.


----------



## cibc-redding (Jan 24, 2021)

do I have to install Xcode?


----------



## sperok (Jan 31, 2021)

Are there any known issues using a tee in the gstreamer plugin pipeline to feed an opencv based analytics sink? The sink does not modify the video but does use websockets to switch scenes in OBS based on what it observes. The goal is to avoid video buffer copies in the analytics pipeline.


----------



## LuigiE.Poletti (Feb 4, 2021)

cibc-redding said:


> I've read through all the posts here as well as documentation I could find on gstreamer.  We're running OBS in Mac OS 10.15 (Catalina).  I've installed gstream runtime using Homebrew, and I've copied the obs-gstreamer.so file to plugins folder of OBS.
> 
> The gstream source still doesn't show in OBS, and I think it's because my path isn't set.
> 
> ...



I have same problem, have you find some solution?


----------



## Tuna (Feb 4, 2021)

LuigiE.Poletti said:


> I have same problem, have you find some solution?





Tuna said:


> Try installing GStreamer via macports. Latest versions of homebrew changed install locations and therefore are not found by the pre-built binary. Or, as always, build and link the plugin yourself to the GStreamer libraries you have installed.


----------



## Tuna (Feb 5, 2021)

Tuna updated obs-gstreamer with a new update entry:

0.3.0



> added a glib main loop for the source feature. this should fix a lot of things for Windows and macOS (error reporting, restarting on EOS and/or ERROR, other?)
> fix an EOS restart issue
> added an experimental audio filter
> plugin reports its build hash in log (pseudo versioning)



Read the rest of this update entry...


----------



## jann2021 (Feb 8, 2021)

Hi,
obs-gstreamer is great but... I can't have audio and video sync with low delay... If I check "sync applink to clock audio/video" audio/video is synchronized but delay is bigger than in vlc source.
I'm using this command:

```
uridecodebin uri=rtsp://user:password@ip/live latency=100 name=src src. ! queue !  video. src. ! queue ! audio.
```

running:

```
gst-launch-1.0 rtspsrc location=rtsp://user:password@ip/live latency=100 name=src src. ! queue ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! autovideosink src. ! decodebin ! audioconvert ! autoaudiosink
```
from command line works fine - almost no delay and audio and video is synchronized.

So - the plugin is working ok as far as low video delay, but for me is useless as far as audio+video low delay. My camera is Dahua.

Anybody is using this plugin to have audio&video stream with low delay and can share with me a solution?


----------



## johnny_bravo (Feb 8, 2021)

jann2021 said:


> Hi,
> obs-gstreamer is great but... I can't have audio and video sync with low delay... If I check "sync applink to clock audio/video" audio/video is synchronized but delay is bigger than in vlc source.
> I'm using this command:
> 
> ...



Try playing with all combinations of sync to source and sync to sink.  If not set right, latency will stick to 2 seconds.  If you have only one camera, try without sync.  It brought back latency for me from 2000ms ( 2 seconds) to about 400ms.


----------



## TheGodlyNoob (Feb 8, 2021)

hey guys, I tried setting it up yesterday and so far it's working great besides that the audio is not in sync with the video.

I send my stream to an RTMP server I setup with NGINX on my raspberry pi and then I receive it into my OBS Gstreamer source.

The audio sometimes starts crackling really bad/starts having really bad robotic audio and it is delayed 2+ seconds ( at random ).

When I use VLC source I have no audio delay from the RTMP feed so it's probably something I need to add in the pipeline.

Here is what I am using currently :

uridecodebin uri=rtmp://rtmpserver name=bin latency=100 ! queue ! video. bin. ! queue ! audio.


----------



## jann2021 (Feb 8, 2021)

johnny_bravo said:


> Try playing with all combinations of sync to source and sync to sink.  If not set right, latency will stick to 2 seconds.  If you have only one camera, try without sync.  It brought back latency for me from 2000ms ( 2 seconds) to about 400ms.



Hi,
I have two cameras but only one is with audio. I've tried combinations with time stamps and sync. No success. The only success is small video delay. Audio is not working with gstreamer. I've tested it on linux and windows 10. 
But gst-launch is playing as it should so it's not gstreamer problem but obs-gstreamer plugin or some magic configuration. Can you share johny yours gstreamer source path? or print screen with all settings?


----------



## jwoods09 (Feb 14, 2021)

Hi, @Tuna -
Thanks for the great plugin.  I had a ton of problems with my stream from an IP camera in OBS freezing and using your plugin has seemed to resolve it. However, after about 6 hours, the stream in OBS goes black. After researching, I do have VLC installed as well. That fixed the black screen, but it was freezing. Your plugin fixed the freezing but now its going black. LOL. Do you have any thoughts on how I could resolve this? Im running OBS 26.1.1 on XUBUNTU installed on a mini pc. 

I appreciate your willingness to help everyone here!

PS: Im VERY new to streaming so I apologize if I haven't provided enough information to help me LOL.


----------



## adalbert (Feb 28, 2021)

Hi,
after working for a while with this nice plugin on various PCs, I often found installing GStreamer every time and setting all paths pretty frustrating and time consuming. So I think i found a way to make an easy and clean solution for portable setups (you have everything in one directory - OBS, obs-gstreamer and GStreamer runtime). That should work for Windows PCs.

1. Unzip OBS-Studio-26.1-Full-x64 (i found 26.1.1 to not work) to _OBS _directory. Create _gstreamer _folder inside that directory.
2. Copy contents from _C:\gstreamer\1.0\mingw_x86_64a_\ into _gstreamer _directory inside _OBS _directory.
3. Extract _obs-gstreamer.dll_ into _OBS\obs-plugins\64bit_ directory.

Now create file _run_obs_gstreamer.bat_ inside _OBS _directory:

```
cd /D "%~dp0"
cd gstreamer
SET GSTREAMER_1_0_ROOT_MINGW_X86_64=%cd%
cd bin
SET PATH=%cd%
SET GST_PLUGIN_PATH=%cd%
cd..
cd..
cd bin
cd 64bit
start obs64.exe
```
It will set all required variables on the runtime, and enable GStreamer just for that OBS installation. To run OBS with GStreamer, simply double click that BAT file. You can even create a shortcut for that BAT file, set the OBS icon and put it on your desktop.
If you want to also have all scenes and profiles saved inside the OBS directory (so you can use it on external drive and move between PCs), create empty portable_mode.txt file inside OBS directory and inside BIN directory (probably only one is really required).

If you zip OBS directory and put on your USB drive or cloud storage, in theory it should work out of the box on any Windows PC.


----------



## Paul-Tahoe (Mar 6, 2021)

It seems like a few people have made this work on a Mac but none of them have really shared how exactly.  What little is out there says Macport but then doesn't really say how or what.  There is a prebuilt but then people say that doesn't work.

After much trial and mostly error.  I did finally make it work with the prebuilt.  I had to create a symbolic link from the gstream libraries to where the prebuilt thinks they are.  Probably easiest to do from a terminal window.


Download GStream and install.  https://gstreamer.freedesktop.org/download/#macos
I used 1.18.3 runtime installer.  It probably won't let you install it and you'll have to go to System Preferences => Security General tab and allow it to install.
Get the prebuilt:  https://github.com/fzwoch/obs-gstreamer/releases/tag/v0.3.0  (or whatever the latest version is) download obs-gstreamer.zip and expand
From the terminal window logged in as an administrator create directories needed for the plugin in obs (obs-gstreamer and bin)
sudo mkdir -p /Library/Application\ Support/obs-studio/plugins/obs-gstreamer/bin  
Copy obs.gstreamer.so from expanded directory in step 2.  (obs-gstreamer/macos).  If you downloaded it and expanded it in your download directory then from the terminal
sudo cp ~/Downloads/obs-gstreamer/macos/obs-gstreamer.so /Library/Application\ Support/obs-studio/plugins/obs-gstreamer/bin
Create directories and symlink from gstream libraries to where the plugin is expecting them
sudo mkdir -p /opt/local
sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/1.0/lib /opt/local/
Open OBS.  You may get a message about obs-gstreamer.so not being OK.  Cancel.  Quit OBS go to System Preferences => Security General tab and allow it.  Open OBS again.  Now you should see GStreamer Source in the sources.
Add a GStreamer Source.  Uncheck both Sync options.  Put in a pipeline.  For us using PTZOptics camera without audio (we have a separate mixer), it was this:
uridecodebin uri=rtsp://192.168.2.88/1 name=bin ! queue ! video.
Good luck.  It seems like it shouldn't this hard.  I guess is someone were to rebuild the .so with what the current GStream pkg installs into and create the directories above the .so so it can just be plopped in the pluggin directory...


----------



## avico (Mar 17, 2021)

Hi there, I'm using OBS under jetson nano, it works ok, but when I install obs-gstreamer OBS Crashed with this output,
if I remove gstreamer pluggin the problem dissapear. Any suggestion?

QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/locale.ini
Attempted path: /usr/share/obs/obs-studio/locale.ini
Attempted path: share/obs/obs-studio/locale/es-ES.ini
Attempted path: /usr/share/obs/obs-studio/locale/es-ES.ini
info: Using preferred locale 'es-ES'
Attempted path: share/obs/obs-studio/themes/Dark.qss
Attempted path: /usr/share/obs/obs-studio/themes/Dark.qss
info: Physical Cores: 4, Logical Cores: 4
info: Physical Memory: 3956MB Total, 525MB Free
info: Kernel Version: Linux 4.9.140-tegra
info: Distribution: "Ubuntu" "20.04"
info: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.9
info: Portable mode: false
Attempted path: share/obs/obs-studio/themes/Dark/no_sources.svg
Attempted path: /usr/share/obs/obs-studio/themes/Dark/no_sources.svg
QMetaObject::connectSlotsByName: No matching signal for on_advAudioProps_clicked()
QMetaObject::connectSlotsByName: No matching signal for on_advAudioProps_destroyed()
QMetaObject::connectSlotsByName: No matching signal for on_actionGridMode_triggered()
QMetaObject::connectSlotsByName: No matching signal for on_program_customContextMenuRequested(QPoint)
info: OBS 25.0.3+dfsg1-2 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
    samples per sec: 44100
    speakers:        2
info: ---------------------------------
info: Initializing OpenGL...
info: Loading up OpenGL on adapter NVIDIA Corporation NVIDIA Tegra X1 (nvgpu)/integrated
info: OpenGL loaded successfully, version 3.3.0 NVIDIA 32.3.1, shading language 3.30 NVIDIA via Cg compiler
info: ---------------------------------
info: video settings reset:
    base resolution:   1920x1080
    output resolution: 1280x720
    downscale filter:  Bicubic
    fps:               30/1
    format:            NV12
    YUV mode:          601/Partial
info: NV12 texture support not available
info: Audio monitoring device:
    name: Por defecto
    id: default
info: ---------------------------------
warning: Failed to load 'en-US' text for module: 'decklink-ouput-ui.so'
libDeckLinkAPI.so: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio
warning: A DeckLink iterator could not be created.  The DeckLink drivers may not be installed
info: No blackmagic support
info: FFMPEG VAAPI supported
info: obs-gstreamer build: 2b6aa8d
*** buffer overflow detected ***: terminated
Abortado


----------



## Tuna (Mar 18, 2021)

Could be a bug. Without a stack trace I cannot tell.


----------



## alvanfleet (Mar 23, 2021)

I still can't figure out why this isn't working for me. I'm assuming my pipeline must be incorrect as I think I've got all the other components in the right places. I'm attempting to use,

uridecodebin uri=rtsp://10.3.29.94:554/main name=bin ! queue ! video.

Admittedly, I don't really know what I'm doing. I'll answer any questions you have to help me figure this out.


----------



## BloodMan (Mar 28, 2021)

I have frame render losses when closing gstreamer sources (obs & gstreamer current  stable):
https://wetransfer.com/downloads/aa...a51390d8e23dbb094fcb9bb920210328164211/c6dc3e  (40mb.mp4)

This is un / known bug, or something that I misconfigure?


----------



## Tuna (Mar 28, 2021)

BloodMan said:


> I have frame render losses when closing gstreamer sources (obs & gstreamer current  stable):
> https://wetransfer.com/downloads/aa...a51390d8e23dbb094fcb9bb920210328164211/c6dc3e  (40mb.mp4)
> 
> This is un / known bug, or something that I misconfigure?


Speculating here. Perhaps OBS calls the stop/destroy synchronously. In your case the GStreamer will send a TEARDOWN to your RTSP server. This probably takes some time during OBS may be stalled. As check you may want to try to untick the "stop pipeline when hidden" checkbox.


----------



## BloodMan (Mar 30, 2021)

Yup, when I untick there are no drops.


----------



## Tuna (Apr 5, 2021)

Tuna updated obs-gstreamer with a new update entry:

0.3.1



> Fix leaking of the bus handle. Could have let to "too many files" error when pipeline was restarted too often.



Read the rest of this update entry...


----------



## Grackis (Apr 6, 2021)

Hello,

I have got pretty far in the setup here, I have it integrated into OBS but I am having trouble getting the Pipe line to load my cameras rtsp stream into obs. I have tried it many different ways but I always end up with a black/nothing result. Neither of these below urls are working for me via gstreamer but the rtsp link does work using  VLC or obs media. Any ideas? P.S. I have tried it with and without the quotes ""


uridecodebin uri="rtsp://USER:PASS@IP_ADDRESS/cam/realmonitor?channel=4&subtype=0&unicast=true&proto=Onvif" ! queue ! video.
rtspsrc location="rtsp://USER:PASS@IP_ADDRESS/cam/realmonitor?channel=4&subtype=0&unicast=true&proto=Onvif" latency=0 buffer-mode=auto ! rtph264depay ! h264parse ! d3d11h264dec ! video.


----------



## Tuna (Apr 6, 2021)

Could be anything really. Verify that it works with the gst-launch1.0 command first. Maybe try rtspt:// protocol which tunnels RTP over TCP. Since you hid your ip address it may be that no UDP transmission is not possible due to NAT.


----------



## Grackis (Apr 6, 2021)

Tuna said:


> Could be anything really. Verify that it works with the gst-launch1.0 command first. Maybe try rtspt:// protocol which tunnels RTP over TCP. Since you hid your ip address it may be that no UDP transmission is not possible due to NAT.



Thank you so much for the quick reply, i have tried the rtspt command as well with no luck. I am on a fully Vlanned network, however I am able to connect using the VLC or the Media Source within OBS using the...
rtsp://USER:PASSWORD@XX.XX.XX.XX/cam/realmonitor?channel=3&subtype=0&unicast=true&proto=Onvif

ok, i think you are saying use the rtspsrc command directly within the gst-launch windows through command line, not utilizing obs

The results are... "No sink-element named "(NULL)" - ommiting link
removing the "quotes" from my location gets better results...
However i notice in the below information that it has removed anything after the & symbol in my URL

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 rtsp://USERNAME:PASSWORD@IP_ADDRESS/cam/realmonitor?channel=4
Progress: (open) Retrieving server options
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Unauthorized
Additional debug info:
../gst/rtsp/gstrtspsrc.c(6652): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
Unauthorized (401)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
'subtype' is not recognized as an internal or external command,
operable program or batch file.
'unicast' is not recognized as an internal or external command,
operable program or batch file.
'proto' is not recognized as an internal or external command,
operable program or batch file.


----------



## Grackis (Apr 7, 2021)

Ok so after research on my end. The only problem I seem to be having is that Gstreamer will not allow me to input & characters into my src URL is there a way to fix this? maybe a character escape flag or something?  %26 ?


----------



## JohnPW (Apr 8, 2021)

*Video freeze and catch-up*

First thanks to others on this forum for helping me find GStreamer and to the GStreamer developer - you have provided a good low-latency solution - but I have one issue left to resolve….

Thanks to guidance here I am successfully feeding 4 IP camera RTSP streams into OBS with low latency.

My problem is that some streams, at intervals that can vary from a few seconds to many minutes, the video freezes for up to a second and then runs fast to catch up over a second or so.

The detail:-

Camera streams are H264 1080p 30fps, Iframe every second, 4Mbps over local wired network.
OBS GStreamer source pipeline is Uridecodebin uri=rtsp://streamurl name=bin ! queue ! video.
“Use pipeline timestamps” unticked
“Sync appsyncs to clock” unticked
Audio handled separately - but stable low latency needed to maintain lip sync
Win10 with i7 processor not overloaded and plenty of RAM…
Having explored the forum I’ve found many variables that might help and have tried many of them with no success.  I'd really appreciate a steer!  Thanks in anticipation!

Best wishes,  John


----------



## Tuna (Apr 9, 2021)

Sounds like network congestion to me.

Could also be some weird locking timing issue inside the pipeline.. not tellable unless deep debugging/inspection.
Could also be big I-frames from the encoder side.


----------



## JohnPW (Apr 9, 2021)

Tuna said:


> Sounds like network congestion to me.
> 
> Could also be some weird locking timing issue inside the pipeline.. not tellable unless deep debugging/inspection.
> Could also be big I-frames from the encoder side.


Many thanks for the quick reaction.  It shouldn't be network congestion - the ethernet network extends only from the PC, though a gigabit PoE router, to the 4 local cameras over Cat6 ethernet, longest run about 30m.  Allowing for the 2nd stream from each camera there should only be around 5-6MBps per camera, 30Mbps tops... The problem is visible on the OBS preview and programme screens so is on the input side.  (We are also recording at 4Mbps to SSD and streaming 1.5Mbps over a tethered mobile connection offering 20Mbps upstream but the problem is independent of whether we are recording/streaming).  Processor loading is below 10% when not streaming.....

I'll try reducing the camera iFrame frequency and see if that reduces incidence of the glitch...  Similarly I can try some temporary reductions to video resolution and bitrate to reduce iFrame size and indeed some increases, and see if that makes any difference...

Would you be able to offer a steer to any  web pages which explain how to capture logs from the pipeline?  I've found the GStreamer tutorials   but must admit I find them hard to follow!


----------



## JohnPW (Apr 17, 2021)

An update...   

Our video "Freeze and catchup"  issue was made significantly worse with camera stream rates increased form 4Mbps to 6Mbps, and significantly better with the camera stream rate reduced to 3Mbps.  Changing from 1080p to 720p and a camera stream rate of 4MBps significantly reduced or eliminated the problem.  So it does appear to be related to processing capacity or IFrame sizes or similar...  That gives us an interim solution.

We would hope to return to using 1080p with at least 4Mbps in due course so still hope to find a proper solution.  Task Manager is reporting CPU processer utilisation below 20% - but perhaps it is an occasional very short term peak capacity issue? 

Is there any possibility that defining buffer sizes or setting them to be "leaky" might help?  Any tips on how to get detailed information from GStreamer on what is happening would be welcome?


----------



## johnny_bravo (Apr 18, 2021)

Hello JohnPW, we have a very comparable setup. We use a NVidia card to off load the CPU. Here is one of our pipelines : 

rtspsrc location=rtspt://url latency=100 ! rtph264depay ! h264parse ! nvh264dec ! video.

Mind the rtspt , it means we use tcp instead of udp. Gives a lot better stability in our setup.  Please let us know if this helps you !


----------



## johnny_bravo (Apr 18, 2021)

o and by the way, to check if the camera's themselves are working ok, we use ONVIF device manager, an open source project very handsome to tackle IP camera issues. If your camera's are ONVIF compliant, this could help you to pinpoint your problem. We run about 4 camera's on a 100MB POE switch with no network problems at all, so your gigabit should be up to the job.


----------



## JohnPW (Apr 19, 2021)

Johnny_bravo - many thanks for the feedback.  We don't have a graphics card but could add one if it is going to be a solution...  We will try some variants on your pipeline and see if it helps.


----------



## fripster (Apr 19, 2021)

Tuna, you are a lifesaver! We are were using OBS with RTSP camera's under Debian via VLC stream, but Debian has taken the RTSP functionality away in the newest versions of VLC because of non-free code in the VLC plugin. This meant that RTSP was not usable anymore under Debian with OBS!
Now with your plugin we have access to RTSP again! Many, Many thanks for this!!!


----------



## jonvalt (Apr 26, 2021)

Hey man.  I just wanted to come on here (in fact I had to register an account just to post this) to THANK YOU for these step by step instructions.  I'm running OBS on an old iMac, and have been searching the frozen stream thing for awhile now with no luck.  THANK YOU AGAIN.  

Anyone reading - this absolutely works.  Modify the url to match your camera.  In my case, it was:

uridecodebin uri=rtsp://name:password@ip:554 name=bin ! queue ! video. bin. ! queue ! audio.    <---- that period is part of the command!

(If anyone is interested, look for WoodlandsSquirrelCam on Twitch.  I won't link to it because I don't want to spam.  It's just a camera aimed at a squirrel feeder - nothing fancy)



Paul-Tahoe said:


> It seems like a few people have made this work on a Mac but none of them have really shared how exactly.  What little is out there says Macport but then doesn't really say how or what.  There is a prebuilt but then people say that doesn't work.
> 
> After much trial and mostly error.  I did finally make it work with the prebuilt.  I had to create a symbolic link from the gstream libraries to where the prebuilt thinks they are.  Probably easiest to do from a terminal window.
> 
> ...


----------



## JohnPW (May 5, 2021)

johnny_bravo said:


> Hello JohnPW, we have a very comparable setup. We use a NVidia card to off load the CPU. Here is one of our pipelines :
> 
> rtspsrc location=rtspt://url latency=100 ! rtph264depay ! h264parse ! nvh264dec ! video.
> 
> Mind the rtspt , it means we use tcp instead of udp. Gives a lot better stability in our setup.  Please let us know if this helps you !


Johny Bravo many thanks for sharing your pipeline code...  Prompted by your suggestion we have changed to using a similar code which is
rtspsrc location=rtspt://_url_ latency=100 ! rtph264depay ! h264parse  ! video.
The same as yours but without the video clause as we don't have a graphics card...
As a result we have been able to return to full 1080p, with 4 IP cameras feeding at 6Mbps, recording at 1080p 4Mbps and streaming at 720p 2.5Mbps (limited by broadband network speed), all without a graphics card on an i7 processor.  This has eliminated our "freeze and catchup" video problem.  Using TCP instead of UDP for the camera feeds is a little counter-intuitive but it works!  Thank you!


----------



## johnny_bravo (May 7, 2021)

my pleasure .... I am pleased to share the knowledge I gathered from all the people helping me out .... ;-)


----------



## JohnInStockie (May 23, 2021)

Hi Guys, 

I am having trouble installing GStreamer on Windows 10, can someone please help me see what I am doing wrong?

- I have dropped the file 'obs-gstreamer.dll' in the "C:\Program Files\obs-studio\obs-plugins\64bit" folder

- I have downloaded "gstreamer-1.0-mingw-x86_64-1.18.4.msi" and this auto installed in "D:\gstreamer\1.0\mingw_x86_64\bin".  It also updated the env variables adding "GSTREAMER_1_0_ROOT_MINGW_X86_64" as "D:\gstreamer\1.0\mingw_x86_64\"

Yet when I start OBS nothing happens and the logs says this:-  
"18:27:02.121: LoadLibrary failed for '../../obs-plugins/64bit/obs-gstreamer.dll': The specified module could not be found.
18:27:02.121:  (126)
18:27:02.121: Module '../../obs-plugins/64bit/obs-gstreamer.dll' not loaded"

I cant see what I have missed, any ideas please?

Thank you


----------



## Tuna (May 23, 2021)

"D:\gstreamer\1.0\mingw_x86_64\bin" needs to be added to the PATH env variable.


----------



## JohnInStockie (May 26, 2021)

Thanks TUNA

Took my 2 goes to spot the "_... added to the *PATH *env variable ..._" lol, but spotted it AND IT WORKS *Hurrah!!*

THANK YOU VERY MUCH, this will be a game changer (I hope) :)

John


----------



## slamuraishaq (Jun 7, 2021)

hello, is there a plugin available to capture a particular window to then pipe into the rest of gstreamer? i tried using a separate instance of obs that outputs to a udp uri to then bring into a 2nd obs instance via gstreamer source but it resulted in occasional frame drops.
i'm on windows 10.

i see plugins for recording an entire screen and has capability to grab windows by id, but haven't been able to figure out how to grab window ids in windows 10.


----------



## ntoonio (Jun 10, 2021)

Hi! Thanks for this great project!

I'm having some problems with using `audio.`

I have this

```
shmsrc socket-path=/tmp/test is-live=true do-timestamp=true ! queue ! audio/x-raw,rate=48000,channels=2,format=S16LE ! audio.
```

And I'm getting the error

`Filter caps do not completely specify the output format`



Spoiler: Log with GST_DEBUG="*:3"



0:00:15.093086703 10535 0x56492dfef6a0 FIXME                default gstutils.c:3980:gst_pad_create_stream_id_internal:<shmsrc3:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:15.098204982 10535 0x56492e0329e0 WARN              capsfilter gstcapsfilter.c:453:gst_capsfilter_prepare_buf:<capsfilter11> error: Filter caps do not completely specify the output format
0:00:15.098267305 10535 0x56492e0329e0 WARN              capsfilter gstcapsfilter.c:453:gst_capsfilter_prepare_buf:<capsfilter11> error: Output caps are unfixed: audio/x-raw, rate=(int)48000, format=(string)S16LE, channels=(int)2, layout=(string){ interleaved, non-interleaved }
0:00:15.098379089 10535 0x56492e0329e0 WARN           basetransform gstbasetransform.c:2167:default_generate_output:<capsfilter11> could not get buffer from pool: error
error: Filter caps do not completely specify the output format



Although I can hear it when I change `audio.` to `autoaudiosink`. Then it's going though my speakers but not into OBS.

I'm guessing I have to add some field to the caps filter, but I can't figure out what that would be...


----------



## Tuna (Jun 11, 2021)

Instead of a caps filter I would try to use "rawaudioparse" element.

But probably it wants to know whether the data is interleaved of not.


----------



## Noraa (Jun 25, 2021)

Can anyone help me with building a Windows 32-bit version of this plugin? To make a very long story short, I have to use the 32-bit version of OBS for my current workflow. Obviously, the prebuilt 64-bit version won’t work for me :/

Any help would be greatly appreciated!


----------



## momentumv (Jun 26, 2021)

Hi everyone, very helpful forum. I have a PTZoptics camera. My main injest into OBS is through an HDMI capture card, which is great, but I would like to add some other network video sources, and I'm testing out gstreamer with what I have.
SO FAR: I've installed the win10 minGW gstreamer added to path, and put the precompiled dll into the OBS plugin folder.
This gives me a gstreamer source option, and the default video source seems to work fine.
I've been able to run:

```
C:\gstreamer\1.0\mingw_x86_64\bin>gst-play-1.0 rtsp://192.168.1.65/1
Press 'k' to see a list of keyboard shortcuts.
Now playing rtsp://192.168.1.65/1
Pipeline is live.
Redistribute latency...
Redistribute latency...
Redistribute latency...
Prerolled.
```
which displays the feed in a Direct3D11 render window (with quite bad (~1s) latency).
However, if I try to use this pipeline (or lots of others) in the OBS source:
`uridecodebin uri=rtsp://192.168.1.65/1 name=bin ! queue ! video.`
OBS crashes after ~1 sec of windows busy cursor, and will crash on open until I remove obs-gstreamer.dll from the plugins folder. 
My OBS log file doesn't give any clues.
I'm just not sure what I'm doing wrong...


----------



## Tuna (Jun 27, 2021)

momentumv said:


> Hi everyone, very helpful forum. I have a PTZoptics camera. My main injest into OBS is through an HDMI capture card, which is great, but I would like to add some other network video sources, and I'm testing out gstreamer with what I have.
> SO FAR: I've installed the win10 minGW gstreamer added to path, and put the precompiled dll into the OBS plugin folder.
> This gives me a gstreamer source option, and the default video source seems to work fine.
> I've been able to run:
> ...


Most likely the camera is not reachable via UDP at that time? Current release blocks at the first connection step, possible that this blocks all other OBS functionality in the meantime. On the latest development version this step is tried to move to another thread where this may improve on the issue.


----------



## momentumv (Jun 28, 2021)

Thank you for the reply, but I don't understand why would the gst-play work still, if the UDP is not working?
Anyway, using portqryui.exe, I get the following:  

```
=============================================

 Starting portqry.exe -n 192.168.1.65 -e 1259 -p UDP ...


Querying target system called:

 192.168.1.65

Attempting to resolve IP address to a name...

Failed to resolve IP address to name

querying...

UDP port 1259 (unknown service): LISTENING or FILTERED
portqry.exe -n 192.168.1.65 -e 1259 -p UDP exits with return code 0x00000002.
```


----------



## Tuna (Jun 28, 2021)

Don't know for sure, maybe gst-play can revert to fallback transmission like tcp. You could force TCP by using "rtspt://" protocol for uridecodebin for example. Then again you are on a local network. I really have no conclusive idea..


----------



## momentumv (Jun 29, 2021)

Do you have any ideas for generating/testing a "known good" rtsp on my network to test against? Should I attempt to compile the binary for my self? 
Any ideas about logs/crash dumps that could be helpful? I'd love to get this to work.


----------



## Tuna (Jun 29, 2021)

momentumv said:


> Do you have any ideas for generating/testing a "known good" rtsp on my network to test against? Should I attempt to compile the binary for my self?
> Any ideas about logs/crash dumps that could be helpful? I'd love to get this to work.


As of writing the RTSP example in the README is working for me.


----------



## momentumv (Jun 30, 2021)

On Win10? I'm getting the exact same crashing behavior with the example as with my local network source.
specifically: `uridecodebin uri=rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov name=bin ! queue ! video. bin. ! queue ! audio.`


----------



## Tuna (Jun 30, 2021)

Yes, no problem. All I had to do was to confirm the firewall to allow OBS to have network access. You may have to debug this yourself to examine whats happening. See https://gstreamer.freedesktop.org/documentation/gstreamer/running.html?gi-language=c for some starters.. in worst case you need to debug the plugin itself. Always possible you hit a bug.


----------



## momentumv (Jun 30, 2021)

Well, I did a test install on another machine and it works fine. :/ Wonder if it has something to do with nvenc or something. Will do more experimenting on the target machine (including a re-install) and see if I end up with a working system.


----------



## momentumv (Jul 4, 2021)

after complete reinstallation etc, I kept having the same crashing problem with rtsp. This machine is due for a motherboard replacement anyway, so I think I'll just give up until it's a different machine...


----------



## Tuna (Jul 15, 2021)

Tuna updated obs-gstreamer with a new update entry:

0.3.2



> added option to toggle async behavior of sinks
> make start of pipeline asynchronous so it does not block OBS in case the resource is not available



Read the rest of this update entry...


----------



## NeedToMow-NeedToPi (Jul 19, 2021)

Hi

I am using this plugin and it seems to do great - BUT, i cannot make it work with sound. Normal VLC source/Media source is working fine.

Working is:
uridecodebin uri=rtsp://192.168.xxxxx name=bin ! queue ! video.

Not working:
uridecodebin uri=rtsp://192.168.xxxxx name=bin ! queue ! video. bin. ! queue ! audio.

I feel like i have tried all kinds of combinations, can anyone point me in the right direction? :) The source is a Unifi Camera through the NVR.


----------



## dd_obs21 (Aug 11, 2021)

I build OBS from source on RPi 4B. I copied the obs-gstreamer.so file to /usr/lib/obs-plugins. But am getting this error, any idea?


----------



## Tuna (Aug 11, 2021)

You seem to try to load a 64 bit module on a 32 bit os or vice versa.


----------



## superdiy (Nov 20, 2021)

Grackis said:


> Ok so after research on my end. The only problem I seem to be having is that Gstreamer will not allow me to input & characters into my src URL is there a way to fix this? maybe a character escape flag or something?  %26 ?



I also have a dahua camera with similar issues.  I 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


----------



## bobbytj (Nov 25, 2021)

Hi @Tuna , all, 
I'm new with OBS and obs-gstreamer too ;-) I wonder if someone faces the same issues trying to run the (to my knowledge) most recent versions of OBS (27.1.3) and obs-gstreamer (v0.3.2).

Even though I think I did everything correctly trying to intall the obs-gstreamer plugin GStreamer does not show up in the source selection area of OBS. I'v attached the OBS logfile which indicates that obs-gstreamer.dll has NOT been loaded. 
Has anything changed in the OBS API so that obs-gstreamer.dll doesn't get loaded by OBS? Can someone point me to how to get the obs-gsteamer to work?

Facts:
- Win10 64bit
- OBS Studio 64bit 27.1.3 (up and running w/o issues) 
- GStreamer runtime - mingw_x86_64 (up and running w/o issues)
- obs-gstreamer - prebuilt v0.3.2 (tried also with v0.3.1, v0.3.0)

Thanks a lot!

09:06:05.170: CPU Name: Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
09:06:05.170: CPU Speed: 2594MHz
09:06:05.170: Physical Cores: 2, Logical Cores: 4
09:06:05.170: Physical Memory: 16314MB Total, 11423MB Free
09:06:05.170: Windows Version: 10.0 Build 19042 (release: 2009; revision: 1348; 64-bit)
09:06:05.170: Running as administrator: false
09:06:05.170: Aero is Enabled (Aero is always on for windows 8 and above)
09:06:05.170: Windows 10 Gaming Features:
09:06:05.170:     Game DVR: On
09:06:05.173: Sec. Software Status:
09:06:05.174:     Microsoft Defender Antivirus: enabled (AV)
09:06:05.175:     Windows-Firewall: enabled (FW)
09:06:05.176: Current Date/Time: 2021-11-25, 09:06:05
09:06:05.176: Browser Hardware Acceleration: true
09:06:05.176: Portable mode: false
09:06:05.929: OBS 27.1.3 (64-bit, windows)
09:06:05.929: ---------------------------------
09:06:06.042: ---------------------------------
09:06:06.042: audio settings reset:
09:06:06.042:     samples per sec: 48000
09:06:06.042:     speakers:        2
09:06:06.043: ---------------------------------
09:06:06.044: Initializing D3D11...
09:06:06.044: Available Video Adapters: 
09:06:06.056:     Adapter 0: NVIDIA GeForce GTX 850M
09:06:06.056:       Dedicated VRAM: 4252762112
09:06:06.056:       Shared VRAM:    4258344960
09:06:06.056:       PCI ID:         10de:1391
09:06:06.057:       Driver Version: 30.0.14.7196
09:06:06.057:       output 0: pos={0, 0}, size={1920, 1080}, attached=true, refresh=60, name=
09:06:06.057:       output 1: pos={0, -1080}, size={1920, 1080}, attached=true, refresh=59, name=Medion HDMI
09:06:06.057:     Adapter 1: Intel(R) HD Graphics Family
09:06:06.057:       Dedicated VRAM: 117964800
09:06:06.057:       Shared VRAM:    2147483648
09:06:06.057:       PCI ID:         8086:a16
09:06:06.059:       Driver Version: 20.19.15.4835
09:06:06.072: Loading up D3D11 on adapter NVIDIA GeForce GTX 850M (0)
09:06:06.175: D3D11 loaded successfully, feature level used: b000
09:06:06.175: DXGI increase maximum frame latency success
09:06:06.175: D3D11 GPU priority setup failed (not admin?)
09:06:06.793: ---------------------------------
09:06:06.793: video settings reset:
09:06:06.793:     base resolution:   1920x1080
09:06:06.793:     output resolution: 1280x720
09:06:06.793:     downscale filter:  Bicubic
09:06:06.793:     fps:               30/1
09:06:06.793:     format:            NV12
09:06:06.793:     YUV mode:          709/Partial
09:06:06.793: NV12 texture support enabled
09:06:06.795: Audio monitoring device:
09:06:06.795:     name: Standard
09:06:06.795:     id: default
09:06:06.796: ---------------------------------
09:06:06.796: Skipping module '../../obs-plugins/64bit/chrome_elf.dll', not an OBS plugin
09:06:06.805: [CoreAudio encoder]: CoreAudio AAC encoder not installed on the system or couldn't be loaded
09:06:06.806: Failed to load 'en-US' text for module: 'decklink-captions.dll'
09:06:06.807: Failed to load 'en-US' text for module: 'decklink-ouput-ui.dll'
09:06:06.907: [AMF] Unable to load 'amfrt64.dll', error code 126.
09:06:06.910: [AMF] AMF Test failed due to one or more errors.
09:06:06.910: Failed to initialize module 'enc-amf.dll'
09:06:06.920: Skipping module '../../obs-plugins/64bit/libcef.dll', not an OBS plugin
09:06:06.928: Skipping module '../../obs-plugins/64bit/libEGL.dll', not an OBS plugin
09:06:06.928: Skipping module '../../obs-plugins/64bit/libGLESv2.dll', not an OBS plugin
09:06:06.935: [obs-browser]: Version 2.16.3
09:06:06.935: [obs-browser]: CEF Version 75.1.16+g16a67c4+chromium-75.0.3770.100
09:06:06.940: NVENC supported
09:06:06.942: [noise suppress]: NVIDIA RTX denoiser disabled, redistributable not found
09:06:06.967: Module '../../obs-plugins/64bit/obs-gstreamer.dll' not loaded


----------



## Tuna (Nov 25, 2021)

bobbytj said:


> 09:06:06.967: Module '../../obs-plugins/64bit/obs-gstreamer.dll' not loaded



Has the GStreamer runtime "bin" directory added to the Windows PATH variable? E.g. can you run `gst-inspect-1.0` from any directory?


----------



## bobbytj (Nov 25, 2021)

Tuna said:


> Has the GStreamer runtime "bin" directory added to the Windows PATH variable? E.g. can you run `gst-inspect-1.0` from any directory?


Yes - Gstreamer bin is in the system PATH and all contained binaries can be run from any “place” from within the cmd shell. Any ideas what could be the issue?


----------



## Tuna (Dec 6, 2021)

Tuna updated obs-gstreamer with a new update entry:

0.3.3



> encoder: fixed a bug that would result in the bit rate to be completely off target
> output: added experimental output plugin. [no GUI]
> source: added blocking options for sink behavior



Read the rest of this update entry...


----------



## Shween (Dec 29, 2021)

Hello Everybody.

Hope all is well!

I am not new to OBS, and I am definitely not a complete novice when it comes to "complex" features, but this Gstreamer protocol has my mind and soul completely destroyed.

I was sent here because I heard this was the end-all to get the lowest latency RTSP Signal from an IP Security Camera or the like.

I literally know nothing about this protocol, or how "pipelines" are supposed to be compiled or tested, and I cannot find any documentation on it that I can actually understand.

All I want to do is use this IP camera and get the best possible latency.

I have tried almost every pipline combination could find in this, and select few other forums.

I also use a Dahua Variant camera, with the rtsp link of:  rt_sp://admin:<password>@<ipaddress>:554/cam/realmonitor?channel=1&subtype=0_ 

I just see a black screen, and have no idea to know where it is breaking!

It seems I have installed the Runtime correctly for the plugin shows in OBS, and although I still know nothing on how that technically works, apparently the 1 YouTube Video I followed at least got me to that point. ->This Video Here<-

May an angel please help save my soul! I am officially stumped. 

xD Thank you all.


----------



## Tuna (Dec 29, 2021)

You don't write anything about what you are actually doing. The README of the plugin's project even has an example for RTSP cameras. This plugin is not fire and forget. For the correct results you will need to dive into the GStreamer documentation and the features of the elements you are going to use sooner or later. Especially when it comes to "minimal latency" and what impact it has on potential jitter etc pp.


----------



## Shween (Dec 30, 2021)

Tuna Thank you for your reply!
In full Honesty, I had been up many hours straight just copying and pasting and modifying the code that I found on the plugin page, within this forum, and a few other forums as well.

Gonna be doing some heavy research tonight. I am seeing that people are getting good results. I am quite interested in this concept.

I hope to maintain etiquette here, I beg mercy!

As I try to understand this framework, I will try and document my findings as well. 

And a Bump for Love!

Cheers!


----------



## Shween (Dec 30, 2021)

Okay So As much as I have dug around. I am going to start from my starting point.

This is my current OBS Pipeline String template taken Straight from ReadMe.md

```
rtspsrc location=rtspt://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! rtph265depay ! nvdec ! gldownload ! watchdog timeout=10000 ! video. bin. ! queue ! rtpmpadepay ! mpegaudioparse ! mpg123audiodec ! audio.
```


This My cameras Source RTSP ID [*Dahua RTSP]*: 

```
rtsp:// [USER] : [PASS] @ [ADDRESS] : [RTSP PORT] /cam/realmonitor?channel= [CH] &subtype=[STREAM TYPE]
```


RTSP URL that works in MediaSource and VLC Source

```
rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0
```


Also attached as an image are my IP cameras output settings.








And Port Settings





I am able to view the RTSP stream link Thru VLC and Mediasource just fine (with wild latency of course).

I am also able to input all of the other ReadMe.md examples into the pipeline string entry, and they all work!

I am getting absolute no video feed from. What could I try?


----------



## Shween (Dec 30, 2021)

Again Not to Spam: But I installed Gstreamer in Windows 10 according to *This Demonstration* <-Video Link

Also Another update: Does this error mean anything to you?

```
ERROR: from element /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Unauthorized
```



This is the current pipeline:

```
uridecodebin uri=rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.
```



Full Debug String

```
C:\Users\OMW>gst-launch-1.0 uridecodebin uri=rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.
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 rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1
Progress: (open) Retrieving server options
ERROR: from element /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Unauthorized
Additional debug info:
../gst/rtsp/gstrtspsrc.c(6658): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source:
Unauthorized (401)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
'subtype' is not recognized as an internal or external command,
operable program or batch file.
```


----------



## Shween (Dec 30, 2021)

Haha again not to Spam, I thought it was Dahua, but the Camera is an Amcrest IP Security Camera?

Is it possible it is not compatible?


----------



## Shween (Dec 30, 2021)

GAHHH Now I think I really broke something.....

This is the latest in errors:
ERROR: pipeline could not be constructed: no element "C:".

I accidentally click on a default application after I ran a command at one point. And now it seems Gstreamer cannot initialize in Command Line.

I have reinstalled Gstreamer as well. 

Oh Man..... Should I quit now?


----------



## Shween (Dec 30, 2021)

Goodness Me...... So I have figured out a 'Workaround'

it seems i must now put ".exe" after the launch command

so instead of:
*gst-launch-1.0*

I use:
*gst-launch-1.0.exe*

and it begins to 'work' again

now this is my error string:

```
gst-launch-1.0.exe uridecodebin uri=rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.
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 rtsp://admin:Look@Me!@192.168.1.108:554/cam/realmonitor?channel=1
Progress: (open) Retrieving server options
ERROR: from element /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source: Unauthorized
Additional debug info:
../gst/rtsp/gstrtspsrc.c(6658): gst_rtspsrc_send (): /GstPipeline:pipeline0/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source:
Unauthorized (401)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
'subtype' is not recognized as an internal or external command,
operable program or batch file.
```

sorry for all the 'updates'

im really pulling my hair out here. One issue has created many. I hope this is all still able to be interpreted :-/


----------



## Shween (Dec 30, 2021)

Whoa Whoa Whao Okay Guys. Hold the Phone:

Could this be a bug or omission of feature in Gstreamer???

This rtsp link cannot be parsed it seems due to the Ampersand "&"  in the URL

Supposedly, %26 should do the trick officially.

Check out this Image from another Forum




Perhaps as a "Security Camera" this Rtsp link containing an '&' is made to avoid possible exploits?
Confirm?
Deny?
Paradox?


----------



## Shween (Dec 30, 2021)

superdiy said:


> I also have a dahua camera with similar issues.  I 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:*
> ...




Hey @superdiy, I'm hoping finding the solution to this will begin to fix many problems!


----------



## Shween (Jan 1, 2022)

[SOLVED?]

Happy New Year All!

First, after a few days of absolute mind racking, I need to say, You all here are an endlessly brilliant group!

So, after futting around trying to mess with a camera on my laptop to test compatibility, I decided to just move onto the main rig.

Installed GStreamer, and set up the Environment Paths as Previous.

Installed OBS Plugin dll.

Hey @superdiy;
And for the Dahua Cams, I picked it up after re-re-re-re-re-re-reading This Post by @camfix HERE to use **+** in the place of an ampersand"&" in my pipeline.

It Worked!

Then I tried it with the Ampersand again.....

IT WORKED!?

This is now my code:

```
rtspsrc location=rtspt://admin:password@192.168.1.107:554/cam/realmonitor?channel=1&subtype=0 latency=0 ! rtpjitterbuffer latency=10 ! rtph264depay ! h264parse ! nvh264dec ! queue ! video.
```

Like I said, this is working remarkably well!

I am not exactly sure what this pipeline is commanding other than a basic understanding, so i was wondering if someone might be so kind as to explain the flow of this pipeline (I will also be referencing the API)

Also, what other parameters could I add to this pipeline to make it more efficient, and also bring in the audio from the camera source.

You are a remarkably brilliant group of people, and a wicked shout-out to @Tuna for this plugin. 

This is truly a revolutionary advancement for the platform. Nothing but praise!

I would be interested to know what you make of this? o.O


----------



## Tuna (Jan 1, 2022)

Happy New Year. Sounds plausible you had to escape the ampersand somehow.

For specific options you should refer to the GStreamer documentation. Alternatively you can check available options for each element with the gst-inspect tool - e.g. "gst-inspect-1.0 rtspsrc".

Iirc the rtspsrc already has a jitterbuffer internally, so may not reuire an additional one.

For adding the audio I recommend looking at the examples again and read https://gstreamer.freedesktop.org/d...aunch.html?gi-language=c#pipeline-description - then you hopefully have an idea what these pipeline desciptions do and how to craft them. It it basically connecting another path fropm the rtspsrc to the the audio destination.


----------



## superdiy (Jan 11, 2022)

Shween said:


> Hey @superdiy;
> And for the Dahua Cams, I picked it up after re-re-re-re-re-re-reading This Post by @camfix HERE to use **+** in the place of an ampersand"&" in my pipeline.
> 
> It Worked!
> ...



Thank you @Shween 

I've managed to get the "gst-launch-1.0" command to work by using the "**+**" instead of the "&" in the pipelines.  Somebody also said in another thread that "video." should be replaced by "fakevideosink" (without the "." at the end) when the pipeline is used with "gst-launch-1.0". 

Seems like the "&" does not have to be replaced in the pipeline in @Tuna's gstreamer plugin in OBS though - pipelines work successfully with "&" in gstreamer plugin in OBS.

I finally managed to get my "rtspsrc " pipelines working in OBS after replacing "nvh264dec" with "avdec_h264" - I know too little to know why.

I've also tried "d3d11h264dec" as a decoder, but without any luck - what still boggles my mind is that:

d3d11h264dec - works with gst-launch-1.0, but does not work with the gstreamer plugin in OBS
nvh264dec - neither works with gst-launch-1.0 nor with the gstreamer plugin in OBS
I also thought that if something works successfully with gst-launch-1.0, it _will_ work in OBS, but that seems to be a flawed assumption. 

Finally all of the following pipelines work on my setup:

uridecodebin uri=rtspt://<user>:<password>@192.168.0.108/cam/realmonitor?channel=1&subtype=0 name=bin ! queue ! video.
rtspsrc location=rtspt://<user>:<password>@192.168.0.108/cam/realmonitor?channel=1&subtype=0 latency=100 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! video.
rtspsrc location=rtspt://<user>:<password>@192.168.0.108/cam/realmonitor?channel=1&subtype=0 latency=0 ! rtpjitterbuffer latency=10 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! video.
BUT, I also found that if you want any latency option to have an effect (on video), you have to ensure that "Sync to clock (video)" is checked, otherwise the latency values are ignored - don't know if somebody else can confirm this perhaps?

Thank you for all the help up until now.


----------



## adamchapin (Jan 23, 2022)

Hi, wondering if there is a zero latency version of the uridecodebin like there is for the rtspsrc? I tried putting in latency=0 and it didn't work. Examples below. 

uridecodebin uri="rtsp://USER:PASS@IP_ADDRESS/cam/realmonitor?channel=4&subtype=0&unicast=true&proto=Onvif" ! queue ! video.

rtspsrc location="rtsp://USER:PASS@IP_ADDRESS/cam/realmonitor?channel=4&subtype=0&unicast=true&proto=Onvif" latency=0 buffer-mode=auto ! rtph264depay ! h264parse ! d3d11h264dec ! video. 

Thanks


----------



## SCREAMING_SNAKE_CASE (Feb 19, 2022)

I'm having issues running frei0r plugins on Windows. GStreamer itself works fine - I have it in my PATH, it runs, I'm able to construct pipelines and they are working as intended etc. But when trying to use frei0r-filter-hqdn3d anywhere in the pipeline, I get this error in the log:
`Cannot start GStreamer: no element "frei0r-filter-hqdn3d"`

So clearly gstreamer doesn't seem to see this filter, although the libgstfrei0r.dll is properly installed along with everything else, and physically present in my `c:\gstreamer\1.0\mingw_x86_64\lib\gstreamer-1.0\`. I'm also 100% sure the rest of gstreamer is running absolutely fine, only frei0r plugins aren't working.

Reading this page and this one, I only have two ideas:

I have the MinGW x86-64 version (as required by obs-gstreamer) and installation instructions are specific to the paths from the MSVC one. I've tried different environment variables mentioned in the manual to point gstreamer to the plugins directory just in case some paths are hardcoded, all to no avail.
frei0r filters are part of GStreamer's `plugins-bad` set. Could it be they have some dependencies on Windows that aren't mentioned in the manual? Maybe something related to MinGW in particular?
Any other ideas?


----------



## TVEngineer (Feb 26, 2022)

I am using a PTZoptics camera in RTSP mode using the example pipeline for video all works as expected. The camera also has audio input to the camera that is muxd into the rtsp stream as AAC at 128kbps. I need an audio pipeline that will work with the example video pipeline for this AAC audio stream. Any usable combination that actually works would be greatly appreciated.


----------



## Tuna (Feb 26, 2022)

TVEngineer said:


> I am using a PTZoptics camera in RTSP mode using the example pipeline for video all works as expected. The camera also has audio input to the camera that is muxd into the rtsp stream as AAC at 128kbps. I need an audio pipeline that will work with the example video pipeline for this AAC audio stream. Any usable combination that actually works would be greatly appreciated.


The README has examples that decodes audio and video, no?


----------



## TVEngineer (Feb 26, 2022)

using decodebin to try to find the correct pipeline.
gst-launch-1.0 rtspsrc location=rtsp://192.168.111.16:554/1 latency=0 name=src src. ! decodebin ! videoconvert ! autovideosink src. ! decodebin ! audioconvert ! autoaudiosink
says Missing element: MPEG-4 AAC decoder
Failed to load plugin 'C:\gstreamer\1.0\mingw_x86_64\lib\gstreamer-1.0\libgstassrender.dll'
Failed to load plugin 'C:\gstreamer\1.0\mingw_x86_64\lib\gstreamer-1.0\libgstwavpack.dll'

gst-launch-1.0 rtspsrc location=rtsp://192.168.111.16:554/1 latency=0 name=src src. ! decodebin ! videoconvert ! autovideosink
works fine for the video
Internet searches show that many others have had difficulty trying to find a working MPEG-4 AAC decoder.
Any suggestions how to correct the gstreamer installation or the pipeline? or does gstreamer not support AAC audio?


----------



## Tuna (Feb 26, 2022)

GStreamer uses FFMPEG for AAC decoding iirc (most common decoder at least). If the FFMPEG is compiled without AAC support (most likely licensing reasons) it cannot be found.


----------



## wa2flq (Mar 9, 2022)

I am using a PTZoptics Camera as well.  For a a while I was chasing audio distortion (sample rate or decode bug?) in OBS.    I decided to refresh my entire software set. We only use OBS to record and stream with Zoom.  Platform is Windows 10 Pro with a  NVIDIA Quadro K2200.
This works:

GStreamer 1.18.5 - Complete Installation
ffmpeg  N-105871-ge645a1ddb9-20220307
obs-gstreamer v0.3.3
OBS 27.2.3

Gstreamer Source - uridecodebin  uri="rtsp://admin:admin@10.1.10.215:554/1"  name=bin ! queue ! video. bin. ! queue   !  audio.  (or rtspt)
No options selected.

Notes:
We tried to use the Media Source in OBS at first.  The latency drifted and we also had problems keeping the audio and video synchronized.
Still trying to understand  Properties for the Gstreamer source and what they actually do (or not).
Next step is to look into element settings that affect latency.
So many knobs, still on the learning curve


----------



## cr0ybot (Mar 25, 2022)

I attempted to use the pipeline below as I try to display video & audio from MonaServer:


```
playbin uri=srt://127.0.0.1:1234 latency=50000000 audio-sink=audio video-sink=video
```


But I'm getting this error:


```
Cannot start GStreamer: could not set property "audio-sink" in element "playbin1" to "audio"
```


I've been able to successfully display audio/video via the below pipeline, but _uridecodebin _doesn't appear to have any latency settings (I am very new to gstreamer so I'm probably wrong about that). I'm getting about 3 seconds of delay, but with another camera using RTSP I've been able to reduce the delay to roughly 1 second.


```
uridecodebin uri="srt://127.0.0.1:1234" name=bin ! queue ! video. bin. ! queue ! audio.
```


I found this blog post which purports to have solved their latency issues using SRT with the first pipeline above, but if I don't specify audio/video sinks then a Direct3D window is opened with the stream instead of passing the sinks to OBS.






						Low-latency video streaming with OBS - Bat & Octopus Software
					

I recently had a need to stream multiple consumer video sources (e.g. USB-connected webcams) over the internet with some interesting conditions. Jump down to the last section if you want an overview of the final solution. A modest proposal The video sources and any  audio sources need to be in...




					batoct.com


----------



## Tuna (Mar 26, 2022)

Use srtsrc directly. Something like:


```
srtsrc ! decodebin name=bin ! queue ! video. bin. ! queue ! audio.
```


----------



## NotKnownPerson (Apr 8, 2022)

OK, I'm stuck. My camera source just disappeared randomly last week. (Windows 10) Logs show error: [Cannot start GStreamer: no element "videoconvert"]. Haven't figured it out, paths are good, reinstalled GStreamer, Reinstall plugin, reset camera, nothing. I've spent 20+ hours on this, downgraded things, everything that wasn't reinstalling windows. Fresh OBS with fresh GStreamer install shows same error. I don't get it.

We decided to get a new mac to upgrade our old failing Windows 10 system. All is well, except my OBS M1 build won't accept the prebuilt x86_64 obs-gstreamer build, and I can't figure out how to build an M1-native build. I have meson installed, GStreamer installed via macports, and... It throws an error.

Run-time dependency *libobs* found: *NO* (tried pkgconfig, framework and cmake)
meson.build:25:2: *ERROR:* C header 'obs/obs.h' not found

I have no clue where I'm supposed to find this dependency. Do I have to compile this on a machine with a full OBS build enviroment, or am I doing something wrong? (Like blindly compiling ARM builds of x86_64 plugins or something... )

I really want the speed benefits of running native arm OBS, it's literally the difference between 1080p30 and 4K60 on our system.

EDIT: installed CMake through MacPorts. New error!



Spoiler: Terminal Output



Found CMake: */opt/local/bin/cmake* (3.22.3)
Traceback (most recent call last):
  File "mesonbuild/mesonmain.py", line 151, in run
  File "mesonbuild/msetup.py", line 301, in run
  File "mesonbuild/msetup.py", line 185, in generate
  File "mesonbuild/msetup.py", line 229, in _generate
  File "mesonbuild/interpreter/interpreter.py", line 2698, in run
  File "mesonbuild/interpreterbase/interpreterbase.py", line 149, in run
  File "mesonbuild/interpreterbase/interpreterbase.py", line 174, in evaluate_codeblock
  File "mesonbuild/interpreterbase/interpreterbase.py", line 167, in evaluate_codeblock
  File "mesonbuild/interpreterbase/interpreterbase.py", line 182, in evaluate_statement
  File "mesonbuild/interpreterbase/interpreterbase.py", line 567, in assignment
  File "mesonbuild/interpreterbase/interpreterbase.py", line 180, in evaluate_statement
  File "mesonbuild/interpreterbase/interpreterbase.py", line 455, in function_call
  File "mesonbuild/interpreterbase/decorators.py", line 768, in wrapped
  File "mesonbuild/interpreterbase/decorators.py", line 768, in wrapped
  File "mesonbuild/interpreterbase/decorators.py", line 768, in wrapped
  [Previous line repeated 5 more times]
  File "mesonbuild/interpreterbase/decorators.py", line 109, in wrapped
  File "mesonbuild/interpreterbase/decorators.py", line 127, in wrapped
  File "mesonbuild/interpreterbase/decorators.py", line 277, in wrapper
  File "mesonbuild/interpreter/interpreter.py", line 1620, in func_dependency
  File "mesonbuild/interpreter/dependencyfallbacks.py", line 352, in lookup
  File "mesonbuild/interpreter/dependencyfallbacks.py", line 93, in _do_dependency
  File "mesonbuild/dependencies/detect.py", line 112, in find_external_dependency
  File "mesonbuild/dependencies/cmake.py", line 135, in __init__
  File "mesonbuild/dependencies/cmake.py", line 183, in _get_cmake_info
  File "mesonbuild/dependencies/cmake.py", line 614, in _call_cmake
  File "mesonbuild/dependencies/cmake.py", line 585, in _setup_cmake_dir
  File "importlib/resources.py", line 168, in read_text
  File "importlib/resources.py", line 47, in _get_package
  File "importlib/__init__.py", line 127, in import_module
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'mesonbuild.dependencies.data'
meson.build:23:0: *ERROR:* Unhandled python exception
    This is a Meson bug and should be reported!


Now I'm just confused. Is there somewhere else I should have gotten CMake?


----------



## Tuna (Apr 8, 2022)

NotKnownPerson said:


> Do I have to compile this on a machine with a full OBS build enviroment,


Yes, you will need libobs header and library. Maybe you can get them from brew. I don't know.


----------



## h3y6P (Jun 8, 2022)

Got gstreamer and the plugin loaded up in OBS but having trouble with viewing and hearing my PTZ cam once the new source is added

My purpose for moving over to gstreamer in OBS is to minimize the delay/lag that I'm experiencing when using VLC cam links 

I'm adding following into the pipeline dialouge when adding a new "GStreamer Source" :


_rtspsrc location="rtsp://192.168.185.139:8554/hevc" latency=120 name=src src. ! decodebin ! videoconvert ! video. src. ! decodebin ! audioconvert ! audio._

I've confirmed this is indeed my PTZ camera's address

Am I missing any commands?


----------



## h3y6P (Jun 8, 2022)

h3y6P said:


> Got gstreamer and the plugin loaded up in OBS but having trouble with viewing and hearing my PTZ cam once the new source is added
> 
> My purpose for moving over to gstreamer in OBS is to minimize the delay/lag that I'm experiencing when using VLC cam links
> 
> ...


Some more details stream is h265 and the audio is AAC


----------



## Tuna (Jun 8, 2022)

h3y6P said:


> Some more details stream is h265 and the audio is AAC


Do you have a working launch command that works from the command line? Is that behind NAT? If so maybe try rtspt:// as protocol.


----------



## DGal (Jun 17, 2022)

I have tested this plugin as per instruction here, but after setting the source, OBS crash as soon as the source is deleted.


----------



## h3y6P (Jun 22, 2022)

Tuna said:


> Do you have a working launch command that works from the command line? Is that behind NAT? If so maybe try rtspt:// as protocol.



My pipe line is now working great for video with unnoticeable delay. But I'm having trouble figuring out how to get audio in my pipeline.

Any help would be appreciated I'm a little overwhelmed.

Here's my current pipeline


rtspsrc location="rtsp://192.168.xxx.xxx:8557/h264" latency=0 buffer-mode=auto ! rtph264depay ! h264parse ! d3d11h264dec ! video.

My options are AAC or G.711 as for audio


----------



## Tuna (Jul 22, 2022)

Tuna updated obs-gstreamer with a new update entry:

0.3.4



> encoder: fix a crash when output scaling is enabled
> source: support some 10/12 bit input formats (when compiled with GStreamer/OBS headers that support it)
> source: default value for using timestamps has changed to true
> macOS is compiled with .so suffix instead of renaming it
> GStreamer runtime version has been added to the log



Read the rest of this update entry...


----------



## boblinux12 (Jul 27, 2022)

Anyone knows how to install and configure v0.3.4 of obs-gstreamer.so plugin for MacOS?
I have made great progress at 90-95% completed , the outstanding issue the GStream Source is not visible in OBS Source List.
I have $PATH included for /Library/Frameworks/GStreamer.framework/Versions/1.0/bin
Is there anything else I need to configure or check or other?
Confirmed the gst-inspect-1.0 is workable and good via Terminal.
Using this reference how-to guide. https://obsproject.com/forum/threads/obs-gstreamer.88517/post-515437
The GStreamer is located at /usr/local whereas the reference guide shows make symlink to /opt/local ? 
I've tried both locations perhaps I didn't do this right?

Here are the steps for MacOS obs-gstramer.so plugin.

Download GStream and install.  https://gstreamer.freedesktop.org/download/#macos
I used 1.18.3 runtime installer.  It probably won't let you install it and you'll have to go to System Preferences => Security General tab and allow it to install.
Get the prebuilt:  https://github.com/fzwoch/obs-gstreamer/releases/tag/v0.3.0  (or whatever the latest version is) download obs-gstreamer.zip and expand
From the terminal window logged in as an administrator create directories needed for the plugin in obs (obs-gstreamer and bin)
sudo mkdir -p /Library/Application\ Support/obs-studio/plugins/obs-gstreamer/bin
Copy obs.gstreamer.so from expanded directory in step 2.  (obs-gstreamer/macos).  If you downloaded it and expanded it in your download directory then from the terminal
sudo cp ~/Downloads/obs-gstreamer/macos/obs-gstreamer.so /Library/Application\ Support/obs-studio/plugins/obs-gstreamer/bin
Create directories and symlink from gstream libraries to where the plugin is expecting them
sudo mkdir -p /opt/local
sudo ln -s /Library/Frameworks/GStreamer.framework/Versions/1.0/lib /opt/local/
Open OBS.  You may get a message about obs-gstreamer.so not being OK.  Cancel.  Quit OBS go to System Preferences => Security General tab and allow it.  Open OBS again.   Now you should see GStreamer Source in the sources.
Add a GStreamer Source.  Uncheck both Sync options.  Put in a pipeline.  For us using PTZOptics camera without audio (we have a separate mixer), it was this:
uridecodebin uri=rtsp://192.168.2.88/1 name=bin ! queue ! video.


----------



## Tuna (Aug 17, 2022)

Tuna updated obs-gstreamer with a new update entry:

0.3.5



> encoder: add H.265 encoder (VAAPI only)
> encoder: add VAAPI encoder device selection



Read the rest of this update entry...


----------



## ErAzOr (Aug 22, 2022)

Are Intel CPUs also supported for the H265 encoder? In the moment only h264 is selectable (with gstreamer 0.3.5)


----------



## Tuna (Aug 22, 2022)

ErAzOr said:


> Are Intel CPUs also supported for the H265 encoder? In the moment only h264 is selectable (with gstreamer 0.3.5)


There is no runtime check for hardware support. So it should be there. Note that HEVC works for recording only, not for streaming.


----------



## ErAzOr (Aug 22, 2022)

OK thank you for the information.
Than I have to figure out, why it is not working in my case.

Is it possible to output to an URL (like in custom ffmpeg), or rust record to a file?


----------



## mauibra (Sep 10, 2022)

Ciao a tutti. Ho installato il plug-in ma non riesco a farlo funzionare su un notebook con un processore AMD RYZEN. Funziona benissimo su un PC con un processore Intel i5. Vorrei sapere se i processori AMD sono compatibili con questo plugin. Grazie


----------



## Leebunker321 (Sep 26, 2022)

hope someone can help 
i have 3 pcs that i stream from 2 use gstreamer no problem but the 3rd just won’t pull the feeds 
it’s the same obs portable on each so i’m at a bit of a loss any ideas ?


----------



## Dukercan (Nov 10, 2022)

I am having problems getting sound from my OBS GStreamer inputs.
Cameras are Bosch Flexidome IP 4000HD. Audio is on and set to AAC 48kbps
OBS is 28.1.2 (64bit) on Win 11
Pipeline is : 
rtspsrc location=rtspt://service:xxxxxx@10.0.0.199:554/?inst=2 latency=0 buffer-mode=auto ! rtph264depay ! h264parse ! nvh264dec ! video.
Video works fine, but when I add bin. ! queue ! audio. to the end, I loose the video and there is no audio.
The cameras work fine as RTSP inputs as a Media Source giving picture and sound streams, but they are lagging and sound/picture are off by 1.5 seconds.  Trying GStreamer to see if I can get them more in sync.
Anyone have an answer?
Thanks


----------



## Tuna (Nov 11, 2022)

Dukercan said:


> I am having problems getting sound from my OBS GStreamer inputs.
> Cameras are Bosch Flexidome IP 4000HD. Audio is on and set to AAC 48kbps
> OBS is 28.1.2 (64bit) on Win 11
> Pipeline is :
> ...


That pipeline is bogus. You try to connect the audio path from an element named "bin" but you have not given any element such name. You probably want to add "name=bin" to the "rtspsrc" element. Eventually you also want to add queues for each branch..


----------



## Tuna (Monday at 9:00 AM)

Tuna updated obs-gstreamer with a new update entry:

0.4.0



> encoder: add NVENC H.265 (marvin0815)
> encoder: add QSV H.264/H.265 (marvin0815)
> encoder: add RockChip H.264/H.265 (happyme531)
> filter: add I422 color format
> ...



Read the rest of this update entry...


----------

