Re: [mpg123-users] libmpg123 opens non-mp3 files
Brought to you by:
sobukus
From: Thomas O. <tho...@or...> - 2023-12-20 13:09:28
|
Am Tue, 19 Dec 2023 22:58:06 +0100 schrieb Guido Jäkel via mpg123-users <mpg...@li...>: > I would like to suggest to use the 'file' command to detect the MIME > type of the audio files first. Libmpg123 tries as hard as it can to extract something out of the data you give it. This includes all kinds of weird historically used formats including MPEG data with a leading RIFF header suggesting it's a WAV file. This might confuse the 'file' tool, too. But for regular files that don't try to be funny, where a header for WAV or OGG Vorbis really means that, file, or, respectively, libmagic when used in your own program, is a good way to pre-filter files. MPEG audio is a bit special in that it doesn't specify a container format with clear identification. It's a stream of raw frames and metadata got tacked on later. So maybe it's more sensible to check if it is something else known first, as OGG etal. are easily identified, and only after that throw libmpg123 on it. Oh, you can also just use libsndfile for all your audio reading, as current libsndfile has MP3 read and write support via libmpg123 and liblame. Libmpg123 is for folks who really want to deal with MPEG layer 3 files, possibly including some specifics (like high-efficiency volume scaling or the crude equalizer). Alrighty then, Thomas |