From 5372b77987cbdf16f681526152325bee8388ab62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 24 Jan 2023 15:28:17 +0200 Subject: [PATCH] Revert "avvidenc: Set timebase in the ffmpeg context to nanoseconds and set framerate" This reverts commit 50db59449e9cdb637c5f0c1b7c5dccd582fac4ee. This broke the MPEG-1 video encoder as it requires the framerate to be used for the timebase. Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1734 Part-of: --- subprojects/gst-libav/ext/libav/gstavcodecmap.c | 13 +++++++------ subprojects/gst-libav/ext/libav/gstavvidenc.c | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/subprojects/gst-libav/ext/libav/gstavcodecmap.c b/subprojects/gst-libav/ext/libav/gstavcodecmap.c index a7c64e0106..6610593bb6 100644 --- a/subprojects/gst-libav/ext/libav/gstavcodecmap.c +++ b/subprojects/gst-libav/ext/libav/gstavcodecmap.c @@ -2956,13 +2956,14 @@ gst_ffmpeg_videoinfo_to_context (GstVideoInfo * info, AVCodecContext * context) bpp += GST_VIDEO_INFO_COMP_DEPTH (info, i); context->bits_per_coded_sample = bpp; - context->time_base.den = 1000000000; - context->time_base.num = 1; context->ticks_per_frame = 1; - - if (GST_VIDEO_INFO_FPS_N (info) != 0) { - context->framerate.num = GST_VIDEO_INFO_FPS_N (info); - context->framerate.den = GST_VIDEO_INFO_FPS_D (info); + if (GST_VIDEO_INFO_FPS_N (info) == 0) { + GST_DEBUG ("Using 25/1 framerate"); + context->time_base.den = 25; + context->time_base.num = 1; + } else { + context->time_base.den = GST_VIDEO_INFO_FPS_N (info); + context->time_base.num = GST_VIDEO_INFO_FPS_D (info); } context->sample_aspect_ratio.num = GST_VIDEO_INFO_PAR_N (info); diff --git a/subprojects/gst-libav/ext/libav/gstavvidenc.c b/subprojects/gst-libav/ext/libav/gstavvidenc.c index 9659d694d4..34d4165a2e 100644 --- a/subprojects/gst-libav/ext/libav/gstavvidenc.c +++ b/subprojects/gst-libav/ext/libav/gstavvidenc.c @@ -308,7 +308,9 @@ gst_ffmpegvidenc_set_format (GstVideoEncoder * encoder, * (1<<16) - 1 . We therefore scale them down. * Agreed, it will not be the exact framerate... but the difference * shouldn't be that noticeable */ - ffmpegenc->context->time_base.num = 1; + ffmpegenc->context->time_base.num = + (gint) gst_util_uint64_scale_int (ffmpegenc->context->time_base.num, + 65535, ffmpegenc->context->time_base.den); ffmpegenc->context->time_base.den = 65535; GST_LOG_OBJECT (ffmpegenc, "MPEG4 : scaled down framerate to %d / %d", ffmpegenc->context->time_base.den, ffmpegenc->context->time_base.num);