How to save file from filesink in dynamic pipeline

Dimitrios Katsaros patcherwork at gmail.com
Tue Apr 11 11:57:03 UTC 2017


Pad probes have a GstPadProbeReturn value. I do not know what python
defaults to if you run the function without a return value, But for
blocking probes you need to remove the probe to allow buffer flow to
continue. Otherwise you pipeline will block on that probe and hang until
the probe is removed. I am not sure why buffer_probe would not be called
with BUFFER probes. Are you sure the pipeline is running when you set the
probe? if you are in PAUSED or lower you will never receive a buffer to
trigger the pad.

I can see that you are looking at the filesink pad for when it recieves the
eos event. However at that point the eos has not been handled by the
filesink yet and you are removing the elements, which may lead to a
corrupted file. What you should do instead is monitor the messages comming
from the filesink. It will pose an EOS message on the bus when it is done.
You can respond to that message by removing the pipeline.

I am assuming image bin is the bin you want to remove from the pipeline?
you should set the state of the bin to null, then get the state to ensure
that it has been set to NULL and then remove it. I do not think that gstbin
drops the state of the removed elements on its own so you need to handle
this. Also, you do not need to stop the entire pipeline. Once an element
goes to eos it will flush all incoming buffers so you should be able to
release the bin and disconnect the pad.

Discarding the sub pipe is also valid. You just need to be aware that there
is an overhead involved with recreating elements so keeping the elements
rather than destroying them will help you on that regard.

Remeber these are just suggestions from the snippet that you posted so if
you feel that there is a better solution for your case, then it is possible
that you are right and I just am not aware of some hidden cavet for your
application!


dmt

On Mon, Apr 10, 2017 at 10:59 AM, Edgar Thier <
edgar.thier at theimagingsource.com> wrote:

> Hi Dimitrios,
>
> Thanks for your response.
>
> > What you can do is add a buffer probe to the sink pad of the queue hen
> you intend to disconnect
> > once you signal stopping a file. On the next buffer recieved you trigger
> the eos event and then
> > do the pipeline cleanup.
>
> Currently my code looks like this:
>
>
>     def eos_callback(self, pad, event):
>         print("In EOS")
>         self.pipeline.set_state(Gst.State.PAUSED)
>         self.srcpad.unlink(self.queue_pad)
>         self.pipeline.remove(self.image_bin)
>         self.pipeline.set_state(Gst.State.PLAYING)
>
>     def buffer_probe(self, pad, probe_info):
>         print("Received next buffer")
>         self.eos_probe =
> self.filesink.get_static_pad("sink").add_probe(Gst.
> PadProbeType.EVENT_DOWNSTREAM,
>
> self.eos_callback)
>         pad.send_event(Gst.Event.new_eos())
>
>     def _disconnect(self):
>         print("Disconnecting")
>         self.queue_pad.add_probe(Gst.PadProbeType.BUFFER,
>                                  self.buffer_probe)
>
> I call self._disconnect() to trigger a stop. The probe gets added, however
> buffer_probe is not
> called. When I change the probe type to BLOCKING, buffer_probe gets called
> but my application hangs
> itself. I am not sure what I am missing...
>
> As to reusing the elements for saving the stream:
> My plan was to simply throw that part of the pipeline away once the
> recording stopped and re-add a
> new bin for recording when a new one is requested.
>
> Regards,
>
> Edgar
> _______________________________________________
> 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/20170411/d2bc79e5/attachment.html>


More information about the gstreamer-devel mailing list