Catching NAVIGATION events in PyGst

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Catching NAVIGATION events in PyGst

Pavel Hofman
Hi,

Please may I ask how to catch Gst.EventType.NAVIGATION
https://lazka.github.io/pgi-docs/Gst-1.0/enums.html#Gst.EventType.NAVIGATION
in a simple gstreamer python player, e.g. this
https://brettviren.github.io/pygst-tutorial-org/playbin-example-video.py ?

I would assume something like this
https://github.com/gkralik/python-gst-tutorial/blob/master/basic-tutorial-5.py#L35
but do not know the event string name.

I want to make a simple player where clicking on some parts of the video
screen runs some action (zoom in/out command sent to a streaming camera).

Thank you very much for any help and hints.

Best regards,

Pavel.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Catching NAVIGATION events in PyGst

Pavel Hofman
Dne 21. 09. 20 v 13:46 Pavel Hofman napsal(a):
> Hi,
>
> Please may I ask how to catch Gst.EventType.NAVIGATION
> https://lazka.github.io/pgi-docs/Gst-1.0/enums.html#Gst.EventType.NAVIGATION
> in a simple gstreamer python player, e.g. this
> https://brettviren.github.io/pygst-tutorial-org/playbin-example-video.py ?

Finally figured it out, with help of the gstnavigationtest.c source.
Just in case someone needs the same - a crude code fragment:


import gi

gi.require_version('Gst', '1.0')
from gi.repository import Gst


def on_event(pad, info):
    event = info.get_event()
    type = event.type
    if type == Gst.EventType.NAVIGATION:
        struct = event.get_structure()
        if struct.get_string('event') == 'mouse-button-press':
            print(struct)
    return Gst.PadProbeReturn.OK


# initialize GStreamer
Gst.init(None)
# build the pipeline

pipeline = Gst.parse_launch(
    "rtspsrc location=rtsp://192.168.105.21:554?channel=0 latency=1 !
rtph264depay ! h264parse !  vaapih264dec low-latency=1 ! vaapisink"
)
# start playing
pipeline.set_state(Gst.State.PLAYING)

# for some reason no events from the vaapisink bin (first in the list),
but the second bin (vaapih264dec) works OK
bin = pipeline.children[1]
# sink = 0, src = 1
pad = bin.pads[0]
pad.add_probe(Gst.PadProbeType.EVENT_UPSTREAM, on_event)

# wait until EOS or error
bus = pipeline.get_bus()
bus.add_signal_watch()

msg = bus.timed_pop_filtered(
    Gst.CLOCK_TIME_NONE,
    Gst.MessageType.ERROR | Gst.MessageType.EOS
)
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel