ios - CFBasicAnimation 中带有自定义键的动画在导出视频时不起作用
<p><p>我有 FrameChangeAnimation 类,它需要多个 Sprite 表和持续时间。所以假设我有 3 个 spritesheet,每个包含 16 个字符 block ,然后我给 '3' 秒作为持续时间。在将 FrameChangeAnimation 实例作为 CALayer 返回后,我将其附加到屏幕上,它可以流畅地播放 </p>
<p>现在我想将此动画导出为视频。问题是,当我这次附加 CABasicAnimation 时,持续时间。 'Duration' 参数不起作用,所有帧都在一秒钟内播放。</p>
<pre><code> GTAnimation *an = [ initWithFrame:CGRectMake(0, 0, videoSize.width, videoSize.height) withFileName:@"Host_Angry_" withSeconds:3.5];
CALayer *animationLayer = ;
animationLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
;
CABasicAnimation *fadeAnimation = ;
fadeAnimation.fromValue = ;
fadeAnimation.toValue = ;
fadeAnimation.additive = NO;
fadeAnimation.removedOnCompletion = NO;
fadeAnimation.beginTime = 0.0;
fadeAnimation.duration = 3.5;
fadeAnimation.repeatCount = HUGE_VAL;
fadeAnimation.fillMode = kCAFillModeBoth;
;
CALayer *parentLayer = ;
CALayer *videoLayer = ;
videoLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
;
;
videoLayer.anchorPoint =CGPointMake(0.5, 0.5);
videoLayer.position = CGPointMake(CGRectGetMidX(parentLayer.bounds), CGRectGetMidY(parentLayer.bounds));
animationLayer.anchorPoint =CGPointMake(0.5, 0.5);
animationLayer.position = CGPointMake(CGRectGetMidX(parentLayer.bounds), CGRectGetMidY(parentLayer.bounds));
videoComposition.animationTool = ;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>根据 AVVideoCompositionCoreAnimationTool 类的文档,</p>
<p>“任何动画都将在视频的时间线上进行解释,而不是实时的,因此您应该:</p>
<p>将动画的 beginTime 属性设置为 1e-100 而不是 0(CoreAnimation 将其替换为 CACurrentMediaTime);</p></p>
<p style="font-size: 20px;">关于ios - CFBasicAnimation 中带有自定义键的动画在导出视频时不起作用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/10448482/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/10448482/
</a>
</p>
页:
[1]