From cc2a2fc37cfa25ec1b8a4c2a93d0f34bd4c7d1f3 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 17 Feb 2026 16:05:27 +0100 Subject: [PATCH] vcomp/lavc: improve time_base setting for /1001 formats eg. 29.97, 1/30 was set - improve to set 1001/30000 for AVCodecCtx.framerate just invert the time_base fraction --- src/video_compress/libavcodec.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 40996dd5a..2d1cb1e02 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -43,6 +43,7 @@ #include #include #include // for strcmp, strlen, strstr, strchr +#include // for av_inv_q #include #include #include @@ -953,9 +954,9 @@ bool set_codec_ctx_params(struct state_video_compress_libav *s, AVPixelFormat pi s->codec_ctx->width = desc.width; s->codec_ctx->height = desc.height; /* frames per second */ - s->codec_ctx->time_base = (AVRational){1,(int) desc.fps}; - s->codec_ctx->framerate = (AVRational) { get_framerate_n(desc.fps), - get_framerate_d(desc.fps) }; + s->codec_ctx->time_base = (AVRational) { get_framerate_d(desc.fps), + get_framerate_n(desc.fps) }; + s->codec_ctx->framerate = av_inv_q(s->codec_ctx->time_base); s->codec_ctx->gop_size = s->requested_gop; s->codec_ctx->max_b_frames = 0;