Hide source when playback ends - upgrade

When adding a media source an option exists to "Hide source when playback ends"

This appears to only toggle whether or not the last frame of the video remains.

I propose that this be actually hidden such that the eye icon change to "hidden" and an event is fired so API connected programs can detect the end of playback.


If there is some reason it does not currently do this I request that the reason be explained. I cannot think of why a hidden non-looping video file would remain visible in the sources pane. This is not meant to be a challenge but rather so I understand a use case where this would be helpful.



This has a variety of benefits.

API controlled playback can know when to switch scenes, playback the next file in a queue, etc.

Stream Decks (what I am doing and this is one of my final issues before release) can detect end of playback to avoid having to manually toggle the source to restart playback later.

And other related benefits.

This should not be terribly hard to do, and is probably a 5 minute change for someone who is familiar with the code but that is not me. I have yet to view the code so it will take me a lot longer to get up to speed.
 
To speed things along I have started looking at the code.

This appears to be a really good place to add it.
./plugins/obs-ffmpeg/obs-ffmpeg-source.c
Line 230 function media_stopped

I just have to figure out how sources are hidden or not.

What I am concerned with and what is likely going to take me longer to do is conflicts with my patch and program integrity and stability. I do not have any test cases to ensure I dont really break things.
 
This will be my final for the evening and I will not be able to work on this for at least 1 day. However I think I am close so if someone wants to take the lead feel free :D I am afraid of freeing resources that would be used later or not freeing everything I should and leaking all over the floor - or in bad circumstances causing crashes in the software :/


I think that in obs-ffmpeg-source.c s->source contains the requisite info to be able to call obs_sceneitem_set_visible() and maybe obs_sceneitem_release()

I will play around with this if no one else does by the time I am available. I have exactly 40 minutes with the code so I will likely break things in unintended ways that do not manifest themselves for some time to come.
 
just thought of a reason why this may never have been done.

Potential conflict between "Close file when inactive" and "Hide source when playback ends"

If you hide it and call obs_sceneitem_release() the file must be closed.

If you want to remove the last frame from the video output but plan on replaying the file over and over you may want to leave the file open.

Hiding it therefore may cause a performance hit in some cases but it likely will not be that great although I honestly do not know. This is something that needs to be investigated.
 
Top