Skip to content

MP3: detect headerless VBR after parsing finishes - #2633

Open
bernardwiesner wants to merge 1 commit into
MediaArea:masterfrom
bernardwiesner:fix/mp3-headerless-vbr-detection
Open

MP3: detect headerless VBR after parsing finishes#2633
bernardwiesner wants to merge 1 commit into
MediaArea:masterfrom
bernardwiesner:fix/mp3-headerless-vbr-detection

Conversation

@bernardwiesner

@bernardwiesner bernardwiesner commented Jun 2, 2026

Copy link
Copy Markdown

Headerless MP3 with late bitrate change is incorrectly reported as CBR

MediaInfoLib reports a headerless MP3 as CBR when its first frames use one bitrate but later frames use different bitrates.

This occurs with both the default ParseSpeed and ParseSpeed=1.0.

Reproduction

Use an MP3 without Xing, Info, or VBRI metadata. The file should begin with CBR frames and switch to VBR frames later.

Example fixture structure:

  • First 30 seconds: CBR MP3 at 128 kbps
  • Final 30 seconds: VBR MP3
  • No Xing, Info, or VBRI header

kalimba_60s_cbr_then_vbr_no_xing.mp3

Run:

mediainfo --Output=JSON kalimba_60s_cbr_then_vbr_no_xing.mp3

The audio stream reports:
"BitRate_Mode": "CBR"

Expected result:
"BitRate_Mode": "VBR"

Problem

File_Mpega::Streams_Fill() detects headerless VBR files by checking whether more than one bitrate has been observed:

if (BitRate_Count.size()>1)
    BitRate_Mode=__T("VBR");

This check runs after the initial frames are parsed. If those frames all use the same bitrate, the stream is initially classified as CBR.

Later frames continue to update BitRate_Count, including frames inspected after the default tail seek. However, the bitrate mode is not re-evaluated during finalization.

As a result, a headerless MP3 that begins with CBR frames and changes bitrate later can incorrectly remain classified as CBR.

@bernardwiesner
bernardwiesner force-pushed the fix/mp3-headerless-vbr-detection branch from 22edc6a to 02ac14e Compare June 2, 2026 05:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant