我正在尝试测试是否可以使用硬件编码进行实时通信,例如720p客户端到客户端延迟为100毫秒,系统延迟为40毫秒,网络为60毫秒,带有VT的iOS已经可以了。 当我使用AMediaCodec进行尝试时,似乎编解码器总是在第一个输出可用之前缓冲8个以上的帧。 继续调用AMediaCodec_queueInputBuffer输入视频帧AMediaCodec_dequeueOutputBuffer来处理输出。但是直到输入8帧或更多帧,我才能获得任何可用的输出。取而代之的是AMEDIACODEC_INFO_TRY_AGAIN_LATER。 尝试了H264高调和基线。 当我用Codecvisa检查转储的h264流时,得到了DPB(解码图像缓冲区)大小8,看起来像是额外缓冲的提示?
我还在Grafika MediaCodec示例代码中对MoviePlayer.java进行了一些简单的测试。 我担心编解码器在初始解码滞后后会保留多少个输出缓冲区,因为只有在开始时,我才能接受初始延迟。 我添加了一个extra_buffer_cnt,当queueInputBuffer支持时,++-当dequeueOutputBuffer时, 并且我还添加了一个while循环来调用dequeueOutputBuffer,以确保可以及时调用dequeueOutputBuffer。 从日志中,我可以看到某些strem的额外缓冲区始终为8,而对于其他strem则可以为0。
12-07 10:57:45.614 : decoderInputBuffers pts 0
submitted frame 0 to dec, size=40658
12-07 10:57:45.634 : no output from decoder available
loop
decoderInputBuffers pts 98000
submitted frame 1 to dec, size=17438
12-07 10:57:45.664 : no output from decoder available
loop
decoderInputBuffers pts 200000
submitted frame 2 to dec, size=17410
decoder output buffers changed
12-07 10:57:45.674 : no output from decoder available
loop
decoderInputBuffers pts 351000
submitted frame 3 to dec, size=22043
12-07 10:57:45.704 : no output from decoder available
loop
decoderInputBuffers pts 450000
submitted frame 4 to dec, size=21515
12-07 10:57:45.724 : no output from decoder available
loop
decoderInputBuffers pts 550000
submitted frame 5 to dec, size=21449
12-07 10:57:45.754 : no output from decoder available
loop
decoderInputBuffers pts 650000
submitted frame 6 to dec, size=21640
12-07 10:57:45.774 : no output from decoder available
loop
decoderInputBuffers pts 750000
submitted frame 7 to dec, size=25636
12-07 10:57:45.804 : no output from decoder available
loop
decoderInputBuffers pts 848000
submitted frame 8 to dec, size=21466
12-07 10:57:45.814 : no output from decoder available
decoder output format changed: {mime=video/raw, crop-top=0, crop-right=359, slice-height=640, color-format=2141391876, height=640, width=368, what=1869968451, buffer-size=380928, crop-bottom=639, crop-left=0, stride=384}
loop
decoderInputBuffers pts 950000
12-07 10:57:45.824 : submitted frame 9 to dec, size=25224
startup lag 210.543229 ms
surface decoder given buffer 14 (size=8)
dequeueOutputBuffer pts 0 extra buffer 9
12-07 10:57:45.834 : surface decoder given buffer 13 (size=8)
dequeueOutputBuffer pts 98000 extra buffer 8
loop
decoderInputBuffers pts 1046000
submitted frame 10 to dec, size=25172
12-07 10:57:45.844 : surface decoder given buffer 12 (size=8)
dequeueOutputBuffer pts 200000 extra buffer 8
12-07 10:57:45.864 : no output from decoder available
loop
decoderInputBuffers pts 1149000
submitted frame 11 to dec, size=25137
12-07 10:57:45.874 : surface decoder given buffer 11 (size=8)
dequeueOutputBuffer pts 351000 extra buffer 8
12-07 10:57:45.884 : no output from decoder available
loop
decoderInputBuffers pts 1248000
submitted frame 12 to dec, size=25343
12-07 10:57:45.894 : surface decoder given buffer 10 (size=8)
dequeueOutputBuffer pts 450000 extra buffer 8
12-07 10:57:45.914 : no output from decoder available
loop
decoderInputBuffers pts 1400000
submitted frame 13 to dec, size=22197
12-07 10:57:45.924 : surface decoder given buffer 9 (size=8)
dequeueOutputBuffer pts 550000 extra buffer 8
12-07 10:57:45.934 : no output from decoder available
loop
decoderInputBuffers pts 1499000
submitted frame 14 to dec, size=26267
12-07 10:57:45.944 : surface decoder given buffer 8 (size=8)
dequeueOutputBuffer pts 650000 extra buffer 8
12-07 10:57:45.954 : no output from decoder available
loop
decoderInputBuffers pts 1600000
submitted frame 15 to dec, size=25947
12-07 10:57:45.964 : surface decoder given buffer 7 (size=8)
dequeueOutputBuffer pts 750000 extra buffer 8
12-07 10:57:45.984 : loop
decoderInputBuffers pts 1700000
submitted frame 16 to dec, size=26060
12-07 10:57:45.994 : surface decoder given buffer 6 (size=8)
dequeueOutputBuffer pts 848000 extra buffer 8
12-07 10:57:46.004 : no output from decoder available
loop
decoderInputBuffers pts 1799000
submitted frame 17 to dec, size=26003
12-07 10:57:46.014 : surface decoder given buffer 5 (size=8)
dequeueOutputBuffer pts 950000 extra buffer 8
12-07 10:57:46.024 : no output from decoder available
loop
decoderInputBuffers pts 1900000
submitted frame 18 to dec, size=22085
12-07 10:57:46.034 : surface decoder given buffer 13 (size=8)
dequeueOutputBuffer pts 1046000 extra buffer 8
12-07 10:57:46.044 : no output from decoder available
loop
decoderInputBuffers pts 2012000
12-07 10:57:46.054 : submitted frame 19 to dec, size=26195
surface decoder given buffer 12 (size=8)
dequeueOutputBuffer pts 1149000 extra buffer 8
12-07 10:57:46.074 : no output from decoder available
loop
decoderInputBuffers pts 2097000
submitted frame 20 to dec, size=25963
12-07 10:57:46.084 : surface decoder given buffer 11 (size=8)
dequeueOutputBuffer pts 1248000 extra buffer 8
12-07 10:57:46.094 : no output from decoder available
loop
decoderInputBuffers pts 2200000
submitted frame 21 to dec, size=25869