'AVAssetWriter crashing with HEVC With Alpha - looking for workaround

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]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source