views:

899

answers:

2

I am looking for a java library that will allow me to "trim" an audio file so that I can pull out and save X amount of seconds of an audio file. Ideally, I am looking for something that would be like a substr for an audio file. If I want from 123 seconds in to 153 seconds in I would be able to do:

coollib.load('bigfile.mp3');    
coollib.trimAudioSeconds(123,30);
coollib.export('newfile.mp3');

I have seen this post:

http://stackoverflow.com/questions/86083/any-good-recommendations-for-mp3sound-libraries-for-java

But it didn't have anything about my substr quest. I am hoping someone has needed this functionality before so they will know exactly what direction to point me.

Thanks!

A: 

I don't know about an existing library, but what you can do is read the file header for bitrate information, then multiply that by the seconds you want to go in, read so many bytes of the file and throw them away. Then you're at the right point to start recording, read so many bytes, and stop.

A regular mp3 library should be able to tell you about bitrate without your having to read the header yourself.

Then there's the problem of variable bitrate files...

Karl
and That's why you had asked for a library that does it, I understand. I just wanted to point out that it shouldn't really be a whole lot of extra work to write in your own functionality.
Karl
A: 

Hi, jack... I am also looking for a java library can editing mp3 files, and I see your questions here. Had you found any library can work? Can you also tell me where can I get that? Thanks for your help..

Allen