jave2 icon indicating copy to clipboard operation
jave2 copied to clipboard

different bitrate between windows and linux when convert wav to mp3

Open jelly074100209 opened this issue 3 years ago • 3 comments

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;
    }
}

jelly074100209 avatar Jan 18 '22 09:01 jelly074100209

What jave version are you using on windwows and on linux?

a-schild avatar Jan 18 '22 09:01 a-schild

What jave version are you using on windwows and on linux?

ws.schild jave-core 3.2.0 ws.schild jave-nativebin-linux64 3.2.0 ws.schild jave-nativebin-win64 3.2.0

jelly074100209 avatar Jan 18 '22 09:01 jelly074100209

I'm sorry, the format result shoule be: windows mp3 format: MP3 80 Kbps CBR linux mp3 format: MP3 32 Kbps VBR OFL

jelly074100209 avatar Jan 18 '22 09:01 jelly074100209