Opened 2 months ago

Last modified 5 weeks ago

#11195 new defect

AVC in MXF container calculates incorrect avg_frame_rate

Reported by: ariley Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

The AVC essence is interlaced 29.97hz, but ffprobe says the essence is 14.99fps -- half what is expected:

$ ./ffprobe mxf_avc_incorrect_fps.mxf 
ffprobe version N-117011-gbb91425eb8 Copyright (c) 2007-2024 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-14)
  configuration: --extra-cflags=-g --extra-cxxflags=-g --optflags=-O0
  libavutil      59. 36.100 / 59. 36.100
  libavcodec     61. 13.100 / 61. 13.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.101 / 61.  2.101
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
[mxf @ 0x5606f2464640] index entry 102 + TemporalOffset 127 = 229, which is out of bounds
Input #0, mxf, from 'mxf_avc_incorrect_fps.mxf':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010100
    uid             : 28d57eae-5674-1f1e-91b8-00d028174ef2
    generation_uid  : 32d57eae-5674-1f1e-bd28-00d028174ef2
    company_name    : Omneon Inc.
    product_name    : Omneon Media Subsystem
    modification_date: 2024-09-16T18:08:31.532000Z
    product_version : SB Release 10.2.0.0-eng.3892 (trunk)
    product_version_num: 10.2.0.0.1
    application_platform: Omneon Media Api (mqx)    
    product_uid     : 00000000-0000-1000-8000-050e0b010602
    material_package_umid: 0x060A2B34010101050101062313000BF28ED87EAE56741F1E837500D028174EF2
    timecode        : 00:00:00:00
  Duration: 00:00:03.34, start: 0.000000, bitrate: 13501 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 14.99 fps, 29.97 tbr, 29.97 tbn
      Metadata:
        file_package_umid: 0x060A2B34010101050101062313004C3738D97EAE56741F1E9FF700D028174EF2

I've tested various versions as far back as 4.1, all of them reporting the same 14.99fps.

It seems like avformat_find_stream_info() is miscalculating the value of sti->info->codec_info_duration_fields:

2806             if (pkt->duration > 0) { 
2807                 const int fields = sti->codec_desc && (sti->codec_desc->props & AV_CODEC_PROP_FIELDS);
2808                 if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && st->start_time != AV_NOPTS_VALUE && pkt->pts >= st->start_time
2809                     && (uint64_t)pkt->pts - st->start_time < INT64_MAX
2810                 ) { 
2811                     sti->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, sti->info->codec_info_duration + pkt->duration);
2812                 } else
2813                     sti->info->codec_info_duration += pkt->duration;
2814                 sti->info->codec_info_duration_fields += sti->parser && sti->need_parsing && fields
2815                                                          ? sti->parser->repeat_pict + 1 : 2;
2816             } 

fields is always 1, and sti->parser->repeat_pict is always 0, leading to sti->info->codec_info_duration_fields having the same value as sti->info->codec_info_duration. Then, when we get here (where time_base==1001/30000):

2924                 av_reduce(&st->avg_frame_rate.num, &st->avg_frame_rate.den,
2925                           sti->info->codec_info_duration_fields * (int64_t) st->time_base.den,
2926                           sti->info->codec_info_duration * 2 * (int64_t) st->time_base.num, 60000);

the avg_frame_rate ends up being half what it should (15000/1001).

Change History (1)

comment:1 by syehoonkim, 5 weeks ago

With this issue, ffmpeg now cannot remux such AVC mxf files.
Before ffmpeg version N-117457-gb33f02c777-g1cead90292+3, at least I could remux AVC mxf files, although with problems.(See #10832, #9571, #9647)

Note: See TracTickets for help on using tickets.