views:

327

answers:

2

Are there any ways to automatically trim an MP3 uploaded to a website to 30 seconds (or some other length) in PHP? If not, is there any good 3rd party services that could be integrated (transparently to the user) to achieve the same effect?

Thanks.

+5  A: 

You could try the MP3 Class on PHPClasses. It features the following example:

require_once './class.mp3.php';
$mp3 = new mp3;
$mp3->cut_mp3('input.mp3', 'output.mp3', 0, -1, 'frame', false);

In this case, the 'frame' can be substituted with 'second' to base the cut on a time-frame.

Jonathan Sampson
+1  A: 

In Debian/ubuntu try installing mpgtx:

apt-get install mpgtx

mptsplit input.mp3 [00:00:00-00:00:30] -o output.mp3

I'm sure you'll find mpgtx available in other fine Linux distros too, or just install from source.

Paul Dixon