MP3 decoder module?

P

Paul Rubin

Anyone know of a reasonable mp3 decoder library I can call from
Python? Some Googling didn't find anything too promising. It found
Pymedia (which plays mp3's through a sound system) and any number of
utilities that parse ID3 tags and other metadata. But I want to
actually decode the mp3 frames and crunch on the audio samples.
Basically I want to write a program that takes an mp3 audio file and
finds the silent frames, with the idea of chopping the file into
segments at those points automatically, or compressing the silences
out of spoken audio to make it play faster without chipmunking up the
pitch, etc. Of course if you know of something that does this stuff
already, that can help too.

I think I don't need mp3 encoding, just decoding. I want to decode
and recognize certain frames and chop them out, but the non-chopped
frames will be copied verbatim to avoid quality loss from re-encoding.

Thanks.
 
P

Paul Rubin

Paul Rubin said:
Basically I want to write a program that takes an mp3 audio file and
finds the silent frames, with the idea of chopping the file into
segments at those points automatically, or compressing the silences
out of spoken audio to make it play faster without chipmunking up the
pitch, etc. Of course if you know of something that does this stuff
already, that can help too.

I should add: I prefer not to expand the entire file to WAV and crunch
on that. This is partly because I want to look for silences in
specific places in the mp3 without having to decode the whole file,
partly because I still need to know where the original mp3 frames are
in the file. For the actual files I want to crunch, I don't need to
handle VBR, but it would be nice to support it just from the point of
view of doing things right.
 
T

Terry Carroll

Paul said:
Anyone know of a reasonable mp3 decoder library I can call from
Python? Some Googling didn't find anything too promising. It found
Pymedia (which plays mp3's through a sound system).... But I want to
actually decode the mp3 frames and crunch on the audio samples.

As I read the Pymedia docs, you can use it to decode frames from an MP3,
and operate on the decoded sound data.

See http://pymedia.org/tut/dump_wav.html for a discussion.
 
P

Paul Rubin

Terry Carroll said:
As I read the Pymedia docs, you can use it to decode frames from an
MP3, and operate on the decoded sound data.

See http://pymedia.org/tut/dump_wav.html for a discussion.

Hmm, thanks, it looks like there's more there than I thought at first,
tough still pretty confusing. I'll look at it some more. Meanwhile
I'm just doing a semi-manual kludge, looking at a file visually with
audacity to figure out the chop point, then chopping all similar files
(I have a bunch of sets of files that are related to each other and
use the same chop points) with file.truncate. This is extremely fast
but seems to sometimes cut an mp3 frame in the middle. So I'd like to
figure out more accurately where the exact frame boundaries are.
Chopping in the middle gets a harmless error message from the mpg123
software decoder but might have some worse effect with a hardware
decoder. I have some cheap portable players that I can try it on but
I haven't done that yet.

I'm surprised there's not more code like this around.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top