Skip to content

🎥 Make videos programmatically with React

add overlay template + tailwind support

Jonny Burger01531bb99795
diff --git a/packages/create-video/src/templates.tsx b/packages/create-video/src/templates.tsx
index 88637e2caa..19ad447e17 100644
--- a/packages/create-video/src/templates.tsx
+++ b/packages/create-video/src/templates.tsx
@@ -376,8 +376,8 @@ export const FEATURED_TEMPLATES: Template[] = [
defaultBranch: 'main',
featuredOnHomePage: null,
previewURL: null,
- templateInMonorepo: null,
- allowEnableTailwind: false,
+ templateInMonorepo: 'template-overlay',
+ allowEnableTailwind: true,
},
{
homePageLabel: 'Code Hike',
diff --git a/packages/template-overlay/.eslintrc b/packages/template-overlay/.eslintrc
new file mode 100644
index 0000000000..67f9fd93c1
--- /dev/null
+++ b/packages/template-overlay/.eslintrc
@@ -0,0 +1,3 @@
+{
+ "extends": "@remotion",
+}
diff --git a/packages/template-overlay/.github/workflows/render-video.yml b/packages/template-overlay/.github/workflows/render-video.yml
new file mode 100644
index 0000000000..8fdd260f8a
--- /dev/null
+++ b/packages/template-overlay/.github/workflows/render-video.yml
@@ -0,0 +1,21 @@
+on: workflow_dispatch
+
+name: Render video
+jobs:
+ render:
+ name: Render video
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@main
+ - uses: actions/setup-node@main
+ - run: sudo apt update
+ - run: sudo apt install ffmpeg
+ - run: npm i
+ - run: echo $WORKFLOW_INPUT > input-props.json
+ env:
+ WORKFLOW_INPUT: ${{ toJson(github.event.inputs) }}
+ - run: npm run build -- --props="./input-props.json"
+ - uses: actions/upload-artifact@v2
+ with:
+ name: video.mp4
+ path: out/video.mp4
diff --git a/packages/template-overlay/.gitignore b/packages/template-overlay/.gitignore
new file mode 100644
index 0000000000..d4c3477585
--- /dev/null
+++ b/packages/template-overlay/.gitignore
@@ -0,0 +1,8 @@
+node_modules
+dist
+.DS_Store
+.env
+
+# Ignore the output video from Git but not videos you import into src/.
+out
+package-lock.json
diff --git a/packages/template-overlay/.prettierrc b/packages/template-overlay/.prettierrc
new file mode 100644
index 0000000000..37d5071748
--- /dev/null
+++ b/packages/template-overlay/.prettierrc
@@ -0,0 +1,5 @@
+{
+ "useTabs": false,
+ "bracketSpacing": true,
+ "tabWidth": 2
+}
diff --git a/packages/template-overlay/.vscode/settings.json b/packages/template-overlay/.vscode/settings.json
new file mode 100644
index 0000000000..9165da4444
--- /dev/null
+++ b/packages/template-overlay/.vscode/settings.json
@@ -0,0 +1,5 @@
+{
+ "editor.tabSize": 2,
+ "typescript.tsdk": "node_modules/typescript/lib",
+ "typescript.enablePromptUseWorkspaceTsdk": true
+}
diff --git a/packages/template-overlay/README.md b/packages/template-overlay/README.md
new file mode 100644
index 0000000000..3c6594d20d
--- /dev/null
+++ b/packages/template-overlay/README.md
@@ -0,0 +1,54 @@
+# Remotion video
+
+<p align="center">
+ <a href="https://github.com/remotion-dev/logo">
+ <picture>
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/remotion-dev/logo/raw/main/animated-logo-banner-dark.gif">
+ <img alt="Animated Remotion Logo" src="https://github.com/remotion-dev/logo/raw/main/animated-logo-banner-light.gif">
+ </picture>
+ </a>
+</p>
+
+Welcome to your Remotion project!
+
+## Commands
+
+**Install Dependencies**
+
+```console
+npm i
+```
+
+**Start Preview**
+
+```console
+npm start
+```
+
+**Render video**
+
+```console
+npm run build
+```
+
+**Upgrade Remotion**
+
+```console
+npm run upgrade
+```
+
+## Docs
+
+Get started with Remotion by reading the [fundamentals page](https://www.remotion.dev/docs/the-fundamentals).
+
+## Help
+
+We provide help on our [Discord server](https://discord.gg/6VzzNDwUwV).
+
+## Issues
+
+Found an issue with Remotion? [File an issue here](https://github.com/remotion-dev/remotion/issues/new).
+
+## License
+
+Note that for some entities a company license is needed. [Read the terms here](https://github.com/remotion-dev/remotion/blob/main/LICENSE.md).
diff --git a/packages/template-overlay/package.json b/packages/template-overlay/package.json
new file mode 100644
index 0000000000..a55af4428f
--- /dev/null
+++ b/packages/template-overlay/package.json
@@ -0,0 +1,29 @@
+{
+ "name": "template-overlay",
+ "version": "1.0.0",
+ "description": "My Remotion video",
+ "scripts": {
+ "start": "remotion studio",
+ "build": "remotion render",
+ "upgrade": "remotion upgrade",
+ "test": "eslint src --ext ts,tsx,js,jsx && tsc"
+ },
+ "repository": {},
+ "license": "UNLICENSED",
+ "devDependencies": {
+ "@remotion/eslint-config": "workspace:*",
+ "@types/react": "18.3.1",
+ "@types/web": "0.0.78",
+ "eslint": "8.56.0",
+ "prettier": "3.2.5",
+ "typescript": "5.3.3"
+ },
+ "dependencies": {
+ "@remotion/cli": "workspace:*",
+ "@remotion/google-fonts": "workspace:*",
+ "react": "18.3.1",
+ "react-dom": "18.3.1",
+ "remotion": "workspace:*"
+ },
+ "private": true
+}
diff --git a/packages/template-overlay/remotion.config.ts b/packages/template-overlay/remotion.config.ts
new file mode 100644
index 0000000000..8aadfc9bba
--- /dev/null
+++ b/packages/template-overlay/remotion.config.ts
@@ -0,0 +1,13 @@
+// See all configuration options: https://remotion.dev/docs/config
+// Each option also is available as a CLI flag: https://remotion.dev/docs/cli
+
+// Note: When using the Node.JS APIs, the config file doesn't apply. Instead, pass options directly to the APIs
+// All configuration options: https://remotion.dev/docs/config
+
+import { Config } from "@remotion/cli/config";
+
+Config.setVideoImageFormat("png");
+Config.setPixelFormat("yuva444p10le");
+Config.setCodec("prores");
+Config.setProResProfile("4444");
+Config.setMuted(true);
diff --git a/packages/template-overlay/src/Overlay.tsx b/packages/template-overlay/src/Overlay.tsx
new file mode 100644
index 0000000000..1b59d25a2d
--- /dev/null
+++ b/packages/template-overlay/src/Overlay.tsx
@@ -0,0 +1,74 @@
+import {
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
+} from "remotion";
+import React, { useMemo } from "react";
+import { loadFont } from "@remotion/google-fonts/Roboto";
+
+const { fontFamily } = loadFont();
+
+const title: React.CSSProperties = {
+ fontFamily,
+ fontSize: 80,
+ fontWeight: "bold",
+};
+
+const text: React.CSSProperties = {
+ fontWeight: "bold",
+ fontFamily,
+ fontSize: 40,
+ color: "#4290F5",
+};
+
+const disappearBeforeEnd = 20;
+
+export const Overlay: React.FC = () => {
+ const frame = useCurrentFrame();
+ const { fps, durationInFrames } = useVideoConfig();
+
+ const scale = spring({
+ fps,
+ frame,
+ config: {
+ mass: 0.5,
+ },
+ });
+
+ const out = spring({
+ fps,
+ frame: frame - durationInFrames + disappearBeforeEnd,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: disappearBeforeEnd,
+ });
+
+ const rotate = interpolate(out, [0, 1], [0, -Math.PI / 20]);
+ const outY = interpolate(out, [0, 1], [0, -500]);
+
+ const container: React.CSSProperties = useMemo(() => {
+ return {
+ position: "absolute",
+ backgroundColor: "white",
+ borderRadius: 25,
+ right: 90,
+ top: 90,
+ scale: String(scale),
+ translate: `0 ${outY}px`,
+ rotate: `${rotate}rad`,
+ padding: 40,
+ };
+ }, [scale, outY, rotate]);
+
+ return (
+ <AbsoluteFill>
+ <div style={container}>
+ <div style={title}>Look</div>
+ <div style={text}>I'm an overlay!</div>
+ </div>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/template-overlay/src/Root.tsx b/packages/template-overlay/src/Root.tsx
new file mode 100644
index 0000000000..984bc727cc
--- /dev/null
+++ b/packages/template-overlay/src/Root.tsx
@@ -0,0 +1,17 @@
+import { Composition } from "remotion";
+import { Overlay } from "./Overlay";
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <>
+ <Composition
+ id="Overlay"
+ component={Overlay}
+ durationInFrames={75}
+ fps={30}
+ width={1920}
+ height={1080}
+ />
+ </>
+ );
+};
diff --git a/packages/template-overlay/src/index.ts b/packages/template-overlay/src/index.ts
new file mode 100644
index 0000000000..f31c790edb
--- /dev/null
+++ b/packages/template-overlay/src/index.ts
@@ -0,0 +1,4 @@
+import { registerRoot } from "remotion";
+import { RemotionRoot } from "./Root";
+
+registerRoot(RemotionRoot);
diff --git a/packages/template-overlay/tsconfig.json b/packages/template-overlay/tsconfig.json
new file mode 100644
index 0000000000..0a292af5f2
--- /dev/null
+++ b/packages/template-overlay/tsconfig.json
@@ -0,0 +1,15 @@
+{
+ "compilerOptions": {
+ "target": "ES2018",
+ "module": "commonjs",
+ "jsx": "react-jsx",
+ "outDir": "./dist",
+ "strict": true,
+ "noEmit": true,
+ "lib": ["es2015"],
+ "esModuleInterop": true,
+ "skipLibCheck": true,
+ "forceConsistentCasingInFileNames": true,
+ "noUnusedLocals": true
+ }
+}
diff --git a/packages/template-skia/package.json b/packages/template-skia/package.json
index c0bb8a8887..0085ec49c1 100644
--- a/packages/template-skia/package.json
+++ b/packages/template-skia/package.json
@@ -28,5 +28,6 @@
"eslint": "8.56.0",
"prettier": "3.2.5",
"typescript": "5.3.3"
- }
+ },
+ "private": true
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 85d0f93236..6ccd99a7b2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1821,6 +1821,43 @@ importers:
specifier: 5.3.3
version: 5.3.3
+ packages/template-overlay:
+ dependencies:
+ '@remotion/cli':
+ specifier: workspace:*
+ version: link:../cli
+ '@remotion/google-fonts':
+ specifier: workspace:*
+ version: link:../google-fonts
+ react:
+ specifier: 18.3.1
+ version: 18.3.1
+ react-dom:
+ specifier: 18.3.1
+ version: 18.3.1([email protected])
+ remotion:
+ specifier: workspace:*
+ version: link:../core
+ devDependencies:
+ '@remotion/eslint-config':
+ specifier: workspace:*
+ version: link:../eslint-config
+ '@types/react':
+ specifier: 18.3.1
+ version: 18.3.1
+ '@types/web':
+ specifier: 0.0.78
+ version: 0.0.78
+ eslint:
+ specifier: 8.56.0
+ version: 8.56.0
+ prettier:
+ specifier: 3.2.5
+ version: 3.2.5
+ typescript:
+ specifier: 5.3.3
+ version: 5.3.3
+
packages/template-skia:
dependencies:
'@remotion/cli':
@@ -1851,6 +1888,9 @@ importers:
'@remotion/eslint-config':
specifier: workspace:*
version: link:../eslint-config
+ '@types/dom-webcodecs':
+ specifier: 0.1.11
+ version: 0.1.11
'@types/react':
specifier: 18.3.1
version: 18.3.1
diff --git a/tsconfig.json b/tsconfig.json
index 622b97f04d..1a3d53914a 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -132,6 +132,9 @@
{
"path": "./packages/template-helloworld"
},
+ {
+ "path": "./packages/template-overlay"
+ },
{
"path": "./packages/studio"
},