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

后端 未结 2 510
甜味超标
甜味超标 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.

    0 讨论(0)
  • 2021-02-02 03:56

    AFAIK you need to take the header out as well as feed it with SPS/PSS as first buffers, But getting -1 is not a big deal it will be a normal behaivour. Some devices will crash if they are not feeded by SPS/PPS before the other NALs

    0 讨论(0)
提交回复
热议问题