[FFmpeg-devel] [PATCH] avcodec/v4l2_m2m: fix setting the frame rate

Andriy Gelman andriy.gelman at gmail.com
Tue Mar 17 00:54:11 EET 2020


On Mon, 16. Mar 10:00, Ming Qian wrote:
> v4l2 set the frame rate through frame intervals,
> not set frame rate directly.
> the frame rate and frame intervals are reciprocal.
> so in libavdevice/v4l2.c we can see the following code:
> 	tpf->numerator   = framerate_q.den;
> 	tpf->denominator = framerate_q.num;
> 
> Signed-off-by: Ming Qian <ming.qian at nxp.com>
> ---
>  libavcodec/v4l2_m2m_enc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m_enc.c b/libavcodec/v4l2_m2m_enc.c
> index c9f1741bfd..5b954f4435 100644
> --- a/libavcodec/v4l2_m2m_enc.c
> +++ b/libavcodec/v4l2_m2m_enc.c
> @@ -40,8 +40,8 @@ static inline void v4l2_set_timeperframe(V4L2m2mContext *s, unsigned int num, un
>      struct v4l2_streamparm parm = { 0 };
>  
>      parm.type = V4L2_TYPE_IS_MULTIPLANAR(s->output.type) ? V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE : V4L2_BUF_TYPE_VIDEO_OUTPUT;
> -    parm.parm.output.timeperframe.denominator = den;
> -    parm.parm.output.timeperframe.numerator = num;
> +    parm.parm.output.timeperframe.denominator = num;
> +    parm.parm.output.timeperframe.numerator = den;
>  
>      if (ioctl(s->fd, VIDIOC_S_PARM, &parm) < 0)
>          av_log(s->avctx, AV_LOG_WARNING, "Failed to set timeperframe");
> -- 
> 2.25.1
> 

Probably clearer to make the change in the call to the function with:

v4l2_set_timeperframe(s, avctx->framerate.den, avctx->framerate.num);

Otherwise this commit lgtm.

Thanks,
-- 
Andriy


More information about the ffmpeg-devel mailing list