问题
I'm looking into using the android MediaCodec class to decode HEVC. Are there any examples of projects that do this?
At present I configure the decoder with the following:
AMEDIAFORMAT_KEY_MIME: "video/hevc"
AMEDIAFORMAT_KEY_MAX_HEIGHT: 4320
AMEDIAFORMAT_KEY_MAX_WIDTH: 8192
AMEDIAFORMAT_KEY_HEIGHT: 1600
AMEDIAFORMAT_KEY_WIDTH: 3840
AMEDIAFORMAT_KEY_FRAME_RATE: 24
AMEDIAFORMAT_KEY_PUSH_BLANK_BUFFERS_ON_STOP: 1
When using this setup, I get no video output. I've also tried setting csd-0
, csd-1
and csd-2
to the VPS, SPS and PPS respectively, but have had no luck.
I get the following error in the console, but have been assured it is unrelated:
01-19 15:40:36.048: E/OMXNodeInstance(17230): OMX_GetExtensionIndex OMX.google.android.index.storeMetaDataInBuffers failed
01-19 15:40:36.048: E/ACodec(17230): [OMX.google.hevc.decoder] storeMetaDataInBuffers failed w/ err -2147483648
I have found that dequeueOutputBuffer
is always returning -1
. It appears that dequeueInputBuffer
is returning indices that have been queued by queueInputBuffer
before they are obtained from dequeueOutputBuffer
.
Has anyone managed to decode HEVC video on Android?
回答1:
VLC at least has support for it, although I'm not sure exactly which decoders it has been tested with (I can see from your log snippet that you're using the SW decoder). As far as I know, the only detail about it that you'd need to take care of is passing the packets in annex b format (with start codes) instead of the mp4/mkv format - just as for H264.
See e.g. http://git.videolan.org/?p=vlc.git;a=commitdiff;h=86630a1, http://git.videolan.org/?p=vlc.git;a=commitdiff;h=5e19ce93 and http://git.videolan.org/?p=vlc.git;a=commitdiff;h=7b79a086 for some examples on this.
Also, the log message about storeMetaDataInBuffers
failing is unrelated and nothing to worry about, see Q12 at http://bigflake.com/mediacodec/.
回答2:
Might also want to look at the MX Player, which plays HEVC on my Nexus 7. But, absent any current Android hardware support for HEVC, HD content playback is too jittery. 640p and lower resolutions play fine - though maybe not in the majority of Android devices with lesser cpu capability.
回答3:
The problem seems to be with the resolution - 512x216 didn't work and gave the above symptoms, but 1920x800 worked fine. I've asked another question about what resolutions are supported.
来源:https://stackoverflow.com/questions/28028723/android-mediacodec-for-hevc