PresentationTimeUs对于MediaCodec有什么用途? [英] What is the use of presentationTimeUs for MediaCodec?

查看:424
本文介绍了PresentationTimeUs对于MediaCodec有什么用途?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

queueInputBuffer(int索引,int偏移量,int大小,长presentationTimeUs,int标志)如下:

此缓冲区的显示时间戳(以微秒为单位).这是通常,应该显示此缓冲区的媒体时间(渲染).

The presentation timestamp in microseconds for this buffer. This is normally the media time at which this buffer should be presented (rendered).

如果由解码器决定何时要呈现解码图像,为什么解码器需要它?我已经为presentationTimeUs尝试了一些任意数字,但它们似乎对解码没有任何影响.例如,如果我将presentationTimeUs的原始值加倍,则视频似乎与原始解码的方式和速度完全相同.

Why does the decoder need this if it is up to the app when to present the decoded image? I have tried some arbitrary numbers for presentationTimeUs, and they do not seem to make any difference to the decoding. For example, if I double the original values of presentationTimeUs, the video seems to be decoded exactly the same way and at the same speed as the original.

有人能对此有所启发吗?

Could anyone shed some light on this?

推荐答案

出于多种原因, decoder 需要知道输入缓冲区的 timestamps .

The decoder needs to know the input buffer's timestamps for multiple reasons.

首先,如果流具有 B帧,则对缓冲区进行重新排序并为缓冲区分配正确的 timestamps decoder .因此,当在输入缓冲区上收到 timestamps 时,会将它们排入队列以进行重新排序.

First, if the stream has B-frames, then the reordering of buffers and assigning the correct timestamps to the buffers is performed by the decoder. So when the timestamps are received on the input buffer, the same is queued for reordering.

其次,,如果用例类似于 Android-TV ,并且实际上具有 tunneled视频播放,则 timestamp视频解码器消耗,该解码器被隧道到底层的 HW 块,以进行同步和渲染.

Secondly, if the use-case is something like Android-TV which infact has the tunneled video playback, the timestamp is consumed by the video decoder which is tunneled to the underlying HW block for synchronization and rendering.

最后,如果数据包或帧中有任何丢包,则如果 decode 观察到 timestamps中的突然跳跃,则可能会执行某种隐藏操作./code>而不调用刷新.这不是规范,而是某些解码器的高级功能.

Lastly, if there is any drop in packets or frames, the decoder can potentially perform some sort of concealment if it an observes abrupt jump in timestamps without a flush being called. This is not a norm, but is an advanced feature of some decoders.

如您所指出的,在传统情况下,同步是由播放器引擎执行的,其中 decoder 会将输入缓冲区的时间戳反映到输出缓冲区上.

In traditional cases, as you have pointed out, the synchronization is performed by the player engine in which decoder shall reflect the input buffer timestamp onto the output buffer.

这篇关于PresentationTimeUs对于MediaCodec有什么用途?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆