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
This commit is contained in:
Martin Pulec
2026-02-17 16:05:27 +01:00
parent 9e5cb700b2
commit cc2a2fc37c

View File

@@ -43,6 +43,7 @@
#include <cmath>
#include <cstdint>
#include <cstring> // for strcmp, strlen, strstr, strchr
#include <libavutil/rational.h> // for av_inv_q
#include <list>
#include <map>
#include <regex>
@@ -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;