Greg Hochmuth
Greg Hochmuth

Reputation: 401

Manipulate MP3 programmatically: Muting certain parts?

I'm trying to write a batch process that can take an MP3 file and mute certain parts of it, ideally in Python or Java.

Take this example: Given a 2 minute MP3, I want to mute the time between 1:20 and 1:30. When saved back to a file, the rest of the MP3 will play normally -- only that portion will be silent.

Any advice for setting this up in a way that's easy to automate/run on the command line would be fantastic!

Upvotes: 5

Views: 1793

Answers (4)

Daniel Mošmondor
Daniel Mošmondor

Reputation: 19956

One (somehow pretentious) idea: record a mute (silent) mp3 in bitrate that your mp3 is. Then, copy all the frames from original mp3 up to the point when you want your silence to start. Then, copy as much muted frames you need from your 'silence file'. Then, copy the rest from the original file.

You'll have muted file without re-encoding the file!

Upvotes: 1

Art Clarke
Art Clarke

Reputation: 2505

Or use Xuggler to decode the MP3 file, mute out the audio you care about, and then re-encode.

Upvotes: 0

Nosredna
Nosredna

Reputation: 86236

Audacity (available for Windows, Mac, Linux) has a plugin (currently for Windows only) that allows it to be scripted. The target language is Perl, but perhaps Python would work.

There's also a built-in XLisp interpreter called Nyquist.

Upvotes: 0

Al.
Al.

Reputation: 2872

SoX is a multi-platform sound editing tool and I've used it a lot in the past. More info at http://sox.sourceforge.net/

I don't think you can mute a section of an MP3 file with a single command though. You could split the file into 3 parts, mute the middle part, then stitch them together again.

Hope that helps

Upvotes: 2

Related Questions