简体   繁体   English

Android mediacodec实时解码h264流,延迟时间约为1秒

[英]Android mediacodec decoding h264 stream in real time with about 1 second latency

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. 我试图通过Galaxy S3中的madiacodec从WIFI摄像头解码h264直播流,视频播放正常,但似乎mediacode低电平总是缓冲1秒视频帧,新帧只能由新传入的NAL单元解码。 This causes about 1 second of latency. 这导致大约1秒的延迟。

When MediaCodec.createDecoderByType("video/avc"); MediaCodec.createDecoderByType("video/avc"); is called I can see from logcat that 22 buffers are allocated, 调用我可以从logcat看到分配了22个缓冲区,

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. 我可以看到在我可以取出任何帧之前需要将16个NAL单元推入解码器。

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? 无论如何,我可以减少这个视频缓冲?

First of all, are you sure that each NAL unit corresponds to one frame? 首先,你确定每个NAL单元对应一个帧吗? H.264 doesn't dictates how many NAL unit will be there for each frame, it depends on encoder implementation. H.264没有规定每帧有多少NAL单元,它取决于编码器的实现。 Second thing, I'm having similar issues when using a device with Qualcomm chipset. 第二件事,我在使用Qualcomm芯片组的设备时遇到了类似的问题。 I'm not using MediaCodec, but IOMX interface, but basically I get the same latency. 我没有使用MediaCodec,而是使用IOMX接口,但基本上我得到了相同的延迟。 I wonder if you you have prints in logcat saying how mnay input buffers are allocated. 我想知道你是否在logcat中有关于如何分配mnay输入缓冲区的打印件。 Those will be more relevant to the issue, and not the buffers on the output port. 这些与问题更相关,而不是输出端口上的缓冲区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 android mediacodec:实时解码h264 nals - android mediacodec: real time decoding h264 nals Android MediaCodec 实时 h264 编码/解码延迟 - Android MediaCodec realtime h264 encoding/decoding latency 使用 MediaCodec 在 Android 上使用 H264 数据解码 RTP 流 - Decoding an RTP stream with H264 data on Android Using MediaCodec 用MediaCodec流解码原始h264会导致黑色表面 - Decoding raw h264 with MediaCodec stream results in black surface Android MediaCodec解码h264原始数据延迟问题 - Android MediaCodec decode h264 raw data latency issue 在Android中解码Raw H264流? - Decoding Raw H264 stream in android? 使用ffmpeg解析有关MediaCodec编码的h264流中的显示时间的信息 - use ffmpeg to parse info about presentation time in h264 stream encoded by MediaCodec 媒体编解码器解码h264流限制 - mediacodec decode h264 stream limitation 解码H264视频时Android MediaCodec releaseOutputBuffer抛出MediaCodec.CodecException - Android MediaCodec releaseOutputBuffer throws MediaCodec.CodecException when decoding H264 video 在某些使用MediaCodec高分辨率解码H264流的三星设备上,dequeueOutputBuffer始终返回-1 - on some Samsung devices decoding H264 stream at hight resolution with MediaCodec, dequeueOutputBuffer always return -1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM