Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: decode mp3

I need to decode an MP3 file with Python. What is a good library which can do that?

I looked at PyMedia but the project seems dead and it didn't worked on MacOSX. Then I found out about pyffmpeg but I didn't got it working on MacOSX so far.

Any suggestion?

like image 360
Albert Avatar asked Dec 04 '10 17:12

Albert


4 Answers

I did try an easy_install of PyMedia on OS X / Fink, and it did not work because it could not find the source. This module does look quite dead…

One way of decoding MP3 is to call ffmpeg without going through pyffmpeg, but by calling ffmpeg using the standard subprocess module instead.

like image 84
Eric O Lebigot Avatar answered Nov 17 '22 20:11

Eric O Lebigot


You really need an external library. It'd be very difficult to do in Python with any sort of speed - see How to convert MP3 to WAV in Python for some discussion.

How about python-mad? MAD being the 'mpeg audio decoder'; there's a python library. It'd give you the audio data. Never used it myself...

like image 39
Robert Avatar answered Nov 17 '22 21:11

Robert


I decided to code this myself based on subprocess and ffmpeg.

Some code can be found here: https://github.com/albertz/learn-midi/blob/master/decode.py

like image 1
Albert Avatar answered Nov 17 '22 21:11

Albert


Please try https://github.com/sampsyo/audioread

It's fast, installs from pypi and works well

like image 1
Yuri Baburov Avatar answered Nov 17 '22 20:11

Yuri Baburov