Skip to content

🎥 Make videos programmatically with React

expoert og images

Jonny Burger31f0548b0af5
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 0d50998f61..d8c3c0b90f 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -13,7 +13,8 @@
"serve": "docusaurus serve",
"clear": "docusaurus clear",
"lint": "eslint src && eslint components",
- "test": "vitest --run"
+ "test": "vitest --run",
+ "remotion": "remotion preview src/remotion/entry.ts"
},
"dependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.15.4",
@@ -26,6 +27,7 @@
"@mdx-js/react": "^1.6.21",
"@remotion/babel-loader": "3.2.44",
"@remotion/bundler": "3.2.44",
+ "@remotion/cli": "3.2.44",
"@remotion/gif": "3.2.44",
"@remotion/google-fonts": "3.2.44",
"@remotion/lambda": "3.2.44",
diff --git a/packages/docs/remotion.config.ts b/packages/docs/remotion.config.ts
new file mode 100644
index 0000000000..f49bf48d98
--- /dev/null
+++ b/packages/docs/remotion.config.ts
@@ -0,0 +1,4 @@
+import path from "path";
+import { Config } from "remotion";
+
+Config.Bundling.setPublicDir(path.join(process.cwd(), "static"));
diff --git a/packages/docs/src/remotion/Expert.tsx b/packages/docs/src/remotion/Expert.tsx
new file mode 100644
index 0000000000..cedd0c09c9
--- /dev/null
+++ b/packages/docs/src/remotion/Expert.tsx
@@ -0,0 +1,97 @@
+import React from "react";
+import { AbsoluteFill, Img, staticFile } from "remotion";
+import { experts } from "../data/experts";
+import "./font.css";
+
+export const Expert: React.FC<{
+ expertId: string;
+}> = ({ expertId }) => {
+ const expert = experts.find((e) => e.slug === expertId);
+
+ return (
+ <AbsoluteFill
+ style={{
+ height: "100%",
+ width: "100%",
+ display: "flex",
+ backgroundColor: "#fff",
+ fontSize: 32,
+ fontWeight: 600,
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <div>
+ <div
+ style={{
+ display: "flex",
+ flexDirection: "row",
+ alignItems: "center",
+ height: 150,
+ backgroundColor: "#222",
+ paddingRight: 40,
+ }}
+ >
+ <div
+ style={{
+ flex: 1,
+ fontFamily: "GTPlanar",
+ color: "white",
+ height: "100%",
+ display: "flex",
+ alignItems: "center",
+ paddingLeft: 40,
+ fontSize: 40,
+ }}
+ >
+ Experts
+ </div>
+ <div
+ style={{
+ height: "100%",
+ display: "flex",
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <Img
+ style={{
+ height: 60,
+ }}
+ src="https://www.remotion.dev/img/remotion-white.png"
+ />
+ </div>
+ </div>
+ <div
+ style={{
+ height: 350,
+ display: "flex",
+ flexDirection: "row",
+ }}
+ >
+ <Img height="350" src={staticFile(expert.image)} />
+ <div
+ style={{
+ width: 700,
+ backgroundColor: "#0B84F3",
+ display: "flex",
+ justifyContent: "flex-end",
+ alignItems: "flex-end",
+ padding: 50,
+ }}
+ >
+ <div
+ style={{
+ color: "white",
+ fontFamily: "GTPlanar",
+ fontSize: 60,
+ }}
+ >
+ {expert.name}
+ </div>
+ </div>
+ </div>
+ </div>
+ </AbsoluteFill>
+ );
+};
diff --git a/packages/docs/src/remotion/Root.tsx b/packages/docs/src/remotion/Root.tsx
new file mode 100644
index 0000000000..52037bfc9a
--- /dev/null
+++ b/packages/docs/src/remotion/Root.tsx
@@ -0,0 +1,25 @@
+import React from "react";
+import { Folder, Still } from "remotion";
+import { experts } from "../data/experts";
+import { Expert } from "./Expert";
+
+export const RemotionRoot: React.FC = () => {
+ return (
+ <Folder name="experts">
+ {experts.map((e) => {
+ return (
+ <Still
+ key={e.slug}
+ component={Expert}
+ defaultProps={{
+ expertId: e.slug,
+ }}
+ height={630}
+ width={1200}
+ id={`${e.slug}`}
+ />
+ );
+ })}
+ </Folder>
+ );
+};
diff --git a/packages/docs/src/remotion/entry.ts b/packages/docs/src/remotion/entry.ts
new file mode 100644
index 0000000000..f31c790edb
--- /dev/null
+++ b/packages/docs/src/remotion/entry.ts
@@ -0,0 +1,4 @@
+import { registerRoot } from "remotion";
+import { RemotionRoot } from "./Root";
+
+registerRoot(RemotionRoot);
diff --git a/packages/docs/src/remotion/font.css b/packages/docs/src/remotion/font.css
new file mode 100644
index 0000000000..79e4aa72ab
--- /dev/null
+++ b/packages/docs/src/remotion/font.css
@@ -0,0 +1,6 @@
+@font-face {
+ font-family: "GTPlanar";
+ src: url("../../static/img/gt-planar-bold.woff2") format("woff2");
+ font-weight: 900;
+ font-style: normal;
+}
diff --git a/packages/example/src/Expert/index.tsx b/packages/example/src/Expert/index.tsx
new file mode 100644
index 0000000000..304d012d47
--- /dev/null
+++ b/packages/example/src/Expert/index.tsx
@@ -0,0 +1,60 @@
+import React from 'react';
+import {Img} from 'remotion';
+
+export const Expert: React.FC = () => {
+ return (
+ <div
+ style={{
+ height: '100%',
+ width: '100%',
+ display: 'flex',
+ backgroundColor: '#fff',
+ fontSize: 32,
+ fontWeight: 600,
+ }}
+ >
+ <div
+ style={{
+ position: 'absolute',
+ height: 350,
+ width: 700,
+ left: 60,
+ top: 230,
+ backgroundColor: '#0B84F3',
+ }}
+ />
+ <Img
+ width="400"
+ height="160"
+ src="https://jonnyburger.s3.eu-central-1.amazonaws.com/element-0+(1).png"
+ style={{
+ top: 50,
+ left: 43,
+ position: 'absolute',
+ }}
+ />
+ <Img
+ width="350"
+ height="350"
+ src="https://www.remotion.dev/img/freelancers/benjamin.jpeg"
+ style={{
+ top: 230,
+ left: 750,
+ position: 'absolute',
+ }}
+ />
+ <div
+ style={{
+ bottom: 90,
+ left: 100,
+ position: 'absolute',
+ color: 'white',
+ fontFamily: 'GTPlanar',
+ fontSize: 60,
+ }}
+ >
+ Benjamin Jameson
+ </div>
+ </div>
+ );
+};
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 99662718f2..6d35c4b49c 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -7,6 +7,7 @@ import {ColorInterpolation} from './ColorInterpolation';
import {MyCtx, WrappedInContext} from './Context';
import CorruptVideo from './CorruptVideo';
import {ErrorOnFrame10} from './ErrorOnFrame10';
+import {Expert} from './Expert';
import {FontDemo} from './Fonts';
import {Framer} from './Framer';
import {FreezeExample} from './Freeze/FreezeExample';
@@ -536,6 +537,16 @@ export const Index: React.FC = () => {
durationInFrames={150}
/>
</Folder>
+ <Folder name="og-images">
+ <Composition
+ id="expert"
+ component={Expert}
+ width={1200}
+ height={630}
+ fps={30}
+ durationInFrames={150}
+ />
+ </Folder>
</>
);
};
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6be28ad846..7c7dd74454 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -267,6 +267,7 @@ importers:
'@mdx-js/react': ^1.6.21
'@remotion/babel-loader': 3.2.44
'@remotion/bundler': 3.2.44
+ '@remotion/cli': 3.2.44
'@remotion/gif': 3.2.44
'@remotion/google-fonts': 3.2.44
'@remotion/lambda': 3.2.44
@@ -318,6 +319,7 @@ importers:
'@mdx-js/react': [email protected]
'@remotion/babel-loader': link:../babel-loader
'@remotion/bundler': link:../bundler
+ '@remotion/cli': link:../cli
'@remotion/gif': link:../gif
'@remotion/google-fonts': link:../google-fonts
'@remotion/lambda': link:../lambda