Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MP3 support #258

Closed
erikd opened this issue May 6, 2017 · 69 comments
Closed

Add MP3 support #258

erikd opened this issue May 6, 2017 · 69 comments
Labels
help wanted Extra attention is needed Wishlist

Comments

@erikd
Copy link
Member

erikd commented May 6, 2017

The MP3 patents have now fully expired so libsndfile can now add support.

The best bet would be https://www.mpg123.de which is LGPL and has updates as recently as this year.

I (@erikd) don't have sufficient time and motivation to do this, but would be happy to guide someone else.

@evpobr
Copy link
Member

evpobr commented May 7, 2017

Milestone?

@erikd
Copy link
Member Author

erikd commented May 7, 2017

Until some actually steps forward to offer to do this and actually has some code that is worth reviewing, it doesn't make sense to have a milestone.

@dabfalcon
Copy link

I hope someone steps forward and this feature would be great.

@erikd
Copy link
Member Author

erikd commented May 10, 2017

It also seems that https://www.mpg123.de is a decoder only. All the other supported formats have both encode and decode so that would have to be the same for MP3 especially fore the CSound use case.

liblame may be the best bet.

@evpobr
Copy link
Member

evpobr commented May 10, 2017

Agreed, mpg123 and LAME are the best.

Bad thing i will be buzy all the summer.

@dabfalcon
Copy link

Bad thing I'm too n00b. How hard is it?
I'm good with PHP / web / did a course on C++.

@erikd
Copy link
Member Author

erikd commented May 11, 2017

This is definitely more difficult than using libsndfile as a library, mainly because the libsndfile API was specifically designed to be easy to use.

I would also rank this as more difficult than adding Opus support, because it requires you to hook up two libraries, one for decoding and one for encoding.

@faroit
Copy link

faroit commented May 18, 2017

Also interesting, from this recent statement:

However, the end of the mp3 licensing program does not automatically mean that all mp3 technology is available license-free now. Apart from the core mp3 patents included in the licensing program, there might still be some implementation–specific patents (or patents for other functional enhancements) that have not expired. Thus, manufacturers will have to check the situation regarding their intended products first before including mp3.

@jpffitch
Copy link

jpffitch commented Jun 4, 2017

uuuuuuIn csound at present we use a Russian library libmpadec for reading. Seems OK. Is it worth investigating? I should add that it has not been changed by the author for years but i have tweaked it, and have developer status for it. Code in csound tree and on sourceforge

@jpffitch
Copy link

jpffitch commented Jun 8, 2017

Is there a template for adding a new format or does one just edit, say, ogg.c to new code? Some time since I last tried (10 years) and things have changed.

@erikd
Copy link
Member Author

erikd commented Jun 8, 2017

Closest thing to a template is src/new.c.

@eblanca
Copy link

eblanca commented Jun 13, 2017

For a wider view, i see on the decoding side there's much more: there is libmad which is very VERY stable and currently many distributions still provide it, not to mention its feature being based only on integer number calculation. This makes it very suitable for embedded systems, imho.
On the other hand, the writing/encoding side also offers many names to pick. If libsndfile will be able to read mpeg layer1/2/3 audio, then why offering layer3-only encoding? libtwolame provides layer2 encoding (layer2 is very often used even today, both into DVDs and into DVB streams) and for layer1, well, perhaps it may be also evaluated.

@jpffitch
Copy link

Does the licence matter? GPL v LGPL ? With so many options I feel the need for guidance.

The mpg123 +lame plan looks like the mainsteam way to go, but I do not claim expertise in MP3.

@erikd
Copy link
Member Author

erikd commented Jun 13, 2017

GPL is no good, but LGPL, BSD, MIT would all be fine.

@rjamorim
Copy link

not to mention its feature being based only on integer number calculation. This makes it very suitable for embedded systems, imho.

mpg123 can be built to perform only fixed-point math, and with better performance than MAD according to Thomas Orgis. Also, mpg123 has assembly optimizations for several architectures and SIMD flavors.

@eblanca
Copy link

eblanca commented Jul 4, 2017

mpg123 can be built to perform only fixed-point math

Didn't know this, great!

@cvanwinkle
Copy link

FWIW, I've used mpg123 under LGPL in my program for MPEG-2 Audio Layer II decoding (aka MP2 audio) for a while and have validated that it decodes MP3 to my liking although we don't use it for that. So one nice thing about mpg123 is that it can decode several layers of MPEG audio and not just what is known as MP3. So assuming someone else does the work for wiring in mpg123 other than me (which is likely), it would be good to accommodate the other flavors as well.

@erikd
Copy link
Member Author

erikd commented Jul 31, 2017

All the other formats supported by libsndfile support decoding and encoding. As I understand it mpg123 only does decoding, so something else will have to be used for the encoder, probably liblame.

@rjamorim
Copy link

rjamorim commented Aug 1, 2017

Hello, Erik. Indeed, mpg123 only does decoding, and I strongly support using LAME for encoding. Back in 2004 I conduced a public listening test, and LAME got the best ranking (granted, it was a long time ago, but neither of the other encoders advanced much since then)
https://web.archive.org/web/20071016053926/http://www.rjamorim.com:80/test/mp3-128/results.html

Also, another reason I thought for choosing mpg123 over MAD (besides the licensing issue): MAD was last updated in 2004. mpg123 was last updated last week and the developer, Thomas Orgis, is very approachable.

@foolswood
Copy link
Contributor

foolswood commented Aug 3, 2017

I am happy to have a go at this (unless someone else has started, in which case let me know).

@foolswood
Copy link
Contributor

foolswood commented Aug 4, 2017

Made a start (not working yet) over here: https://github.com/concert/libsndfile/tree/mp3.

Thinking about RDWR, that might be a bit tricky with the lame/mpg123 split, any thoughts on that (otherwise I might leave that mode unimplemented in the first attempt).

@foolswood
Copy link
Contributor

foolswood commented Sep 20, 2017

Read support PR is #322. At the moment I'm after shape review to see if I'm on the right track but hopefully it makes at least some sense :)

@foolswood
Copy link
Contributor

Lame can use libsndfile for opening its input formats, so I'm concerned that using it as a decoder for libsndfile introduces a dependency loop. If lame were to split into liblame and the lame frontend (as I believe it is the latter that has the dependency) that would break the cycle. However given that's a big change and the last release was in 2012 I don't think that's likely.

Suggestions welcome.

@define-private-public
Copy link

define-private-public commented Dec 14, 2019

I'd also like to voice my thanks for working on this. I'm created (as far as I know so far), the only cross platform audio loading and playback library for C#/.NET core and I'm using libsndfile right now for all of the media format decoding. (It's called Basoon BTW) I was looking to use MP3Sharp to do MP3 decoding. But if I can get MP3 decoding w/ out having to add an extra project, that is super.

@cd-jcroome
Copy link

Hey guys, just checking in on this. How's it going? Any tricky blockers or tasks you want to off-load? Echoing the many thanks you've received on your work already.

@jpffitch
Copy link

jpffitch commented Apr 22, 2020 via email

@marcusmueller
Copy link

@jpffitch is your current progress visible somewhere? That would enable me to test, and possibly, improve.

@jpffitch
Copy link

jpffitch commented Jun 22, 2020 via email

@martinwguy
Copy link

martinwguy commented Jun 22, 2020 via email

@csukuangfj
Copy link

Is there any plan to merge https://github.com/arthurt/libsndfile.git ?

@robinbernon
Copy link

How's it going?

@AngledLuffa
Copy link

Any progress on this? Could really use this for a personal project of mine.

@martinwguy
Copy link

martinwguy commented Oct 4, 2020

It's unlikely to be included in the master branch soon, as there are still some technical problems to be ironed out. Even when it is technically sound, it will then take some years before it appears in mainline distributions due to the infrequency of Erik's new releases and the extra years it then takes for the distributions to catch up with him.

For your own project, I suggest you just install arthurt's mpeg-support or mp3-codec branch and use that. If you subsequently decide to publish your work, the best strategy woud be to include a custom copy of libsndfile in your source tree and compile against that. Alternatively, you could use one of the existing decoding libraries for MP3 files, of which libmpg123 is the only one I've found that is able to seek in MP3 files to the accuracy of one sample, in case you need that.

@evpobr
Copy link
Member

evpobr commented Oct 4, 2020

#499 (comment)

@randomMesh
Copy link

Looking forward to this. Thumbs up!

@Nelson-numerical-software

Could we consider that this issue is closed with 1.1.0 ? :)

@evpobr
Copy link
Member

evpobr commented May 4, 2022

I guess so 😄

@evpobr evpobr closed this as completed May 4, 2022
@AngledLuffa
Copy link

Thank you everyone! I'm very happy to be able to use this once my work gives me a moment's break

@martinwguy
Copy link

martinwguy commented May 4, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed Wishlist
Projects
None yet
Development

No branches or pull requests