我有兴趣录制带有自定义叠加层的视频,最终会出现在视频中.它们可能是UIImage甚至更好,一个OpenGL视口,现在在任何iPhone设备/ SDK上都有这样的可能吗?
谢谢
我正在寻找将我的图片序列导出为快速视频的正确方法.
我知道AV基金会能够合并或重新组合视频,还可以添加构建单个视频资产的音轨.
现在......我的目标有点不同.我想从头开始创建一个视频.我有一套UIImage,我需要在一个视频中渲染所有这些.我阅读了有关AV Foundation的所有Apple文档,我找到了AVVideoCompositionCoreAnimationTool类,它能够获取CoreAnimation并将其重新编码为视频.我还检查了Apple提供的AVEditDemo项目,但似乎有些东西在我的项目中没有用.
我的步骤:
1)我创建了CoreAnimation Layer
CALayer *animationLayer = [CALayer layer];
[animationLayer setFrame:CGRectMake(0, 0, 1024, 768)];
CALayer *backgroundLayer = [CALayer layer];
[backgroundLayer setFrame:animationLayer.frame];
[backgroundLayer setBackgroundColor:[UIColor blackColor].CGColor];
CALayer *anImageLayer = [CALayer layer];
[anImageLayer setFrame:animationLayer.frame];
CAKeyframeAnimation *changeImageAnimation = [CAKeyframeAnimation animationWithKeyPath:@"contents"];
[changeImageAnimation setDelegate:self];
changeImageAnimation.duration = [[albumSettings transitionTime] floatValue] * [uiImagesArray count];
changeImageAnimation.repeatCount = 1;
changeImageAnimation.values = [NSArray arrayWithArray:uiImagesArray];
changeImageAnimation.removedOnCompletion = YES;
[anImageLayer addAnimation:changeImageAnimation forKey:nil];
[animationLayer addSublayer:anImageLayer];
Run Code Online (Sandbox Code Playgroud)
2)比我实例化AVComposition
AVMutableComposition *composition = [AVMutableComposition composition];
composition.naturalSize = CGSizeMake(1024, 768);
CALayer *wrapLayer = [CALayer layer];
wrapLayer.frame …
Run Code Online (Sandbox Code Playgroud)