我怎么养活H.264 NAL单元到Android媒体codeC的解码? [英] How do I feed H.264 NAL units to Android MediaCodec for decoding?

查看:187
本文介绍了我怎么养活H.264 NAL单元到Android媒体codeC的解码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何使用Android的媒体codec类脱code H.264视频。首先,我试图手动解析NAL单元出来的H.264文件,并将其输送到媒体codeC的解码。我相信我正确地分析NAL单元出来的文件(搜索为0x00为0x00为0x01序列中的文件,表示NAL单元的开始),但媒体codeC总是超时并返回-1每一次我做调用dequeueOutputBuffer()。有谁知道如何喂养H.264 NAL单元到媒体codeC的解码的具体情况如何?我应该剥去0×00 0×00 0×01序列之前,我把它NAL单元?我需要忽略/丢弃某些NAL单元类型?我需要prePEND提取的SPS和PPS信息(带或不带0×00 0×00 0×01序列)各NAL单元之前?我玩弄了很多在这里的想法和他们都不是平移的。在这个领域的任何指导意见将非常AP preciated。

I'm trying to figure out how to use Android's MediaCodec class to decode H.264 video. To start, I'm trying to manually parse the NAL units out of an H.264 file and feed them to MediaCodec for decoding. I believe I'm parsing the NAL units out of the file correctly (searching for 0x00 0x00 0x01 sequence in file, indicates the start of a NAL unit), but MediaCodec always times out and returns -1 each time I make a call to dequeueOutputBuffer(). Does anyone know the specifics of how to feed H.264 NAL units to MediaCodec for decoding? Am I supposed to strip off the 0x00 0x00 0x01 sequence before I send it a NAL unit? Do I need to ignore/drop certain NAL unit types? Do I need to prepend the extracted SPS and PPS info (with or without the 0x00 0x00 0x01 sequence) before each NAL unit? I'm playing around with a lot of ideas here and none of them are panning out. Any guidance in this realm would be very much appreciated.

推荐答案

至于什么我都经历过,去codeR将返回-1 dequeueOutputBuffer()只要你不给它的SPS / PPS信息。当你这样做时,德codeR应与dequeueOutputBuffer()的INFO_OUTPUT_FORMAT_CHANGED标志(-2)返回,之后,将正确返回去codeD架。

As far as what I have experienced, the decoder will return -1 on dequeueOutputBuffer() as long as you don't feed it the sps/pps info. When you do that, the decoder should return with the INFO_OUTPUT_FORMAT_CHANGED flag (-2) on dequeueOutputBuffer(), and after that will properly return decoded frames.

如果去codeR仍返回-1,尝试添加SPS / PPS信息到去codeR的标志BUFFER_FLAG_ codeC_CONFIG。

If the decoder still returns -1, try adding the sps/pps info to the decoder with the flag BUFFER_FLAG_CODEC_CONFIG.

这篇关于我怎么养活H.264 NAL单元到Android媒体codeC的解码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆