c - ffmpeg.c 什么是 pts 和 dts ?这个代码块在 ffmpeg.c 中做了什么?

标签 c ffmpeg

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

此代码位在 ffmpeg.c 中的作用是什么? , 它的目的是什么?

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)。您可以在这里找到解释 inside a tutorial .

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

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

关于c - ffmpeg.c 什么是 pts 和 dts ?这个代码块在 ffmpeg.c 中做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6044330/

相关文章:

c - 二叉树的中序遍历

c++ - dos.h 是一个什么样的库(静态的还是动态的)?

python - 无法在 Windows 7 机器中使用 OpenCV 2.4.3、Python 2.7 打开 ".mp4"视频文件

c - 与 char *foo() 函数关联的内存是否被释放(在 C 中)?

python - C 方法通过 ctypes 将字符串返回给 Python

c++ - 如何使用 CURLPP 库通过 C/C++ 代码检查网站是 http 还是 https?

ffmpeg - 使用了 Libtool 库,但 `LIBTOOL' 未定义?

python - 可视化 ffmpeg 基准

video - FFmpeg:将任何视频转换为边栏模糊的方形 1:1 视频

c# - 从图像生成视频并添加音频时,视频无法播放