序列化/挑选解码器上下文?

发布于 2025-02-02 01:04:07 字数 122 浏览 2 评论 0原文

是否可以存储和加载解码器上下文来恢复过程启动的解码会话?

上下文/目标:使用视频压缩在昂贵的链接上发送图像数据;几乎只使用中间帧(在关键帧之间的小时)。如果中断,则允许消费者端恢复解码,而无需生产者方面的新密钥框架。

Is it possible to store and load decoder contexts to resume a decoding session across process launches?

Context/Goal: use video compression to send image data over an expensive link; use intermediate frames almost exclusively (hours in between key frames). Allow consumer side to resume decoding in the event of interruption without requiring new key-frames from producer side.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静赏你的温柔 2025-02-09 01:04:07

有一个

现代api (某些杂项功能也是在这里)似乎没有任何可以保存/加载avcodeccontext

我正在寻找一个类似的解决方案,以在解码在视频中来回跳动以通过在密钥帧之间的codec上下文中来回跳动以精确帧,从而减少密钥帧之间的差距。不幸的是,这似乎没有可能。

当您想修剪视频时,可以在关键帧之间选择一个开始框架时(请参阅相关问题):

  • 创建一个对解码器的编码器(您可能想传递与初始生产者使用的相同的编码参数)
  • 在需要停止解码时, 将Seek位置保存在文件中,
  • 将最后一个解码的框架发送到编码器,冲洗并抓住数据包。那应该是关键帧。

当您恢复时,请寻找您到达文件中的位置,然后先发送到以前抓取的数据包的解码器。希望这应该使您处于与解码停止时所处的类似状态。然后,从您的流中恢复阅读数据包并将其发送到解码器。

这没有进行测试,并且阅读已编写的内容在这里实际上可能不起作用,尤其是对于某些编解码器而言。

There was an avcodec_copy_context but it has been deprecated, also because it was not actually copying a context but only its parameters.

In the modern api (some miscellanea functions also here) there doesn't appear to be anything that would allow to save/load a AVCodecContext.

I was looking for a similar solution for being able while decoding to jump back and forth in the video to precise frames by storing codec context in between keyframes so to reduce the gap between keyframes. This unfortunately doesn't appear to be a possibility.

Maybe the solution could be similar to you do when you want to trim a video choosing a start frame in between keyframes (see related question):

  • Create an encoder specular to the decoder (you probably want to pass the same encoding parameters used by the initial producer)
  • At the time you need to stop your decoding, save the seek position in the file
  • Send the last decoded frame to the encoder, flush it and grab the packet. That should be a keyframe.

When you resume, seek to the position you had arrived in the file, and send first of all to the decoder the packet you had grabbed before. This should hopefully put you in a similar state to that you were in when decoding stopped. Then resume reading packets from your stream and sending them to the decoder.

This is not tested, and reading what has been written here, it might actually not work, especially for some codecs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文