fzwoch / obs-gstreamer

GStreamer OBS Studio plugin
GNU General Public License v2.0
349 stars 34 forks source link

Ability for other plugins to get the current playback status of a gstreamer source #70

Closed RockNRollGeek closed 1 year ago

RockNRollGeek commented 2 years ago

It's often useful for other plugins to be able to get the status of a source and it's current playback for purposes of control, automation, etc etc. For example, obs-websocket can get the playing status/time/etc of a media source or a vlc playlist source. Recently I was using gstreamer plugin to create an srt listener, and noticed other plugins could not get the status of the gstreamer plugin and whether it was playing back anything or not. In bringing it up a few places, the developer of the obs-websocket plugin mentioned:

"_the developer of the gstreamer source/plugin should implement the .media_get_time callback_"

Is this something that could be implemented in the gstreamer plugin, so that other plugins/apps/etc can see the status of the gstreamer source in regards to playing/paused/duration/etc status of it?

Thanks!

fzwoch commented 2 years ago

If that is all what is required it should be doable.

What is the easiest way to test it?

RockNRollGeek commented 2 years ago

Not sure, my initial use case was using it in conjunction with SRT Stats monitor which pulls info from sources in this way, so theoretically that's one way to test it, though it probably helps if I'm not playing telephone between plugin devs, haha. Here's a link to the original thread for the SRT Stats Monitor plugin if that helps communication a bit: https://github.com/loopy750/SRT-Stats-Monitor/issues/5

rodrigograca31 commented 2 years ago

Im also looking for this feature! I was using obs-websocket and doing obs.send("RestartMedia", { sourceName: mediaSource.sourceName }); to stop and play a VLC source.

Now the GStreamer Source doesnt even show up on the mediaSources list. Sample code:

import OBSWebSocket = require("obs-websocket-js");
const obs = new OBSWebSocket();

console.log("Connecting to OBS...");

obs
    .connect({
        address: "localhost:" + 4444,
        password: "PASSWORD",
    })
    .then(() => {
        return obs.send("GetMediaSourcesList");
    })
    .then((data) => {
        data.mediaSources.forEach((mediaSource) => {
            console.log(mediaSource);
            console.log(mediaSource.sourceName);
        });
    })
    .catch((err) => {
        console.log(err);
    });

For reference these seem to be all the current media methods for VLC/ffmep sources: image

we should start with the basic ones! (play/stop) Also! OBS 28.x (still in beta but will be the next version) comes with obs-websocket built in!

rodrigograca31 commented 1 year ago

Great! :tada:

@fzwoch how do we run the latest code? We need to make a build our selfs? (last time I tried was a pain in the rear and couldnt actually do it)

Is there an v0.4.0 coming up?

I cant wait to use this feature! Thanks for the great work! @kamalmostafa

fzwoch commented 1 year ago

You would have to build it yourself at the moment. Maybe I can do a release in the next week or so.

rodrigograca31 commented 1 year ago

That would be great!

(PS: OBS 29 has come out! lets hope everything is working well) :)

kamalmostafa commented 1 year ago

(PS: OBS 29 has come out! lets hope everything is working well) :)

Thanks for the heads-up @rodrigograca31 ...

I've just tested my new media control and status features -- OBS GUI controls and websocket -- with OBS 29.0.0 on Ubuntu*. Happily, an obs-gstreamer.so binary (built for OBS 28) appears to work just fine in OBS 29 as well.

*obs-studio (29.0.0-0obsproject1~jammy) from https://launchpad.net/~obsproject/+archive/ubuntu/obs-studio