v4l2videodec: fix src side frame rate negotiation
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.
Example error:
0:00:00.560018334 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:264:gst_v4l2_video_dec_set_format:<v4l2h264dec0> Setting format: video/x-h264, stream-format=(string)byte-stream, alignment=(string)au, level=(string)4, profile=(string)main, width=(int)1920, height=(int)800, framerate=(fraction)24/1, pixel-aspect-ratio=(fraction)1/1, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true
0:00:00.562320000 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:660:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Handling frame 0
0:00:00.562393000 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:681:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Sending header
0:00:00.615991000 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:731:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Acquired caps: video/x-raw, format=(string)NV12, width=(int)1920, height=(int)800, interlace-mode=(string)progressive, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)mpeg2, colorimetry=(string)bt709, framerate=(fraction)0/1
0:00:00.616509667 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:738:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Available caps: video/x-raw(format:Interlaced), format=(string)YUY2, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)alternate, colorimetry=(string){ bt709 }; video/x-raw(format:Interlaced), format=(string)I420, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)alternate, colorimetry=(string){ bt709 }; video/x-raw(format:Interlaced), format=(string)YV12, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)alternate, colorimetry=(string){ bt709 }; video/x-raw(format:Interlaced), format=(string)NV12, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)alternate, colorimetry=(string){ bt709 }; video/x-raw, format=(string)YUY2, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)progressive, colorimetry=(string){ bt709 }; video/x-raw, format=(string)I420, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)progressive, colorimetry=(string){ bt709 }; video/x-raw, format=(string)YV12, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)progressive, colorimetry=(string){ bt709 }; video/x-raw, format=(string)NV12, width=(int)[ 48, 1920 ], height=(int)[ 16, 1088 ], framerate=(fraction)[ 0/1, 2147483647/1 ], interlace-mode=(string)progressive, colorimetry=(string){ bt709 }
0:00:00.616823334 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:746:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Filtered caps: video/x-raw, format=(string)YUY2, width=(int)1920, height=(int)800, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string){ bt709 }, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)I420, width=(int)1920, height=(int)800, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string){ bt709 }, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)YV12, width=(int)1920, height=(int)800, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string){ bt709 }, pixel-aspect-ratio=(fraction)1/1; video/x-raw, format=(string)NV12, width=(int)1920, height=(int)800, framerate=(fraction)0/1, interlace-mode=(string)progressive, colorimetry=(string){ bt709 }, pixel-aspect-ratio=(fraction)1/1
0:00:00.617610334 391 0x8c3a40 DEBUG v4l2videoenc gstv4l2videoenc.c:1134:gst_v4l2_video_enc_sink_query:<v4l2h264enc0> Returning sink caps EMPTY
0:00:00.617700000 391 0x8c3a40 DEBUG v4l2videodec gstv4l2videodec.c:752:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> Possible decoded caps: EMPTY
0:00:00.617768000 391 0x8c3a40 ERROR v4l2videodec gstv4l2videodec.c:842:gst_v4l2_video_dec_handle_frame:<v4l2h264dec0> not negotiated