lottie-js icon indicating copy to clipboard operation
lottie-js copied to clipboard

merge and sequence multiple Lottie animation into single animation

Open anilsoniaurionpro opened this issue 2 years ago • 7 comments

Overview

Allow to merge or sequence several Lottie animations into single animation (JSON). Allow to dynamically create animation from other animations. ...

Type

  • [x] New feature
  • [ ] Changes to existing features

Motivation

What inspired this feature request? What problems were you facing, or what else makes you think this should be included? I am trying to create animation dynamically from existing animations and then export it as video on the frontend only. Right now, I have an internal file format that specifies the sequence, and the whole of exporting it to video is not fast as I've to deal with a sequence in the video too. A single Lottie is easy to deal with. ...

Labels

  • [x] Add the Type: Feature Request label to this issue.

anilsoniaurionpro avatar Mar 01 '22 08:03 anilsoniaurionpro

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

github-actions[bot] avatar May 01 '22 02:05 github-actions[bot]

👋@anilsoniaurionpro, I've got the exact same need for my current project. Did you make it somehow and if not, do you have any hints? Thanks for your help!

did avatar Feb 05 '23 14:02 did

👋@anilsoniaurionpro, I've got the exact same need for my current project. Did you make it somehow and if not, do you have any hints? Thanks for your help!

I didn't find any lib to do this. I ended up understanding enough lottie json schema to dynamically merge multiple animations (in js). In my case, I exported Lottie json with a specific structure and special settings in bodymovin like preserving ids etc to achieve this in easy manner.

anilsoniaurionpro avatar Feb 07 '23 05:02 anilsoniaurionpro

thanks @anilsoniaurionpro. I managed to merge my 2 lottie files (same width / height / frames) by doing the same stuff as you did. It wasn't that hard actually, the only "issue" was to rename the refID in the Precomposition layers using some assets.

did avatar Feb 07 '23 07:02 did

thanks @anilsoniaurionpro. I managed to merge my 2 lottie files (same width / height / frames) by doing the same stuff as you did. It wasn't that hard actually, the only "issue" was to rename the refID in the Precomposition layers using some assets.

Before merging I did string replacement . Like jsonStr.replaceAll("comp1", nanoid()). do this for comp0 ... to comp20. Assuming there are max of 21 comps. Same for assets.

anilsoniaurionpro avatar Feb 07 '23 08:02 anilsoniaurionpro

I created a method that took a lottie json and returns a new lottie json (which merges all the layers into a precomp first). this process involved string replacement to solve refID , assetId issues and moving all the layers to assets. so the layer contains only a single layer which is the comp. this makes it easy to adjust timings.

After this multiple json are merged in single one. this includes merging all layers , assets , fonts, markers , chars etc.

anilsoniaurionpro avatar Feb 07 '23 13:02 anilsoniaurionpro

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs.

github-actions[bot] avatar Apr 09 '23 01:04 github-actions[bot]