如何在iOS中特定时间段的视频上应用图像叠加?

时间:2018-12-17 10:33:45

标签: ios filter video-streaming avfoundation

我引用了我的博客和堆栈溢出链接,但没有获得在特定时间段内在视频上应用图像叠加的确切解决方案。(例如:我需要在视频的5到10秒内应用图像叠加)。我尝试将其应用到整个视频上。但是我需要特定的时间段。

您能建议我实现这一目标的最佳解决方案吗?

  CALayer *overlayLayer = [CALayer layer];
  UIImage *overlayImage = overlayImage = [UIImage imageNamed:@“image.png"];


  [overlayLayer setContents:(id)[overlayImage CGImage]];
  overlayLayer.frame = CGRectMake(0, 0, size.width, size.height);
  [overlayLayer setMasksToBounds:YES];

  CALayer *parentLayer = [CALayer layer];
  CALayer *videoLayer = [CALayer layer];
  parentLayer.frame = CGRectMake(0, 0, size.width, size.height);
  videoLayer.frame = CGRectMake(0, 0, size.width, size.height);
  [parentLayer addSublayer:videoLayer];
  [parentLayer addSublayer:overlayLayer];

  composition.animationTool = [AVVideoCompositionCoreAnimationTool
                               videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];

0 个答案:

没有答案