I understand that the r_frame_rate is the lowest framerate with which all
timestamps can be represented accurately. And I know it is just a guess. But
why did the logic behind the calculation change?
Changes between 6.0 and 6.1:
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2864,15 +2872,12 @@ int avformat_find_stream_info(AVFormatContext *ic,
AVDictionary **options)
- 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);
+ const AVCodecDescriptor *desc = sti->codec_desc;
+ AVRational mul = (AVRational){ desc && (desc->props &
AV_CODEC_PROP_FIELDS) ? 2 : 1, 1 };
+ AVRational fr = av_mul_q(avctx->framerate, mul);
+ if (fr.num && fr.den && av_cmp_q(st->time_base, av_inv_q(fr)) <= 0) {
+ st->r_frame_rate = fr;
} else {
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
Proposed changes:
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 6f640b92b1..9d58b440a9 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2876,7 +2876,8 @@ int avformat_find_stream_info(AVFormatContext *ic,
AVDictionary **options)
AVRational fr = av_mul_q(avctx->framerate, mul);
if (fr.num && fr.den && av_cmp_q(st->time_base, av_inv_q(fr))
<= 0) {
- st->r_frame_rate = fr;
+ av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den,
+ fr.num, (int64_t)fr.den * mul.num, INT_MAX);
} else {
st->r_frame_rate.num = st->time_base.den;
st->r_frame_rate.den = st->time_base.num;
Antoni Bizoń
________________________________
From: ffmpeg-devel <[email protected]> on behalf of Anton Khirnov
<[email protected]>
Sent: Sunday, September 15, 2024 2:41 PM
To: [email protected] <[email protected]>
Subject: Re: [FFmpeg-devel] A change in r_frame_rate values after upgrade to
FFmpeg 6.1
Quoting Antoni Bizoń (2024-09-13 15:20:16)
> Hello,
> I recently upgraded FFmpeg to version 6.1 in my web application and
> encountered a change while running my app's tests. After the upgrade,
> ffprobe reported an r_frame_rate of 60/1 instead of the expected 30/1
> for two videos in my test suite.
r_frame_rate does not mean what you probably think it means, and is
actually NOT guaranteed to be a frame rate of anything. See if
avg_frame_rate doesn't work better.
--
Anton Khirnov
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".