How to wait for x264enc to encode buffered frames on end-of-stream

Alex Lynch lynch.alex at gmail.com
Tue Aug 20 15:28:19 UTC 2019


I have a Python GStreamer application that uses appsrc to record mp4 files.

The issue is that despite specifying tune=zerolatency for x264enc, there is
latency, and the output video is truncated when an eos is sent to the
pipeline. Depending on the machine, the latency is substantial, resulting
in a much shorter than expected output file.

If I change the pipeline to save the video as an AVI file, it is not
truncated. Unfortunately, the resulting file is approximately 2 GB per
minute versus 12 MB per minute with H.264.

Here is the x264enc pipeline:

appsrc name=appsrc format=time is-live=true
caps=video/x-raw,format=(string)BGR appsrc. ! videoconvert ! x264enc
tune=zerolatency ! qtmux ! filesink location=out.mp4

When the application is finished, it sends end-of-stream messages to the
appsrc and pipeline:

if self._appsrc.emit("end-of-stream") == Gst.FlowReturn.OK:
    self._sink_pipeline.send_event(Gst.Event.new_eos())

Is there a way for my application to wait while x264enc processes its
buffer? A message, perhaps? I don't care how long it takes to finish.
What's important is that all frames pushed to the appsrc are written to the
output video file.

Thanks,
Alex.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20190820/02acf321/attachment.html>


More information about the gstreamer-devel mailing list