Official way to stop a pipeline in Python?

Mathieu Duponchelle mathieu at centricular.com
Mon Sep 9 18:07:19 UTC 2019


set_state(Gst.State.NULL) should work, you probably want to collect a stacktrace
at hang time and figure out what's blocking :)

On 9/9/19 4:57 PM, pisymbol . wrote:
> I have an application that worked fine on Ubuntu 16.04 but now hangs on Ubuntu 18.04 when I try to stop my pipeline.
>
> Here is how I am initializing my pipeline;:
>
> self.recorderBin = Gst.parse_bin_from_description(RECORD_PIPELINE, False)
> self.recorderPipeline = Gst.Pipeline()
> self.recorderPipeline.add(self.recorderBin)
> bus = self.recorderPipeline.get_bus()
> bus.add_watch(GLib.PRIORITY_DEFAULT, self._on_message)
>
> At some point, the application starts recording and the bus is set into the PLAYING state which succeeds, recording begins.
>
> Now when the user presses the stop button:
>
> self.recorderPipeline.send_event(Gst.Event.new_eos())
>
> When the EOS is sent to the bus and self._on_message is triggered and caught:
>
> self.recorderPipeline.set_state(Gst.State.NULL)
> HANG
>
> Am I doing something wrong? I looked at the gst-launch-1.0 code and it seems to be using an event_loop() that polls for messages instead of the callback approach above. Also, gst-launch-1.0 PAUSES the bus, sets the bus state back into the READY state, before actually setting it to the NULL state, de-referencing it, and exiting. I actually tried it that as well but when I set the bus state to PAUSE then READY is hangs again.
>
> Why does the Python code above hang when setting the state while the C code seems to work? Do I need to poll for bus messages and not rely on the auto main loop created underneath me? I can't find a singe Python example that polls for messages. Almost all of them are some flavor of connecting to the bus via callbacks.
>
> Some guidance would be appreciated,
>
> -aps
>
>
>
>
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190909/2d5af2b9/attachment.html>


More information about the gstreamer-devel mailing list