#1104479 file: detect MP3 files created by LAME

Package:
file
Source:
file
Description:
Recognize the type of data in a file using "magic" numbers
Submitter:
Frank Heckenbach
Date:
2026-05-15 22:09:02 UTC
Severity:
normal
Tags:
#1104479#5
Date:
2025-04-30 21:27:59 UTC
From:
To:
I got some MP3 files which were apparently created by LAME that
"file" detects only as "data".

I'm not completely sure if the files are valid, but apparently they
are generated like this, and "ffprobe" and "mpv" do recognize them.

I can't attach the full files because of copyright, but I'm
attaching the header of one which should be enough.

AFAICS, the issue is that the magic bytes are not at the start of
the file, but at offset 0x1a1 after some NUL bytes. I don't know if
this offset is fixed or variable, but it seems to be the same for
all the files I've got.

So the following entry (copied from the original with just the
offsets changed) recognizes all of these files:

0x1a1       beshort&0xFFFE  0xFFFA
# rates
!:strength +20
!:mime	audio/mpeg

#1104479#10
Date:
2026-05-15 22:08:20 UTC
From:
To:
Frank Heckenbach wrote...
(...)

It's been a while, and the problem is still there :-|

It seems MPEG frames have a fixed size of 0x1a1 octets and so possibly
lame preprended an empty one, for whatever reason. From earlier
experience, players are fairly robust against data weirdness, hence this
still worked for you.

While I could bring this upstream, I'd still like to learn more about
what happened here. Were you able to reproduce lame's behaviour with
arbitrary input?

    Christoph