remotion-dev / remotion

🎥 Make videos programmatically with React
https://remotion.dev
Other
20.6k stars 1.04k forks source link

Support assetsPath in @remotion/lottie #3667

Closed apolubek closed 7 months ago

apolubek commented 7 months ago

Feature Request 🛍️

lottie-web supports assetsPath parameter (https://github.com/airbnb/lottie-web/wiki/loadAnimation-options#assetspath) in order to specify root folder of used assets inside the animation. Right now it's only possible to use base64 encoded images inside to lottie json file.

Use Case

 <Lottie animationData={animationData} assetsPath={staticFile("public/path/to/lottie/assets/")} />

That would enable rendering lottie files which have name of the assets instead of base64 encoded images. We could parametrize path programatically to use the same lottie animation file with different assets instead of generating multiple lottie files with different base64 encoded images.

  "assets": [
    {
      "id": "image_0",
      "w": 300,
      "h": 300,
      "u": "",
      "p": "image_0.png",
      "e": 0
    },
  ]

Possible Solution

Adding optional parameter assetsPath to LottieProps type https://github.com/remotion-dev/remotion/blob/0687141bc90848aed874f91de6676ff354c3a942/packages/lottie/src/types.ts#L22 and pass it into lottie.loadAnimation function call.

https://github.com/remotion-dev/remotion/blob/0687141bc90848aed874f91de6676ff354c3a942/packages/lottie/src/Lottie.tsx#L52

JonnyBurger commented 7 months ago

Thanks, nice idea!