AVAsynchronousVideoCompositionRequest sourceFrameByTrackID nil for video with alpha

416 views Asked by At

I'm trying to add some transparent animation videos to my composition as a transition but in my custom compositor (AVVideoCompositing) when I try to get pixel buffer via AVAsynchronousVideoCompositionRequest.sourceFrame it returns nil. If I use non transparent H.264 (mp4) video it works. Transparent video (mov) is encoded with Timecode and Apple ProRes 4444.

Should I try with HEVC? I've seen some suggestions to use Chroma CIFilter on non-transparent video to remove the background, but I'm not sure if that's a right approach.

The desired effect for animated transitions could be seen here.

1

There are 1 answers

0
Frank Rupprecht On

ProRes is actually not supported on iOS. However, you should be able to use CMVideoCodecType.hevcWithAlpha for your use case.

To get a list of available encoders, you can do the following:

import VideoToolbox

var encoders: CFArray?
VTCopyVideoEncoderList(nil, &encoders)
print(encoders!)