When shutting down a GStreamer pipeline that reads frames from an appsrc, encodes them, and writes them out to a file, I noticed that although I had pushed N
buffers into the appsrc, the file would have only N-1
frames about 50% of the time (the remainder of the time it was N
).
I am using GStreamer 1.14.5 on Ubuntu and I have tried sending the EOS action signal using both:
self._pipeline.send_event(Gst.Event.new_eos())
# and
self._appsrc.send_event(Gst.Event.new_eos())
I was able to resolve my issue by calling the appsrc method end_of_stream
instead of emitting the action signal. The documentation says that either of these methods should work so I suppose that there is/was a bug in GStreamer 1.14.5 that resulted in the last buffer not being pushed to the output pad before the EOS was propagated down the pipeline.
TLDR: replace self._appsrc.send_event(Gst.Event.new_eos())
with self._appsrc.end_of_stream()
.