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

Actual sample rate is inconsistent with config #1237

Closed
doug-hoffman opened this issue May 7, 2022 · 3 comments · Fixed by #1376
Closed

Actual sample rate is inconsistent with config #1237

doug-hoffman opened this issue May 7, 2022 · 3 comments · Fixed by #1376
Assignees
Milestone

Comments

@doug-hoffman
Copy link
Contributor

Setting the sample rate above 16kHz results in a sample rate of 16kHz:

BCFY Calls:

$ file 1651891145-20071.mp3 
1651891145-20071.mp3: Audio file with ID3 version 2.4.0, contains:MPEG ADTS, layer III, v2,  16 kbps, 16 kHz, Monaural

Icecast:

$ mpv <url>
 (+) Audio --aid=1 (mp3 1ch 16000Hz)
File tags:
 icy-title: Scanning...
AO: [coreaudio] 16000Hz mono 1ch floatp
A: 00:00:01 / 00:00:07 (19%) Cache: 6.0s/95KB
@doug-hoffman doug-hoffman changed the title Sample rate capped at 16kHz Actual sample rate is inconsistent with config May 7, 2022
@doug-hoffman
Copy link
Contributor Author

I've now seen the sample rate change between restarts without changing the configuration. It has been 22.05kHz occasionally, including right now after setting to 44.1kHz and restarting.

@doug-hoffman
Copy link
Contributor Author

doug-hoffman commented May 7, 2022

Adding debug:

    public MP3AudioConverter(InputAudioFormat inputAudioFormat, MP3Setting setting, boolean normalizeAudio)
    {
        mInputAudioFormat = inputAudioFormat;
        mEncoder = LameFactory.getLameEncoder(inputAudioFormat, setting);
        mNormalizeAudio = normalizeAudio;

        mLog.debug("Audio format:" + mInputAudioFormat);
        mLog.debug("Effective sample rate:" + mEncoder.getEffectiveSampleRate());

Confirms LAME sample rate differs:

15:32:07.138 DEBUG i.g.d.a.c.MP3AudioConverter - Audio format:16-Bit 22050 Hz (default)  [41MB/80MB 52%]
15:32:07.138 DEBUG i.g.d.a.c.MP3AudioConverter - Effective sample rate:16000  [41MB/80MB 52%]

@doug-hoffman
Copy link
Contributor Author

I'm not seeing a clear way to fix this while using the LameEncoder class. We need to be able to call mEncoder.lame.getFlags().setOutSampleRate(), which isn't accessible, to prevent it from resampling. Warning seems like the best immediate path forward.

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

Successfully merging a pull request may close this issue.

2 participants