项目作者: damikdk

项目描述 :
[BUG DEMO] Demonstration of AVAssetExportSession export NOT working correctly with lottie-ios
高级语言: Swift
项目地址: git://github.com/damikdk/LottieExportDemo.git
创建时间: 2019-09-10T19:02:12Z
项目社区:https://github.com/damikdk/LottieExportDemo

开源协议:

下载


LottieExportDemo

Demo project with Lottie-animation export with both AVAssetExportSession and AVAssetWriter. AVAssetWriter works fine, but AVAssetExportSession DOESN’T. We plan to use this method to export videos with any content inside: images, videos, animations and sound.

What is happening

We have a Lottie-animations and we need to export it as video on iPhone. Our current AVAssetWriter implementation and frame-by-frame rendering is too slow, so we want to make it faster.

What is the problem

We have AVAssetExportSession export implementation, but it works wrong because of lottie-ios architecture.

How our AVAssetExportSession works

We create AVMutableVideoComposition and add AnimationView.layer (CALayer) on it by AVVideoCompositionCoreAnimationTool. Then just export it with AVAssetExportSession:

https://github.com/damikdk/LottieExportDemo/blob/ddb256e209d0f6a5a02f419f4fcc54eb56519c5e/LottieExportDemo/ViewController.swift#L136

What’s wrong with it

Timings are broken for AVAssetExportSession and animation is much slower on result video.

More details

Why does it even run? (important)

I removed this line from AnimationView:

  1. guard self.window != nil else { waitingToPlayAimation = true; return }