gpt4 book ai didi

ios - CFBasicAnimation 中带有自定义键的动画在导出视频时不起作用

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:15:48 26 4
gpt4 key购买 nike

我有一个 FrameChangeAnimation 类,它需要多个 spritesheet 和持续时间。所以假设我有 3 个 spritesheet,每个 spritesheet 包含 16 个字符 block ,然后我给出“3”秒作为持续时间。将 FrameChangeAnimation 实例作为 CALayer 返回后,我将其附加到屏幕并流畅播放 [16 帧/秒]

现在我想将此动画导出为视频。问题是,当我这次附加 CABasicAnimation 时。 “持续时间”参数不起作用,所有帧都在一秒钟内播放。

    GTAnimation *an = [[GTAnimation alloc] initWithFrame:CGRectMake(0, 0, videoSize.width, videoSize.height) withFileName:@"Host_Angry_" withSeconds:3.5];

CALayer *animationLayer = [CALayer layer];
animationLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
[animationLayer addSublayer:an.animLayer];

CABasicAnimation *fadeAnimation = [CABasicAnimation animationWithKeyPath:@"currentFrame"];
fadeAnimation.fromValue = [NSNumber numberWithFloat:1.0];
fadeAnimation.toValue = [NSNumber numberWithFloat:45.0];
fadeAnimation.additive = NO;
fadeAnimation.removedOnCompletion = NO;
fadeAnimation.beginTime = 0.0;
fadeAnimation.duration = 3.5;
fadeAnimation.repeatCount = HUGE_VAL;
fadeAnimation.fillMode = kCAFillModeBoth;
[an.animLayer addAnimation:fadeAnimation forKey:@"currentFrame"];

CALayer *parentLayer = [CALayer layer];
CALayer *videoLayer = [CALayer layer];

videoLayer.bounds = CGRectMake(0, 0, videoSize.width, videoSize.height);
[parentLayer addSublayer:videoLayer];
[parentLayer addSublayer:animationLayer];
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 = [AVVideoCompositionCoreAnimationTool videoCompositionCoreAnimationToolWithPostProcessingAsVideoLayer:videoLayer inLayer:parentLayer];

最佳答案

根据 AVVideoCompositionCoreAnimationTool 类的文档,

“任何动画都将在视频的时间轴上进行解释,而不是实时的,因此您应该:

将动画的 beginTime 属性设置为 1e-100 而不是 0(CoreAnimation 将其替换为 CACurrentMediaTime);

关于ios - CFBasicAnimation 中带有自定义键的动画在导出视频时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10448482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com