How do I feed H.264 NAL units to Android MediaCodec for decoding?

后端 未结 2 508
甜味超标
甜味超标 2021-02-02 03:18

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

2条回答
  •  失恋的感觉
    2021-02-02 03:55

    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.

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

提交回复
热议问题