Avassetwriter与Alpha一起使用HEVC撞车 - 寻找解决方法
自升级到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
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
toAVVideoCodecType.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论