Bug fix of wrong video fps 77/303477/3
authorhjkim <backto.kim@samsung.com>
Thu, 28 Dec 2023 07:23:09 +0000 (16:23 +0900)
committerhjkim <backto.kim@samsung.com>
Thu, 11 Jan 2024 02:23:16 +0000 (11:23 +0900)
Change-Id: I62fb8d0db9712ed7e9a56ab0bcb1ffe90711f93a

libavformat/demux.c
packaging/ffmpeg.spec

index 6f640b9..290f220 100644 (file)
@@ -2870,6 +2870,24 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                     av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
                               best_fps, 12 * 1001, INT_MAX);
             }
+
+#ifdef __TIZEN__ //code from ffmpeg 6.0 to fix wrong fps.
+            if (!st->r_frame_rate.num) {
+                AVRational time_base = avctx->framerate.num ? av_inv_q(av_mul_q(avctx->framerate,
+                                                                       (AVRational){avctx->ticks_per_frame, 1}))
+                                                            /* NOHEADER check added to not break existing behavior */
+                                                            : ((ic->ctx_flags & AVFMTCTX_NOHEADER) ? (AVRational){0, 1}
+                                                                                                   : st->time_base);
+                if (   time_base.den * (int64_t) st->time_base.num
+                    <= time_base.num * (uint64_t)avctx->ticks_per_frame * st->time_base.den) {
+                    av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,
+                              time_base.den, (int64_t)time_base.num * avctx->ticks_per_frame, INT_MAX);
+                } else {
+                    st->r_frame_rate.num = st->time_base.den;
+                    st->r_frame_rate.den = st->time_base.num;
+                }
+            }
+#else
             if (!st->r_frame_rate.num) {
                 const AVCodecDescriptor *desc = sti->codec_desc;
                 AVRational mul = (AVRational){ desc && (desc->props & AV_CODEC_PROP_FIELDS) ? 2 : 1, 1 };
@@ -2882,6 +2900,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                     st->r_frame_rate.den = st->time_base.num;
                 }
             }
+#endif
             st->codecpar->framerate = avctx->framerate;
             if (sti->display_aspect_ratio.num && sti->display_aspect_ratio.den) {
                 AVRational hw_ratio = { avctx->height, avctx->width };
index 86b9d21..bf0d40c 100644 (file)
@@ -1,7 +1,7 @@
 Name:       ffmpeg
 Summary:    AV codec lib
 Version:    6.1
-Release:    0
+Release:    1
 Group:      Multimedia/Libraries
 URL:        https://ffmpeg.org/
 License:    LGPL-2.1+