Seeking in AAC streams on Android

旧巷老猫 提交于 2020-01-01 17:09:10

问题


I'm getting an AAC stream from a HTTP server and using that as the datasource for the MediaPlayer in Android.
It plays perfectly fine, but when I try to execute mediaPlayer.seekTo(int position) I get the following errors about a million times:
WARN/AACDecoder(13889): AAC decoder returned error -1, substituting silence
WARN/AACDecoder(13889): AAC decoder returned error 10, substituting silence
WARN/AACDecoder(13889): AAC decoder returned error 1, substituting silence

This error happens on Android 2.2 but it does not seem to work on earlier versions either. Support for seeking is a must in my application, and I would like it to work for Android 1.5 - 2.2.

Is there any good solution on how to seek in AAC streams?


回答1:


You cannot seek a served stream. How could the server handle this?

Even if you save the bytes, raw AAC streams are non-seekable (they contain no seek information). Some media players get around this by parsing the whole file and indexing it on the fly every time they load it. A better solution is to repackage the stream into a container, like MP4. Here's an example using MP4Box:

MP4Box -add raw_stream.aac -new output_file.mp4


来源:https://stackoverflow.com/questions/3933387/seeking-in-aac-streams-on-android

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