From f4049fc292ce1ed749701d2a31bf6026b7d60eac Mon Sep 17 00:00:00 2001 From: Hou Qi Date: Tue, 25 May 2021 16:19:20 +0800 Subject: [PATCH] v4l2videoenc: Set default latency if the frame duration is invalid If the duration of the v4l2object is invalid, use default 25fps instead. Part-of: --- sys/v4l2/gstv4l2videoenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/v4l2/gstv4l2videoenc.c b/sys/v4l2/gstv4l2videoenc.c index 8f3324d..19496b7 100644 --- a/sys/v4l2/gstv4l2videoenc.c +++ b/sys/v4l2/gstv4l2videoenc.c @@ -886,8 +886,12 @@ gst_v4l2_video_enc_decide_allocation (GstVideoEncoder * * more work to explicitly expressed the decoder / encoder latency. This * value will then become max latency, and the reported driver latency would * become the min latency. */ + if (!GST_CLOCK_TIME_IS_VALID (self->v4l2capture->duration)) + self->v4l2capture->duration = gst_util_uint64_scale_int (GST_SECOND, 1, 25); latency = self->v4l2capture->min_buffers * self->v4l2capture->duration; gst_video_encoder_set_latency (encoder, latency, latency); + GST_DEBUG_OBJECT (self, "Setting latency: %" GST_TIME_FORMAT, + GST_TIME_ARGS (latency)); done: gst_video_codec_state_unref (state); -- 2.7.4