3

i want to achieve mp3 compression.. it means i want to convert a 256kbps mp3 file into a 128 or even 64kbps mp3 file using java programming language..

is it possible using JLayer..? how do i do it..?

A code snippet would be useful

Starx
  • 77,474
  • 47
  • 185
  • 261
veenit33
  • 79
  • 2
  • 8

4 Answers4

3

To convert an MP3 file to a file of lower bitrate, you must decode and re-encode the file, so you need an MP3 decoder and an MP3 encoder.

You'll have to find a Java library for de/encoding MP3. One option would be LameOnJ. It's a wrapper for the "lame" MP3 encoder, and uses a platform-specific binary/DLL.

There might also be a pure Java solution, but I don't know any.

See also MP3 Encoding in Java

Community
  • 1
  • 1
sleske
  • 81,358
  • 34
  • 189
  • 227
2

Decoding MP3 is straightforward. However, encoding MP3 is fraught with patents, licenses, and general legal mayhem. LAME is one possibility to adapt, but it too suffers from potential litigation encumbrances. It is also known to be poor at lower bit rates. It is written in C, so you'd have to do translation.

wallyk
  • 56,922
  • 16
  • 83
  • 148
  • You could use Java Native Access (JNA). It's a fairly easy way to access C libraries from Java. And by "fairly easy" I mean you just write an Interface and include the jna.jar file. –  Jan 11 '10 at 20:52
  • @Greg: Actually, LameOnJ (see my answer) is precisely a Java wrapper for the "lame" library, so no need to use JNA directly (though it would be possible). – sleske Jan 11 '10 at 22:11
  • It's a common mistake to believe that MP3 encoding is "straightforward". License fees are due to the patent consortium both for decoders and encoders. The basic rates start at US$ 0.75 for a software decoder and US$ 2.50 for an encoder (decoder license included). – jarnbjo Jan 11 '10 at 22:26
  • patents ended 2017 – Sam Ginrich Jan 18 '22 at 14:52
1

JLayer is decoding only. There is no 100% java solution for encoding. LAME is officially distributed in source code only, so if you want to avoid patent infrigement, you can not distribute LAME binaries with your program without buying a license.

Denis Tulskiy
  • 19,012
  • 6
  • 50
  • 68
1

If you are searching for a pure java version of lame, check out these sources: http://jsidplay2.cvs.sourceforge.net/viewvc/jsidplay2/jump3r/

kenchis
  • 29
  • 1