Add support for additional (low-bitrate, lossy) codecs
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_LINEis 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
I was able to successfully test opus in an ogg container. Now, onto vorbis in an ogg container.
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]
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
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.
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!🤞
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.
Thank you, I'm sure this will be more useful compared to lossless big files.