From fbc968d06c3b126ef8e08ef780b5924740b8fe95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 21 May 2024 16:58:26 +0300 Subject: [PATCH] av1enc: Use 1/90000 as timebase and don't use the framerate at all This mirrors the behaviour in vp8enc / vp9enc and is generally more useful than using any framerate from the caps as it provides some degree of accuracy if the stream doesn't have timestamps perfectly according to the framerate. Part-of: --- subprojects/gst-plugins-bad/ext/aom/gstav1enc.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/aom/gstav1enc.c b/subprojects/gst-plugins-bad/ext/aom/gstav1enc.c index 83121ae5d7..dd68d8bcd3 100644 --- a/subprojects/gst-plugins-bad/ext/aom/gstav1enc.c +++ b/subprojects/gst-plugins-bad/ext/aom/gstav1enc.c @@ -835,15 +835,13 @@ gst_av1_enc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state) av1enc->aom_cfg.g_w = GST_VIDEO_INFO_WIDTH (info); av1enc->aom_cfg.g_h = GST_VIDEO_INFO_HEIGHT (info); - /* Recommended method is to set the timebase to that of the parent - * container or multimedia framework (ex: 1/1000 for ms, as in FLV) */ - if (GST_VIDEO_INFO_FPS_D (info) != 0 && GST_VIDEO_INFO_FPS_N (info) != 0) { - av1enc->aom_cfg.g_timebase.num = GST_VIDEO_INFO_FPS_D (info); - av1enc->aom_cfg.g_timebase.den = GST_VIDEO_INFO_FPS_N (info); - } else { - av1enc->aom_cfg.g_timebase.num = DEFAULT_TIMEBASE_N; - av1enc->aom_cfg.g_timebase.den = DEFAULT_TIMEBASE_D; - } + /* Zero framerate and max-framerate but still need to setup the timebase to avoid + * a divide by zero error. Presuming the lowest common denominator will be RTP - + * VP8 payload draft states clock rate of 90000 which should work for anyone where + * FPS < 90000 (shouldn't be too many cases where it's higher) though wouldn't be optimal. RTP specification + * http://tools.ietf.org/html/draft-ietf-payload-vp8-01 section 6.3.1 */ + av1enc->aom_cfg.g_timebase.num = 1; + av1enc->aom_cfg.g_timebase.den = 90000; av1enc->aom_cfg.g_error_resilient = AOM_ERROR_RESILIENT_DEFAULT; if (av1enc->threads == DEFAULT_THREADS)