ffmpeg.c pts 和 dts 是什么?这个代码块在 ffmpeg.c 中有什么作用? [英] ffmpeg.c what are pts and dts ? what does this code block do in ffmpeg.c?

查看:32
本文介绍了ffmpeg.c pts 和 dts 是什么?这个代码块在 ffmpeg.c 中有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 简单来说,什么是 pts 和 dts 值?
  • 为什么它们在转码 [解码-编码] 视频时很重要?

这段代码在 ffmpeg 中有什么作用.c,它的目的是什么?

What does this code bit do in ffmpeg.c , what is its purpose?

01562    ist->next_pts = ist->pts = picture.best_effort_timestamp;
01563    if (ist->st->codec->time_base.num != 0) {
01564        int ticks= ist->st->parser ? ist->st->parser->repeat_pict+1 : ist->st->codec->ticks_per_frame;
01565        ist->next_pts += ((int64_t)AV_TIME_BASE *
01566                         ist->st->codec->time_base.num * ticks) /
01567                         ist->st->codec->time_base.den;
01568    }

推荐答案

那些是解码时间戳 (DTS) 和演示时间戳 (PTS).您可以在此处教程内找到说明.

Those are the decoding time stamp (DTS) and presentation time stamp (PTS). You can find an explanation here inside a tutorial.

假设我们有一部电影,帧显示为:I B B P.现在,我们需要知道 P 中的信息,然后才能显示 B 帧.正因为如此,帧可能会像这样存储:I P B B.这就是为什么我们在每一帧上都有一个解码时间戳和一个呈现时间戳.解码时间戳告诉我们什么时候需要解码某些东西,呈现时间戳告诉我们什么时候需要显示某些东西.因此,在这种情况下,我们的流可能如下所示:

So let's say we had a movie, and the frames were displayed like: I B B P. Now, we need to know the information in P before we can display either B frame. Because of this, the frames might be stored like this: I P B B. This is why we have a decoding timestamp and a presentation timestamp on each frame. The decoding timestamp tells us when we need to decode something, and the presentation time stamp tells us when we need to display something. So, in this case, our stream might look like this:

   PTS: 1 4 2 3
   DTS: 1 2 3 4
Stream: I P B B

一般来说,PTS 和 DTS 只会在我们正在播放的流中包含 B 帧时有所不同.

Generally the PTS and DTS will only differ when the stream we are playing has B frames in it.

这篇关于ffmpeg.c pts 和 dts 是什么?这个代码块在 ffmpeg.c 中有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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