gpt4 book ai didi

Java ogg vorbis 编码

转载 作者:行者123 更新时间:2023-12-01 05:50:05 24 4
gpt4 key购买 nike

我正在使用 tritonous 包在 ogg-vorbis 中进行音频编码。当我提供音频格式时,我遇到了问题。

 Unsupported conversion: VORBIS 44100.0Hz, unknown bits per sample, mono, unknown frame size,  from PCM_SIGNED 44100.0 Hz, 16 bit, mono, 2 bytes/frame, little-endian

这是我指定格式的代码

File outputFile = new File(userDir+"//San"+"_"+strFilename + ".spx");

// Using PCM 44.1 kHz, 16 bit signed,stereo.
if(osName.indexOf("win") >= 0){
System.out.println("windows");
audioFormat = getWindowsAudioFormat();
sampleRate = 44100.0F;

}else {
System.out.println("mac");
audioFormat = getMacAudioFormat();
sampleRate = 44100.0F;
}

AudioFormat vorbisFormat = new AudioFormat(VORBIS,
sampleRate,
AudioSystem.NOT_SPECIFIED,
1,
AudioSystem.NOT_SPECIFIED,
AudioSystem.NOT_SPECIFIED,
false);


DataLine.Info info = new DataLine.Info(TargetDataLine.class, audioFormat);
TargetDataLine targetDataLine = null;
AudioFileFormat.Type fileType = null;
File audioFile = null;
fileType = VORBIS;
try
{
targetDataLine = (TargetDataLine) AudioSystem.getLine(info);
targetDataLine.open(audioFormat);
}
catch (LineUnavailableException e)
{
System.out.println("unable to get a recording line");
e.printStackTrace();
System.exit(1);
}
AudioInputStream ais = new AudioInputStream(targetDataLine);

ais = AudioSystem.getAudioInputStream(vorbisFormat, ais);
final Recorder recorder = new Recorder(targetDataLine,ais,fileType,outputFile);
int number = 0;
System.out.println("Recording...");

录音机.start();

最佳答案

我编写了一个实用程序类,使用 libogg 和 libvorbis 的 xiph Java 端口从 Java 编码 OGG Vorbis 音频文件。

https://github.com/xjmusic/java-vorbis-encoder/blob/master/VorbisEncoder.java

关于Java ogg vorbis 编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4944086/

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