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

查看:109
本文介绍了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.


所以说我们有一部电影,框架显示为:IBB 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天全站免登陆