Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different bitrate between windows and linux when convert wav to mp3 #192

Open
jelly074100209 opened this issue Jan 18, 2022 · 3 comments
Open

Comments

@jelly074100209
Copy link

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;
    }
}
@a-schild
Copy link
Owner

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

@jelly074100209
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants