Skip to main content

Module mpeg

Module mpeg 

Source
Expand description

MP3 stream info the way mutagen computes it. A transcription of mutagen.mp3.MPEGInfo and mutagen.mp3._util.

The Python pipeline reads durations and bit rates from mutagen headers, not from a decode, and mutagen disagrees with ffprobe on roughly one file in six of the real library (encoder delay handling, LAME padding, CBR estimates). A report that says 2.4s where Python says 2.5s fails parity, so the arithmetic here follows mutagen line for line, including its file-size fallback and its half-to-even bit rate rounding.

StructsΒ§

Frame πŸ”’
One parsed frame header plus whatever the Xing/VBRI/LAME tags in it said. length is None where mutagen leaves the attribute unset.
MpegInfo
MPEGInfo’s useful attributes.
Xing πŸ”’

EnumsΒ§

MpegError
What mutagen raises, by the name Python code prints via type(exc).__name__ β€” that name reaches CSV output in sfx-impact.
Version πŸ”’

FunctionsΒ§

bitrate_table πŸ”’
Per-(version, layer) bit rate tables in kbps, index by the 4-bit field.
clone_frame πŸ”’
duration_ms
_mp3_duration_ms: int(info.length * 1000).
info
MP3(path).info.
info_from
MPEGInfo(fileobj): sync to the first believable frame run and derive length and bit rate from it.
intround πŸ”’
intround: Decimal.from_float(v).to_integral_value(ROUND_HALF_EVEN).
parse_frame πŸ”’
Parse the frame at pos. None is mutagen’s HeaderNotFoundError.
parse_lame πŸ”’
LAMEHeader.parse_version + the two fields of LAMEHeader the length needs. None wherever mutagen raises LAMEError or reports no extended header.
parse_vbr_header πŸ”’
A Xing/Info tag trumps the header’s bit rate and gives a real length; failing that, a Fraunhofer VBRI tag. Neither raises.
parse_vbri πŸ”’
VBRIHeader: (bytes, frames) when a valid tag sits at pos.
parse_xing πŸ”’
read_exact_at πŸ”’
sample_rates πŸ”’
skip_id3 πŸ”’
skip_id3: step over every leading ID3 tag (WMP stacks them).
u16be πŸ”’
u32be πŸ”’