我正在使用JAVE(Java 音频视频编码器)库,并且开发的应用程序在 Windows 上。在 Windows 上,文件的转换工作正常,但是当我在 linux (CentOS 7) 上.mp3
部署时,会引发异常。
据我了解,JAVE还有一个围绕ffmpeg
可执行文件的包装器。
这是我的代码:
try {
File source = new File(sourceFile);
File target = new File(targetFile);
final AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(88000);
audio.setChannels(2);
audio.setSamplingRate(44100);
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);
} catch (EncoderException ex) {
throw ex;
}
例外:
...
Caused by: it.sauronsoftware.jave.EncoderException: Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height
at it.sauronsoftware.jave.Encoder.encode(Encoder.java:926)
at it.sauronsoftware.jave.Encoder.encode(Encoder.java:713)
at com.hft2.ejb.util.Mp3JaveEncoder.encode(Mp3JaveEncoder.java:36)
... 206 more
更新
这是官方页面: http: //www.sauronsoftware.it/projects/jave/
完整的异常日志:https ://jpst.it/1678l
有谁有想法吗?