I am trying to decode h264 live stream from WIFI camera by madiacodec in Galaxy S3, the video plays OK, but it seems that mediacode low level always buffers 1 second of video frames, a new frame can be decoded only by a new incoming NAL unit. This causes about 1 second of latency.
When MediaCodec.createDecoderByType("video/avc");
is called I can see from logcat that 22 buffers are allocated,
01-04 15:39:02.799: I/ExtendedCodec(13374): Smoothstreaming Enabled
01-04 15:39:02.809: I/ACodec(13374): [OMX.qcom.video.decoder.avc] Now Loaded->Idle
01-04 15:39:02.809: I/ACodec(13374): [OMX.qcom.video.decoder.avc] Allocating 22 buffers from a native window of size 245760 on output port
01-04 15:39:02.889: D/DecodeActivity(13374): Decoder started at --- 1388867942894
01-04 15:39:02.889: I/ACodec(13374): [OMX.qcom.video.decoder.avc] Now Idle->Executing
01-04 15:39:03.019: I/ACodec(13374): [OMX.qcom.video.decoder.avc] Now Executing
And I can see about 16 NAL units need to be pushed into decoder before I can get any frame out.
My question is that why this video buffering? any way I can try to allocate less buffer if that is the problem. Is there anyway I can reduce this video buffering?