Can Java trim MP3 files?

T

totoromacau

I am not skillful in Java. I wish to create an MP3 player as well
include a function that can trim an MP3 file according to the time I
specify, e.g. cut the MP3 starting from 02:15:43. Does anyone know how
or can you give me some reference or sample?

Thanks.
 
O

Oliver Wong

[replying to the subject line]

Yes, it's possible to write a program which trims mp3 files in Java. It
might not be easy however.
I am not skillful in Java. I wish to create an MP3 player as well
include a function that can trim an MP3 file according to the time I
specify, e.g. cut the MP3 starting from 02:15:43. Does anyone know how
or can you give me some reference or sample?

Are you skillful at programming in general? You'd have to learn the mp3
file format, and do the appropriate manipulations. You can read some
documentation at http://mpgedit.org/mpgedit/mpeg_format/MP3Format.html it
sounds like it's way above your head, you might want to start on an easier
project before tackling this one.

- Oliver
 
G

Greg Miller

I am not skillful in Java. I wish to create an MP3 player as well
include a function that can trim an MP3 file according to the time I
specify, e.g. cut the MP3 starting from 02:15:43. Does anyone know how
or can you give me some reference or sample?

I don't believe there are any native (free) libraries to do it
from Java, but you could build a wrapper around LAME:
http://lame.sourceforge.net/
 
J

jmcgill

Greg said:
I don't believe there are any native (free) libraries to do it
from Java, but you could build a wrapper around LAME:
http://lame.sourceforge.net/

Be aware that MP3 can only be edited in blocks, and cuts are not
possible with much precision. The best you can do is a single "frame",
144 * BitRate / (SampleRate + Padding).

To do what you want to do, you'll have to first analyze the encoding,
and then figure out in frames where you want to decode. It is really
the same problem as implementing fast-forward/rewind in a player.

Here's an implementation of mpeg decoding.

http://www.mp3-tech.org/programmer/sources/JavaLayer0.0.8.tar.gz
 

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

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top