π₯ Make videos programmatically with React
after effects tutorial
Jonny Burger30bd6d7541f3
diff --git a/packages/docs/components/InlineStep.tsx b/packages/docs/components/InlineStep.tsxnew file mode 100644index 0000000000..c2b3f7cd7f--- /dev/null+++ b/packages/docs/components/InlineStep.tsx@@ -0,0 +1,24 @@+import React from "react";++export const InlineStep: React.FC<{+ children: React.ReactNode;+}> = ({ children }) => {+ return (+ <div+ style={{+ backgroundColor: "var(--ifm-color-primary)",+ height: 24,+ width: 24,+ display: "inline-flex",+ color: "white",+ justifyContent: "center",+ alignItems: "center",+ borderRadius: 12,+ fontSize: 13,+ fontWeight: "bold",+ }}+ >+ {children}+ </div>+ );+};diff --git a/packages/docs/docs/lottie/lottie-aftereffects.md b/packages/docs/docs/lottie/lottie-aftereffects.mdnew file mode 100644index 0000000000..99d2eea561--- /dev/null+++ b/packages/docs/docs/lottie/lottie-aftereffects.md@@ -0,0 +1,91 @@+---+id: lottie-aftereffects+title: Import from After Effects+slug: aftereffects+---++import {InlineStep} from '../../components/InlineStep';++If you are a After Effects user, you might find it useful to convert your After Effects compositions to Remotion compositions. You can use the [`@remotion/lottie`](/docs/lottie) package for this.++:::note+Remotion compositions got their name because After Effects coined this term!+:::++### Install the Bodymovin plugin++- Make sure After Effects is closed.+- Go to [this site](https://aescripts.com/learn/zxp-installer/) and download the ZXP installer for your platform.+- Click [here](https://github.com/airbnb/lottie-web/blob/master/build/extension/bodymovin.zxp?raw=true) to download the latest Bodymovin plugin.+- Open the ZXP installer and drag the bodymovin file into it.++### Create a composition++Open After Effects and create a new project and then click `New composition`.++<img src="/img/lottie/new-composition.png"/>++### Create your animation++Design your animation in After Effects. In this basic example, we used the rounded rectangle tool to draw a blue rounded square and then opened the transform menu and clicked the stopwatch icon to set keyframes for position and rotation to create a simple entrance effect.++<img src="/img/lottie/animation.png"/>++### Allow export as JSON++In the After Effects menu, go to `Preferences -> Scripting & Expressions...`. Enable the first option: `Allow Scripts to Write Files and Access Network`. You only need to do this once.++<img src="/img/lottie/scripting.png"/>++### Open the Bodymovin plugin++In the After Effects menu, go to `Window -> Extensions -> Bodymovin`.++<img src="/img/lottie/bodymovin.png"/>++### Export the animation as JSON++First, select the composition <InlineStep>1</InlineStep>. Then press the export icon <InlineStep>2</InlineStep>. You will be prompted for a location to save the JSON file.+Click Render <InlineStep>3</InlineStep> to write the file.+<img src="/img/lottie/bodymovin-tutorial.png"/>++### Import the file into Remotion++Copy the file into the Remotion project. The recommended way is to the the JSON inside the `public/` folder of Remotion (create it if necessary) and then load it using [`staticFile()`](/docs/staticfile):++```tsx twoslash title="Animation.tsx"+import { continueRender, delayRender, staticFile } from "remotion";+import { useEffect, useState } from "react";+import { Lottie, LottieAnimationData } from "@remotion/lottie";++const Balloons = () => {+ const [handle] = useState(() => delayRender("Loading Lottie animation"));++ const [animationData, setAnimationData] =+ useState<LottieAnimationData | null>(null);++ useEffect(() => {+ fetch(staticFile("animation.json"))+ .then((data) => data.json())+ .then((json) => {+ setAnimationData(json);+ continueRender(handle);+ })+ .catch((err) => {+ console.log("Animation failed to load", err);+ });+ }, [handle]);++ if (!animationData) {+ return null;+ }++ return <Lottie animationData={animationData} />;+};+```++## Finetuning++It is advised to make your composition the same size and duration as the original composition in After Effects. Congrats, you're playing an After Effects animation in Remotion! π++<img src="/img/lottie/result.gif"/>diff --git a/packages/docs/docs/lottie/lottie-staticfile.md b/packages/docs/docs/lottie/lottie-staticfile.mdindex 4cdf673920..73b8ab2c1b 100644--- a/packages/docs/docs/lottie/lottie-staticfile.md+++ b/packages/docs/docs/lottie/lottie-staticfile.md@@ -14,14 +14,14 @@ import { continueRender, delayRender, staticFile } from "remotion";import { useEffect, useState } from "react";import { Lottie, LottieAnimationData } from "@remotion/lottie";-const Balloons = () => {+const Square = () => {const [handle] = useState(() => delayRender("Loading Lottie animation"));const [animationData, setAnimationData] =useState<LottieAnimationData | null>(null);useEffect(() => {- fetch(staticFile("animation.json"))+ fetch(staticFile("data.json")).then((data) => data.json()).then((json) => {setAnimationData(json);diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.jsindex f47ca193c2..5f61d4ba3e 100644--- a/packages/docs/sidebars.js+++ b/packages/docs/sidebars.js@@ -238,6 +238,7 @@ module.exports = {"lottie/lottie-comp","lottie/lottie-staticfile","lottie/lottie-remote",+ "lottie/lottie-aftereffects",],},{diff --git a/packages/docs/static/img/lottie/animation.png b/packages/docs/static/img/lottie/animation.pngnew file mode 100644index 0000000000..68571238c3Binary files /dev/null and b/packages/docs/static/img/lottie/animation.png differdiff --git a/packages/docs/static/img/lottie/bodymovin-tutorial.png b/packages/docs/static/img/lottie/bodymovin-tutorial.pngnew file mode 100644index 0000000000..42d4df4a62Binary files /dev/null and b/packages/docs/static/img/lottie/bodymovin-tutorial.png differdiff --git a/packages/docs/static/img/lottie/bodymovin.png b/packages/docs/static/img/lottie/bodymovin.pngnew file mode 100644index 0000000000..bbc06562c2Binary files /dev/null and b/packages/docs/static/img/lottie/bodymovin.png differdiff --git a/packages/docs/static/img/lottie/new-composition.png b/packages/docs/static/img/lottie/new-composition.pngnew file mode 100644index 0000000000..e86d5e5387Binary files /dev/null and b/packages/docs/static/img/lottie/new-composition.png differdiff --git a/packages/docs/static/img/lottie/result.gif b/packages/docs/static/img/lottie/result.gifnew file mode 100644index 0000000000..9b739a5c51Binary files /dev/null and b/packages/docs/static/img/lottie/result.gif differdiff --git a/packages/docs/static/img/lottie/scripting.png b/packages/docs/static/img/lottie/scripting.pngnew file mode 100644index 0000000000..305832acaeBinary files /dev/null and b/packages/docs/static/img/lottie/scripting.png differdiff --git a/packages/example/public/lottie.json b/packages/example/public/lottie.jsonnew file mode 100644index 0000000000..9e77077161--- /dev/null+++ b/packages/example/public/lottie.json@@ -0,0 +1 @@+{"v":"5.9.6","fr":29.9700012207031,"ip":0,"op":90.0000036657751,"w":1920,"h":1080,"nm":"Comp 1","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[360]},{"t":58.0000023623884,"s":[0]}],"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[979.401,1368,0],"to":[0,-138,0],"ti":[0,138,0]},{"t":58.0000023623884,"s":[979.401,540,0]}],"ix":2,"l":2},"a":{"a":0,"k":[517.365,112.096,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[425.883,425.883],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":98,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.468933612108,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[494.618,123.481],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 2","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":90.0000036657751,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":1,"nm":"White Solid 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[960,540,0],"ix":2,"l":2},"a":{"a":0,"k":[960,540,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"sw":1920,"sh":1080,"sc":"#ffffff","ip":0,"op":90.0000036657751,"st":0,"bm":0}],"markers":[]}\ No newline at end of file