问题
I am trying to layer AVAssetTracks in an AVMutableComposition where the AVAssetTracks have an alpha channel in the video.
I have successfully exported an video AVAsset with pixel buffers than have an alpha channel and transparency, but when I try to add that into an AVMutableCompositionTrack and layer it, it doesnt display correctly.
Is this possible? Is the magic performed when the AVAsset is created or in a the AVMutableComposition or AVVideoComposition?
Any clues would be a huge help.
回答1:
The short answer is that you are not going to be able to get this to work with the built in AVFoundation logic since it only supports h.264 and h.264 does not support an alpha channel. But, if you use a library with alpha channel support, then it can be done. See this question for a working example. You could also implement it yourself by doing the composition operation in your own code with CoreGraphics and then exporting the flat 24BPP graphics when encoding to h.264.
来源:https://stackoverflow.com/questions/27390447/avassettrack-with-alpha-channel