Hi,
I am trying to save a videofile while also displaying a livestream. To do this I attach the filesink part of my pipeline, once I get the signal to start recording. The complete pipeline looks like this: srcbin -> capsfilter -> tee -> videoconvert -> queue -> appsink \ -> queue -> videoconvert -> mpeg2enc -> filesink The problem I now have is that the filesink seems to require an EOS event in order to correctly store the file. My attempts at disconnecting and stopping the filesink branch have only resulted in files with the size 0. What is the correct way to disconnect the branch and correctly save the file? Regards, Edgar _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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. If you need to reset the elements for a new recording you can put them to NULL state and then back to ready/paused/playing. NULL state will ensure that the EOS flag gets reset and any resources connected with the pipeline (like the recorded file) are released. Remeber to change the location parameter on the filesink before setting the pipeline to a higher state than NULL! DimitriosOn Mon, Apr 10, 2017 at 6:05 AM, Edgar Thier <[hidden email]> wrote: Hi, _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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 [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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! On Mon, Apr 10, 2017 at 10:59 AM, Edgar Thier <[hidden email]> wrote: Hi Dimitrios, _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |