From dfaccd1e3a78be722d3304f746baded7b6224ea6 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Tue, 4 Jan 2022 22:45:39 -0800 Subject: [PATCH] obs-ffmpeg: Fix av1 encoding with fractional framerates Just use util_mul_div64 instead of using av_rescale_q_rnd --- plugins/obs-ffmpeg/obs-ffmpeg-av1.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-av1.c b/plugins/obs-ffmpeg/obs-ffmpeg-av1.c index 7ca6594ea..f1a6244e0 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-av1.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-av1.c @@ -336,7 +336,6 @@ static inline void copy_data(AVFrame *pic, const struct encoder_frame *frame, #define SEC_TO_NSEC 1000000000LL #define TIMEOUT_MAX_SEC 5 #define TIMEOUT_MAX_NSEC (TIMEOUT_MAX_SEC * SEC_TO_NSEC) -static const AVRational nsec_timebase = {1, 1000000000}; static bool av1_encode(void *data, struct encoder_frame *frame, struct encoder_packet *packet, bool *received_packet) @@ -400,10 +399,9 @@ static bool av1_encode(void *data, struct encoder_frame *frame, *received_packet = true; uint64_t recv_ts_nsec = - (uint64_t)av_rescale_q_rnd( - av_pkt.dts, enc->context->time_base, - nsec_timebase, - AV_ROUND_NEAR_INF | AV_ROUND_PASS_MINMAX) + + util_mul_div64((uint64_t)av_pkt.dts, + (uint64_t)SEC_TO_NSEC, + (uint64_t)enc->context->time_base.den) + enc->start_ts; #if 0