From dbc89e3ab61f2088e1f6aa1eb2689e0d049fd817 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Wed, 26 Sep 2012 16:31:27 +0200 Subject: [PATCH] videoencoder: use oldest frame PTS to estimate missing outgoing DTS --- gst-libs/gst/video/gstvideoencoder.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 79999f3..63e2d02 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -1757,6 +1757,17 @@ gst_video_encoder_finish_frame (GstVideoEncoder * encoder, GST_BUFFER_FLAG_SET (frame->output_buffer, GST_BUFFER_FLAG_DELTA_UNIT); } + /* DTS is expected monotone ascending, so a good guess is the lowest PTS + * of all pending frames, i.e. the oldest frame's PTS (all being OK) */ + if (!GST_CLOCK_TIME_IS_VALID (frame->dts) && encoder->priv->frames) { + GstVideoCodecFrame *oframe = encoder->priv->frames->data; + + frame->dts = oframe->pts; + GST_DEBUG_OBJECT (encoder, + "no valid DTS, using oldest frame's PTS %" GST_TIME_FORMAT, + GST_TIME_ARGS (frame->pts)); + } + frame->distance_from_sync = priv->distance_from_sync; priv->distance_from_sync++; -- 2.7.4