如何设置纵向视频的背景图像?

时间:2014-02-07 10:47:16

标签: ios avfoundation video-processing

我一直在尝试为肖像视频设置背景图像/ CALayer,以便我可以避免黑条。 我可以设置图像,但它显示黑色背景而不是图像。

CALayer *videoLayer = [CALayer layer]
CGRect frame = CGRectMake(0, 0, size.with, size.height);
videoLayer.frame = frame;
videoLayer.backgroundColor = [UIColor clearColor].CGColor;
CALayer *backgroundImageLalyer = [CALayer layer]
CALayer *outputLayer = [CALayer layer]
[outputLayer addSublayer:backgroundImageLayer]
[outputLayer addSublayer:videoLayer]

[backgroundLayer setContents:(id)[backgroundImage CGImage]];
backgroundLayer.frame = frame;
[backgroundLayer setMasksToBounds:YES];

composition.animationTool = [AVVideoCompositionCoreAnimationTool
                               videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:outputLayer]

有人可以建议我为肖像视频设置背景图片吗?

0 个答案:

没有答案