android mediacodec: real time decoding h264 nals

2019-04-12 02:49发布

I'm trying to decode h264 nals in real time with android low level media api.
Each nal contains one full frame, so i expect that after feeding input with my nal and calling dequeueOutputBuffer it would "immediatly" (with the litle delay of course) display my frame but it doesn't. I see the first frame and the dequeue returns the first buffer only afer feeding the decoder with the second one which at this time should render the second frame. Frames are encoded with zerolatency preset of x264 so no b-frame etc...

I guess that there might be a way to set the encoder to render the frame immediatly after it got it but i couldn't find any good documentation/explanations on that. Any suggestion?

2条回答
SAY GOODBYE
2楼-- · 2019-04-12 03:09

a p-frame can be decoded only after the pre-frame was decoded

查看更多
Summer. ? 凉城
3楼-- · 2019-04-12 03:19

Just because frames are encoded with zero latency setting does not mean they will be decoded with zero latency. Two seperate things. So depending on codec level (resolution, bitrate, framerate) and profile you may have to decode upto 16 frames of h264 video to get aframe out.

查看更多
登录 后发表回答