jave2
jave2 copied to clipboard
different bitrate between windows and linux when convert wav to mp3
Hi when i converted a wav file to mp3, the bitrate under windows is 80k, but under linux is 32k. after checking the file properties, found: windows mp3 format: MP3 32 Kbps VBR OFL linux mp3 format: MP3 80 Kbps CBR
which i confused, why i had set the bitrate, but the result is different?
public static boolean wavToMp3(String sourceWavFile, String targetMp3File, int bitrate, int channel, int sampleRate) { File source = new File(sourceWavFile); File target = new File(targetMp3File);
AudioAttributes audioAttributes = new AudioAttributes();
audioAttributes.setCodec("libmp3lame");
audioAttributes.setBitRate(bitrate); // I set bitrate=80000
audioAttributes.setChannels(channel);
audioAttributes.setSamplingRate(sampleRate);
EncodingAttributes encodingAttributes = new EncodingAttributes();
encodingAttributes.setInputFormat("wav");
encodingAttributes.setOutputFormat("mp3");
encodingAttributes.setAudioAttributes(audioAttributes);
Encoder encoder = new Encoder();
try {
encoder.encode(new MultimediaObject(source), target, encodingAttributes);
return source.delete();
} catch (Exception e) {
log.error("convert failed: {}, source file: {}", e.getMessage(), sourceWavFile);
return false;
}
}
What jave version are you using on windwows and on linux?
What jave version are you using on windwows and on linux?
I'm sorry, the format result shoule be: windows mp3 format: MP3 80 Kbps CBR linux mp3 format: MP3 32 Kbps VBR OFL