gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 02:26:55 38 4
gpt4 key购买 nike

我的音频项目中的一个库连续输出PCM音频的byte []数组流(以及长度和偏移整数)。我正在学习使用Java Sound API的Tritonus实现来将此PCM流编码为mp3。

Java Sound API通过AudioInputStream(由1创建),编码器(由Tritonus提供),2(PCM InputStream)提供了一个转换/编码的byte []数组。

但是我宁愿只使用这样的简单函数:

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

Java Sound API中是否存在这种情况?

如果没有,我可能只会使用这些ByteBuffer-InputStream实现之一...

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

最佳答案

我不知道将纯Java PCM转换为MP3的转换器,但是您当然可以使用Xuggler做到这一点。我建议先查看其MediaTools类,然后再与那里任何较旧的过时的库弄混。

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

关于java - 使用Tritonus AudioSystem:将PCM byte []数组转换为mp3 byte []数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4047685/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com