Discussion:
[SoX-devel] libmagic for MP3 can go horribly wrong
Reuben Thomas
2008-11-06 21:18:08 UTC
Permalink
Hi,

your friendly upstream file maintainer here.

I've just been scratching my head over why some Oggs won't play, and I get
"MAD decode errors". "This isn't just MAD, it's MENTAL!" I'm thinking.

Turns out the problem is that libmagic thinks that anything with ID3 tags
must be MPEG. Now, I can fix this, but you can't, so I suggest that you use
the file suffix first, and only use libmagic if that fails.

An aside: I tried to workaround by going:

play -t ogg *.ogg

but that didn't work. Is that intended? It didn't even play the first file
(there were 20 or so).

Suggestion: whenever you do identify something with libmagic, say so in the
output.
--
http://rrt.sc3d.org/ | fiction, n. fact without citations
robs
2008-11-06 22:48:34 UTC
Permalink
Post by Reuben Thomas
Turns out the problem is that libmagic thinks that anything
with ID3 tags
must be MPEG. Now, I can fix this, but you can't, so I
suggest that you use
the file suffix first, and only use libmagic if that fails.
I'm afraid it's long established SoX behaviour that auto-detection has higher precedence than the file suffix, so difficult to change that now.
Post by Reuben Thomas
play -t ogg *.ogg
-t should have precedence over anything else, i.e. in this case the vorbis handler should be invoked. If the file does not play then I think this means the handler believes it's not a valid source. I get this error in this case:
sox formats: can't open input file `1.flac': Input not an Ogg Vorbis audio stream
Post by Reuben Thomas
Suggestion: whenever you do identify something with
libmagic, say so in the
output.
As we're on the verge of releasing 14.2.0, I suggest we disable libmagic by default in configure.ac.

/Rob
Reuben Thomas
2008-11-06 23:00:50 UTC
Permalink
Post by robs
Post by Reuben Thomas
Turns out the problem is that libmagic thinks that anything
with ID3 tags
must be MPEG. Now, I can fix this, but you can't, so I
suggest that you use
the file suffix first, and only use libmagic if that fails.
I'm afraid it's long established SoX behaviour that auto-detection has higher precedence than the file suffix, so difficult to change that now.
Post by Reuben Thomas
play -t ogg *.ogg
Well, in my case it still gave errors about MP3 until I fixed file. Does the
-t only apply to the first file?
Post by robs
As we're on the verge of releasing 14.2.0, I suggest we disable libmagic
by default in configure.ac.
I concur. Great news about the release.
--
http://rrt.sc3d.org/ | historian, n. a broad-gauge gossip (Bierce)
robs
2008-11-06 23:05:24 UTC
Permalink
Post by Reuben Thomas
Post by Reuben Thomas
play -t ogg *.ogg
Well, in my case it still gave errors about MP3 until I
fixed file. Does the -t only apply to the first file?
Ah yes, of course. Maybe we need a stronger -t, say -T, that applies to all files to its right.
Reuben Thomas
2008-11-06 23:09:28 UTC
Permalink
Post by robs
Post by Reuben Thomas
Post by Reuben Thomas
play -t ogg *.ogg
Well, in my case it still gave errors about MP3 until I
fixed file. Does the -t only apply to the first file?
Ah yes, of course. Maybe we need a stronger -t, say -T, that applies to all files to its right.
It's a bit of a pain really. SoX can't know that I said "*.ogg". I would
prefer something a bit more general, a way of setting "global" options. It's
a pity that one can't just use the left-most position for that, and have
options for a particular file to that file's right. It wouldn't be logical,
but it would be backwards-compatible to have global options at the far
right, only of course not so convenient for e.g. xargs or other programmatic
usage. Maybe something like

--globalopts="..."

which caused the options parser to be re-entered with a "global" flag set?

Ach, it's all starting to sound rather complicated...
--
http://rrt.sc3d.org/ | poetry, n. platitude made obscure
Loading...