使用 Tritonus AudioSystem:将 PCM byte[] 数组转换为 mp3 byte[] 数组
我的音频项目中的一个库不断输出 PCM 音频的 byte[] 数组流(以及长度和偏移整数)。我正在学习使用 Java Sound API 的 Tritonus 实现将此 PCM 流编码为 mp3。
Java Sound API 通过 AudioInputStream(由 1)编码器(由 Tritonus 提供)2)PCM 输入流创建,提供转换/编码的 byte[] 数组。
但我宁愿只使用一个简单的函数,如下所示:
convertPCMToMp3(byte[] samples, int offset, int length)
{
// convert the samples to mp3
// return byte[] encodedsamples int offset int length
}
Does such isn't in the Java Sound API?
如果没有,我可能只会使用这些 ByteBuffer-InputStream 实现之一...
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道纯 java PCM 到 MP3 转换器,但您当然可以使用 Xuggler 来做到这一点。我建议先看看他们的 MediaTools 类,然后再搞乱任何旧的过时的库。
http:// xuggle.wordpress.com/2009/01/23/how-to-use-xuggler-to-decode-and-play-audio/
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/