-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Source: add support for auto-disconnecting NDI connection #993
Source: add support for auto-disconnecting NDI connection #993
Conversation
* Adds a new source property called "Behavior" that lets you choose between the old behavior "Keep source connected" which keeps the NDI source connected at all times, and the new feature "Disconnect source when not visible" which will disconnect NDI to preserve CPU and network resources while sources are not visible. * Adds a "Keep last frame when disconnected" option for the previous behavior setting, so that you can choose if the last frame should be kept, or that the source texture should reset when disconnected. This might solve issue DistroAV#880
A stop / start on the source detail would be a good addition as well so sources cane be paused (properly by stopping the network pull). |
Is this necessary if you have the option for it to only connect when it is visible/active? Do you have an example use case? |
Per my #880 (comment) comment, stopping the NDI stream can be undesirable because it can cause a delay when starting back up. I understand that this PR makes it an option to turn off the NDI stream and defaults to the existing behavior. Let me think about this a little bit; nudge me if I take over a week. |
I understand that in some cases it would ve undesirable, but this is also a feature in the built in vlc plugin. So it is an existing workflow in obs. Also the only way to handle more than a few ndi sources in obs without using up all your resources. In my humble opinion it should be up to the user if they want to risk the delay. With the «remember last frame» feature, it is seldom noticable, especially if you use fade transitions. I just wanted to add this. Please think about it :) |
@haakonnessjoen A few questions about your intentions behind this merged PR. The options are you wrote them are:
This UI makes it possible to enable In your opinion of this change, does that make any sense? I am thinking of changing the UI for this to be:
This would make it impossible/undefined to use Does this seem reasonable? We are talking about this more in:
And I am preparing a PR to make some changes to make this more understandable to the masses. 😆 If you aren't already, feel free to join our Discord server to talk more about this: CC @Trouffman |
I guess it makes sense. If I understand #1046 correctly you could think that not checking this check box would make the source go black if the source disconnects? That could maybe be a feature that would be nice to have in addition though. An option to clear the frame if no new frame has been received in x amount of time. Or should it be combined with this feature, and then the options could stay the way they were? If I recall correctly, I made it/worded it this way since the VLC plugin has similar options. So I made it so you find options that you might be familiar with if you are a VLC user. But maybe the VLC plugin also handles sources being removed with the same option? If not we should maybe try to get the VLC plugins options changed too? |
So you would not object if we tweaked the feature a little bit to make more sense to... me/us? 😄
Can VLC receive and play NDI sources? I played with the VLC NDI Plugin a bit today and see how to enable it to output NDI audio and video, but I do not see any way for it to view NDI sources. |
It might be useful to have an option around the Regardless, we'll probably play with this feature a bit. Just a heads up. Thank you for your code contribution! |
No, I have nothing against it. :) As long as it still does the main thing I added 😅
No, not NDI, just external video sources in general. But it has the same feature in regards to letting it disconnect from the video-source when the source/plugin is not visible, to free resources/bandwidth. |
I had the following bug using the behavior setting:
It seems there is an issue with OBS studio not calling our show or hide callback when a source is shown/hidden by clicking the eye icon in Studio Mode. Seems to work in normal mode. Also, if we try to work around this issue by checking if the source is actually shown in the thread, obs_source_showing always reports true, no matter what the eye icon is set to. |
This is known issue with OBS. Or at least for me. This also happens with the VLC plugin for other video sources. I would guess this is a "feature" in OBS, since in studio mode you have preview/program. And things in preview is not considered live right. So sources are only told that they are active when they are on the "program" output. The reason I think this is considered a feature, is that it makes it easier for people to build systems that will have a "tally" that tells that the source is in fact "live", and not only in a preview output. |
I think this is precisely what @Trouffman fixed in the 6.0.0_actual branch via 85a3110 It will be in master once 6.0.0_actual is merged. |
I duplicated the issue on 6.0.0_actual. His changes appear to work in normal mode but not Studio mode. |
Even if the source is not shown in program or preview, there is no way to determine this using the API. I dont think it is a feature and this problem leads to a tally bug where a source in program will show as also in preview, even if it it isn't. |
Do you know if this has been reported as an issue in OBS? I couldnt find one. |
This is why I changed the OBS source status trigger from source ".activated" = on stream/program to the source ".shown" = not visible on any screen. Make sure that you do not have a filter on any of the scenes as well, because of an NDI filter is on a scene, this will trigger the "is visible". If you could file a bug with the full log that will help diagnose. |
I created an issue: #1078 Was able to get the ndi_source_shown called when I unhide the source (not sure why it wasn't being called before). It seems we need to call ndi_source_update to restart the thread when we get the ndi_source_shown call. It is also necessary to change the check for restarting the thread to look for obs_source_showing instead of obs_source_active as @Trouffman mentioned above. Adding the following line in ndi_source_shown will fix the issue: I would make a pull request, but unsure which branch to use. |
Create your PR from either master or 6.0.0_actual. There have been a lot of changes to the code in the past few days. |
@paulpv I closed the issue I created because your latest commits to 6.0.0_actual fixed the problem. Actually, starting the thread in the ndi_source_shown callback is better than my overkill suggestion of calling the ndi_source_update. Nice work! |
Adds a new source property called "Behavior" that lets you choose between the old behavior "Keep source connected" which keeps the NDI source connected at all times, and the new feature "Disconnect source when not visible" which will disconnect NDI to preserve CPU and network resources while sources are not visible.
Adds a "Keep last frame when disconnected" option for the previous behavior setting, so that you can choose if the last frame should be kept, or that the source texture should reset when disconnected.
This might solve issue #880
This PR fixes issues I have had with having more than a few NDI sources, it is easy to use up a 1 Gbit ethernet connection if each source pulls 200mbit/s of network data. It's was impossible to add the 20 sources I wanted to add, but with this feature, it is possible. It behaves like the vlc plugin, which also has support for choosing if the source should stop the playback while the source is not active.