MediaCodec and 24 bit PCM

I have successfully used MediaCodec to decode audio, however, when I upload a file with 24-bit samples, I do not know how this happened. Since the application accepted 16-bit samples, it fails.

When I print MediaFormat, I see

{mime=audio/raw, durationUs=239000000, bits-format=6, channel-count=2, channel-mask=0, sample-rate=96000} 

I assume that the โ€œbit formatโ€ will be a hint, however, this key is not declared in the API and is not actually issued when the output format is changed. I get

 {mime=audio/raw, what=1869968451, channel-count=2, channel-mask=0, sample-rate=96000} 

(By the way, what is a "what" key? I notice that if I interpret it as 4charcode, it is " outC " ... just a flag, what is the output format?)

So what is the best fit here? If I feed ByteBuffer directly to AudioTrack , it certainly plays statically (assuming PCM 16).

If I know the meaning, then I can convert it myself! On other issues, I understand that you also cannot dictate the output format.

+6
source share

Source: https://habr.com/ru/post/987227/


All Articles