audiofile icon indicating copy to clipboard operation
audiofile copied to clipboard

What about MP3 support?

Open alessio opened this issue 13 years ago • 5 comments

Hi Michael,

in the Debian's BTS I've found this old bug: http://bugs.debian.org/101448

What do you think about adding the support for the MP3 format to the next release of audiofile?

alessio avatar Jan 26 '12 14:01 alessio

The Debian BTS patch contains the C code for an MP3 decoder, so is subject to license fees in some jurisdictions.

One way to do this, getting round all the licensing hassle, is to look for external programs like lame or mpg123, and get them to decode the file, presumably starting them up on a pipe as a read-only non(-backwards)-seekable stream. Legally speaking, I presume, if the user has those tools installed, that means they are authorised to use them in their jurisdiction. Either way, libaudiofile is not shipping an MP3 codec.

martinwguy avatar Mar 04 '16 11:03 martinwguy

@martinwguy Would this change once all MP3 patents expire? This link says it's by the end of the year, but it also mentions there might be unknown patents. It will be interesting to see what happens then.

hishamhm avatar May 27 '17 14:05 hishamhm

it's 2019 now

bart9h avatar Oct 16 '19 02:10 bart9h

Hi! I though I'd comment bcos I've had loads of pain over the last year trying to implement MP3 reading in martinwguy/spettro using libsox, libav and libmp3, and all give me noisy, laggy output, or repeat sections. over and over, or stop decodinging half way through. libmp3 is the most sucessful, but still give noisy output sometimes.

I think I am particularly unlucky because I do a lot of seeking in the MP3 file (I have to read it at two different points simultaneously that both advance), and while libsox and libav have been complete disasters for me despite weeks of effort, libmp3 mostly manages to get it right, except with MP2 level 3, presumably because the result from one packet depends on extra data packed into the free space in up to two of preceding packets. Truly a horrible format to decode if you want to be able to seek reliably.

Incidentally, libsndfile has the same issue with the same reply (when patents expire).so it may be worth checking there too.

Unless I can understand what I'm getting wrong, or how to work around it, I'm currently looking at having to decode MP3 always from start to finish and cache the deoded audio, which not only makes huge memory requirements, but meaks that if you, say, want to play the last few bars of an hour-long piece it would have to decode the whole thing.

The real answer is probably "patches are welcome" :) but with my recent experiences I'd be happy to liase with anyone trying to get this work as a tester.

Blessings -M

martinwguy avatar Oct 16 '19 13:10 martinwguy

https://github.com/erikd/libsndfile/issues/258 - has had some activity recently

mxmilkiib avatar Oct 28 '19 19:10 mxmilkiib