Avassetwriter与Alpha一起使用HEVC撞车 - 寻找解决方法

发布于 2025-01-22 22:31:46 字数 1208 浏览 6 评论 0原文

自升级到MacOS 12.3以来,Apple用Alpha编写HEVC的示例代码正在崩溃。

”碰撞

出于某种原因,没有pixelbufferpool。在更新之前,这很好。

找到解决方法

我已经提交了FB9972239,但是我很想解决这个问题,因为我有需要此功能的用户。

我尝试的

  • avvideocodeckey更改为avvideocodectype.h264。这有效,但显然没有Alpha频道。
  • 将编解码器更改为avvideocodectype.prores444。这不会崩溃,但是没有alpha频道。我觉得这很奇怪,因为ProRes4444支持Alpha。

更新

将输出设置更改为下面可防止崩溃。

总比没有好,但是似乎无法控制α质量似乎并不理想,而非时空的压缩必须导致质量和文件大小较差?

            let outputSettings = [
                AVVideoCodecKey: AVVideoCodecType.hevcWithAlpha,
                AVVideoWidthKey: ExportSettings.width,
                AVVideoHeightKey: ExportSettings.height,
                AVVideoCompressionPropertiesKey: [
                    kVTCompressionPropertyKey_AllowTemporalCompression : false
                                                 ]
                ] as [String: Any]

Since upgrading to macOS 12.3, Apple's sample code for writing HEVC with Alpha is crashing.

Sample code - project: HEVC-Videos-With-Alpha-AssetWriting

Here's the crash
enter image description here

For some reason, there is no pixelBufferPool. This worked perfectly before the update.

Finding a workaround

I've filed FB9972239, but I'd love to work around this issue as I have users who need this.

What I've tried

  • Changing the AVVideoCodecKey to AVVideoCodecType.h264. This works, but obviously without the alpha channel.
  • Changing the codec to AVVideoCodecType.proRes4444. This doesn't crash, but there is no alpha channel. I find this strange, since ProRes4444 supports alpha.

Update

Changing the output settings to the below prevents the crash.

It's better than nothing, but it does not seem ideal to not be able to control alpha quality, and non-temporal compression must result in worse quality and file size?

            let outputSettings = [
                AVVideoCodecKey: AVVideoCodecType.hevcWithAlpha,
                AVVideoWidthKey: ExportSettings.width,
                AVVideoHeightKey: ExportSettings.height,
                AVVideoCompressionPropertiesKey: [
                    kVTCompressionPropertyKey_AllowTemporalCompression : false
                                                 ]
                ] as [String: Any]

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文