gpt4 book ai didi

FFmpeg:为什么 avcodec_receive_frame 需要额外的数据包来获取 I 帧

转载 作者:行者123 更新时间:2023-12-04 23:11:38 25 4
gpt4 key购买 nike

我是 FFmpeg 的新手。使用 nice repo(https://github.com/leandromoreira/ffmpeg-libav-tutorial) 学习时,在 hello_world 示例中,我发现 avcodec_receive_frame 在获得第三个数据包之前不会返回第一个 I 帧,如下图所示:
enter image description here
我想知道为什么需要额外的数据包来接收 I 帧。

最佳答案

大多数现代视频编解码器都使用 I/P/B 帧,这会带来解码时间戳 (DTS) 和呈现时间戳 (PTS)。因此,hello_world 对 ffmpeg 的库的作用如下:-

  • 解复用 (av_read_frame)
  • 根据文件格式(mp4/avi/mkv 等)对数据包进行解复用,直到您拥有所需流的数据包(例如视频)-(我们可以在这里以 NAL 单元为例-不确定)
  • 向解码器提供数据包 (avcodec_send_packet)
  • 开始解码过程,直到它有足够的数据包给你第一帧(基于 DTS 解码)
  • 检查帧是否准备好呈现 (avcodec_receive_frame)
  • 在输入后询问解码器是否有要呈现的帧。它可能还没有准备好,你需要重新喂它,甚至它可能一次给你超过 1 帧。 (根据PTS出帧)
  • 关于FFmpeg:为什么 avcodec_receive_frame 需要额外的数据包来获取 I 帧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66432366/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com