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

Add support for additional (low-bitrate, lossy) codecs #21

Closed
chenxiaolong opened this issue May 23, 2022 · 7 comments
Closed

Add support for additional (low-bitrate, lossy) codecs #21

chenxiaolong opened this issue May 23, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@chenxiaolong
Copy link
Owner

chenxiaolong commented May 23, 2022

I know I said in the README that this would not be implemented, but it seems like a useful enough feature to implement. I'll consider adding lossy compression formats if Android's MediaCodec's encoders for them aren't buggy.

Tentative plan:

  • Add OGG/Opus (Android 10+ only) and OGG/Vorbis (EDIT: M4A/AAC, see below) codecs
  • FLAC will remain the default
  • Both OGG/Opus and OGG/Vorbis will detail to a high bitrate for better quality, but the user will be able to change it

What will not be implemented:

  • Changing the sample rate. I don't want to deal with broken downsampling on some devices so recording always happens at the native sample rate, regardless of which codec is used to encode the output file. (Eg. Pixel 6 Pro's native sample rate for VOICE_LINE is 48kHz)
  • mp3, m4a/aac (EDIT: see below), or any other codec that might be patent encumbered in some countries
  • AMR-NB, AMR-WB, or any other extremely low bitrate codecs
  • wav because the audio is exactly the same as flac, but the file size is larger
@chenxiaolong
Copy link
Owner Author

I was able to successfully test opus in an ogg container. Now, onto vorbis in an ogg container.

@chenxiaolong
Copy link
Owner Author

Hmm, Android doesn't actually support ogg/vorbis encoding. The only audio encoders available on the Pixel 6 Pro are:

c2.android.aac.encoder: [audio/mp4a-latm]
OMX.google.aac.encoder: [audio/mp4a-latm]
c2.android.amrnb.encoder: [audio/3gpp]
OMX.google.amrnb.encoder: [audio/3gpp]
c2.android.amrwb.encoder: [audio/amr-wb]
OMX.google.amrwb.encoder: [audio/amr-wb]
c2.android.flac.encoder: [audio/flac]
OMX.google.flac.encoder: [audio/flac]
c2.android.opus.encoder: [audio/opus]

@chenxiaolong
Copy link
Owner Author

Looks like audio/mp4a-latm is the only thing we can use for Android 9. Patents don't seem like they'll be an issue given that the Android OS provides the codec, not BCR: https://en.wikipedia.org/wiki/Advanced_Audio_Coding#Licensing_and_patents

So we'll have 3 options:

  • FLAC - lossless; free & not patent encumbered; large files
  • OGG/Opus - lossy; free & not patent encumbered; smaller files; Android 10+ only
  • M4A/AAC - lossy, patent encumbered for codec developers only; smaller files; Android 9 compatible

chenxiaolong added a commit that referenced this issue May 25, 2022
This commit adds the initial framework for allowing the configuration of
output codecs. There are three codec choices available:

* FLAC: (default) lossless, compression level 0-8
* OGG/Opus: lossy, bitrate 6-510kbps, Android 10+ only
* M4A/AAC: lossy, HE-AAC bitrate 24-32kbps, AAC-LC bitrate 32-128kbps

While all three codecs are implemented, RecorderThread is currently
hardcoded to use the default. The next step is to save and load the
codec configuration from SharedPreferences and the finally add the user
interface.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 25, 2022
This commit adds the initial framework for allowing the configuration of
output codecs. There are three codec choices available:

* FLAC: (default) lossless, compression level 0-8
* OGG/Opus: lossy, bitrate 6-510kbps, Android 10+ only
* M4A/AAC: lossy, HE-AAC bitrate 24-32kbps, AAC-LC bitrate 32-128kbps

While all three codecs are implemented, RecorderThread is currently
hardcoded to use the default. The next step is to save and load the
codec configuration from SharedPreferences and the finally add the user
interface.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
@greatcoder88
Copy link

Hi! It's me again.

Thanks for thinking about adding multiple codecs.

After testing 1.3 I want to report a bug sometimes at the last second audio overlapping, When I was listening a recording which was 2min and 11sec long then at 2:11 both side of the audio overlapped in a way that can't be understood.

A humble suggestion, aac codec is taking less space as when I shared a 4.66mb flac recording of a 2 min 11 sec long recording through WhatsApp then WA converted and might compressed it into aac which had shockingly only 1.55mb in size!

I guess developer is already adding supporting for M4A/AAC. As per developer's comment, default is FLAC and user will have the choice to select the codecs (FLAC, OGG/Opus, M4A/AAC) in coming release I guess.
Eagerly waiting for the codec selection feature.

@CodElixer
Copy link

CodElixer commented May 25, 2022

I guess developer is already adding supporting for M4A/AAC. As per developer's comment, default is FLAC and user will have the choice to select the codecs (FLAC, OGG/Opus, M4A/AAC) in coming release I guess.
Eagerly waiting for the codec selection feature.

Yes, They're!🤞

chenxiaolong added a commit that referenced this issue May 26, 2022
…erences

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
…erences

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
…erences

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 26, 2022
Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
The configuration is implemented as a bottom sheet that appears when
clicking the new output format preferences. Changes are applied
immediately and per-codec configuration values are preserved when
switching codecs.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
The configuration is implemented as a bottom sheet that appears when
clicking the new output format preferences. Changes are applied
immediately and per-codec configuration values are preserved when
switching codecs.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
The configuration is implemented as a bottom sheet that appears when
clicking the new output format preferences. Changes are applied
immediately and per-codec configuration values are preserved when
switching codecs.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
The configuration is implemented as a bottom sheet that appears when
clicking the new output format preferences. Changes are applied
immediately and per-codec configuration values are preserved when
switching codecs.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
The configuration is implemented as a bottom sheet that appears when
clicking the new output format preferences. Changes are applied
immediately and per-codec configuration values are preserved when
switching codecs.

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
@chenxiaolong
Copy link
Owner Author

This has been implemented and will be available in the next version!

I ended up making OGG/Opus the default. I figure most people will probably prefer (much) smaller files over FLAC's 0 quality loss.

chenxiaolong added a commit that referenced this issue May 27, 2022
…codec is selected

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
chenxiaolong added a commit that referenced this issue May 27, 2022
…codec is selected

Issue: #21
Signed-off-by: Andrew Gunnerson <chillermillerlong@hotmail.com>
@param1903
Copy link

Thank you, I'm sure this will be more useful compared to lossless big files.

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

No branches or pull requests

4 participants