开发者

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

开发者 https://www.devze.com 2023-01-23 01:58 出处:网络
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

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消