Mp3 Ogg

I've had to re-encode mp3 file to ogg and edit a few files to make a few games work. My pygame doesn't seem to allow mp3s. Am I the only one?

(log in to comment)

Comments

I've had this problem as well, as Pygame doesn't seem to get along nicely with MP3s for whatever reason. Converting them is usually the right way to go, as I've had to convert MP3s quite a bit for a lot of Games I've built with Pygame, and almost every time the sounds were able to load and play just fine.

MP3 support is optional in Pygame, and whether you have the support depends on the way you obtain Pygame. Debian for example never included MP3 support, because MP3 was patented, and Debian has strict freedom guarantees (DFSG) but the patent has now expired so I don't know the current situation.

Have to tried installing the latest PyGame from Wheels? I think the wheels are built with MP3 support.

Ogg is safer because it isn't patent-encumbered so it is available in most builds of Pygame.

Pygame 1.9.5 shipped without MP3 support in the wheels, afaict. I have opened an issue about this.
A few notes on sound formats and pygame...

ogg is probably the safest format to use. Various old versions of SDL_mixer had .ogg related issues (as in 10 years ago). But I'm pretty sure those are fixed now too.

The prerelease of pygame has better mp3 support. pygame 1.9.x use this 'smpeg' library for mp3 which was apparently 'quasi legal' pre-patent expiration. But only certain mp3 files actually worked with `smpeg`.
pip install pygame==2.0.0.dev3
Additionally, the pygame 2 mixer is of better quality (better resampling of sound formats to user hardware for example).

Unfortunately .flac format seems buggy on at least the windows pygame binaries currently (for pygame 2 only).
Using 32bit float .wav files has issues with older SDL versions (like pygame in Debian).