Play AAC buffer on Android

半世苍凉 提交于 2019-12-24 11:54:00

问题


Is there a reasonable way to play a memory buffer containing AAC (in an MP4 container) in Android? I cannot write this buffer to disk... it must be played from memory.

Seems that my only option is to decode to PCM manually and use AudioTrack since Android doesn't expose any API that plays non-PCM memory buffers. OpenSL ES has support for memory sources, but Android doesn't implement this.


回答1:


The only way I can find that does this is (as indicated in my question) to manually decode the AAC. There are a few packages for Android that do this, perhaps ffmpeg is the most well-tested and well-known. ffmpeg can be distilled down to just an AAC decoder so the memory needs are quite small (although it's frustrating to introduce a decoder to a device that already has one natively).

Once AAC is decoded into PCM, it can be played in Java (AudioTrack), or natively (OpenSL ES). The playback latency is notably lower for the native option, if such matters to you.



来源:https://stackoverflow.com/questions/20109443/play-aac-buffer-on-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!