v4l2videodec: fix src side frame rate negotiation
authorPhilipp Zabel <p.zabel@pengutronix.de>
Wed, 24 Feb 2021 12:25:43 +0000 (13:25 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 24 Feb 2021 16:15:49 +0000 (17:15 +0100)
Negotiating v4l2h264dec ! v4l2h264enc transcoding pipelines fails in
case the encoder does not accept framerate=(fraction)0/1.
The acquired caps used for downstream negotiation are determined from
gst_v4l2_object_acquire_format(), which sets the GstVideoInfo::fps_n
and ::fps_d fields to 0.
To fix this, copy the frame rate from the sink side.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/882>

sys/v4l2/gstv4l2videodec.c

index 89ad3e8..c61fb25 100644 (file)
@@ -697,6 +697,10 @@ gst_v4l2_video_dec_handle_frame (GstVideoDecoder * decoder,
     if (!gst_v4l2_object_acquire_format (self->v4l2capture, &info))
       goto not_negotiated;
 
+    /* gst_v4l2_object_acquire_format() does not set fps, copy from sink */
+    info.fps_n = self->v4l2output->info.fps_n;
+    info.fps_d = self->v4l2output->info.fps_d;
+
     /* Create caps from the acquired format, remove the format field */
     acquired_caps = gst_video_info_to_caps (&info);
     GST_DEBUG_OBJECT (self, "Acquired caps: %" GST_PTR_FORMAT, acquired_caps);