-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Support MediaCodec audio Float output #6749
Comments
This is less confusing than having audio processing functionality (e.g., playback speed adjustment) just "not work" for some pieces of media. If this change is merged, I will update #6749 to also track making DefaultAudioSink intelligently enable/disable float output depending on how the audio processors are configured. Issue: #7134 PiperOrigin-RevId: 302871568
This is now called
|
I think AudioProcessors should expose what input format they support. That would avoid having to re-sample to 16bit needlessly (which also decrease quality). Only if a processor does not support the inputFormat should the AudioSink automatically resampling to 16bit (as I guess all AudioProcessors are required to support it right now). |
Agreed. My first bullet point is conditional on the fact that all of the (non-resampling) audio processors only accept 16-bit integer PCM at the moment. In a future where we have audio processors that support additional input formats, it would be good if the logic could be clever enough to enable resampling only when necessary. I don't think we need to look at this as a priority though, given what our current audio processors support.
As discussed, it doesn't appear |
I asked the audio framework team why 24 and 32 bit linear PCM are not exposed in the SDK [internal: b/152481314]. |
This is less confusing than having audio processing functionality (e.g., playback speed adjustment) just "not work" for some pieces of media. If this change is merged, I will update #6749 to also track making DefaultAudioSink intelligently enable/disable float output depending on how the audio processors are configured. Issue: #7134 PiperOrigin-RevId: 302871568
Starting with ec78bde, ExoPlayer will now decode audio to |
Correction: |
Use case description
Exoplayer (using MediaCodec) always play compressed audio with a 16bit encoding, when it should play float if available
This has the following drawbacks:
And no advantages that I could identify.
Proposed solution
Use Media Codec float output for audio if supported (API>24).
https://developer.android.com/reference/android/media/MediaCodec#raw-audio-buffers
To do that, the
MediaFormat#KEY_PCM_ENCODING
has to be set toAudioFormat#ENCODING_PCM_FLOAT
during before callingMediaCodec.configure
.Also
DefaultAudioSink.enableConvertHighResIntPcmToFloat
should probably default to true.Alternatives considered
This leads to bigger app size and does not use the platform codecs.
MediaCodecAudioRenderer.getMediaFormat
to configure the codec to output FLOAT.Drawback: Need to subclass MediaCodecAudioRenderer for one utility method. Might not be stable with respect to new releases.
The text was updated successfully, but these errors were encountered: