使用 Tritonus AudioSystem:将 PCM byte[] 数组转换为 mp3 byte[] 数组

发布于 2024-09-29 15:04:11 字数 663 浏览 8 评论 0原文

我的音频项目中的一个库不断输出 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 实现之一...

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白云不回头 2024-10-06 15:04:11

我不知道纯 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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文