简体   繁体   中英

Using Tritonus AudioSystem: Convert PCM byte[] array to mp3 byte[] array

One of the libraries in my audio project continually outputs a byte[] array stream of PCM audio (along with a length and offset integer). I'm learning to use the Tritonus implementation of the Java Sound API to encode this PCM stream into mp3.

The Java Sound API provides an converted/encoded byte[] array via an AudioInputStream (created by 1) an encoder (courtesy of Tritonus) 2)the PCM InputStream).

But i'd rather just a use simple function this like this:

convertPCMToMp3(byte[] samples, int offset, int length)
{
 // convert the samples to mp3
 // return byte[] encodedsamples int offset int length
}

Does such exist in the Java Sound API?

If not, I'll probably just use one of these ByteBuffer-InputStream implementations...

http://www.google.com/search?&q=inputstream+bytebuffer

I'm not aware of a pure-java PCM to MP3 converter, but you can certainly use Xuggler to do this. I would suggest looking at their MediaTools classes first before messing with any of the older stale libraries out there.

http://xuggle.wordpress.com/2009/01/23/how-to-use-xuggler-to-decode-and-play-audio/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM