Skip to content

🎥 Make videos programmatically with React

run prettier

umungobungo452a86111d68
diff --git a/packages/template-vercel/src/app/api/render/route.ts b/packages/template-vercel/src/app/api/render/route.ts
index 22115f7a10..c37d629436 100644
--- a/packages/template-vercel/src/app/api/render/route.ts
+++ b/packages/template-vercel/src/app/api/render/route.ts
@@ -1,171 +1,171 @@
import { Sandbox } from "@vercel/sandbox";
import { RenderRequest } from "../../../../types/schema";
import {
- COMP_NAME,
- DURATION_IN_FRAMES,
- VIDEO_FPS,
- VIDEO_HEIGHT,
- VIDEO_WIDTH,
+ COMP_NAME,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
} from "../../../../types/constants";
const REPO_URL = "https://github.com/remotion-dev/template-vercel.git";
type SSEMessage =
- | { type: "log"; stream: "stdout" | "stderr"; data: string }
- | { type: "phase"; phase: string }
- | { type: "done"; url: string; size: number }
- | { type: "error"; message: string };
+ | { type: "log"; stream: "stdout" | "stderr"; data: string }
+ | { type: "phase"; phase: string }
+ | { type: "done"; url: string; size: number }
+ | { type: "error"; message: string };
function formatSSE(message: SSEMessage): string {
- return `data: ${JSON.stringify(message)}\n\n`;
+ return `data: ${JSON.stringify(message)}\n\n`;
}
export async function POST(req: Request) {
- let sandbox: Sandbox | null = null;
-
- const encoder = new TextEncoder();
- const stream = new TransformStream();
- const writer = stream.writable.getWriter();
-
- const send = async (message: SSEMessage) => {
- await writer.write(encoder.encode(formatSSE(message)));
- };
-
- const runRender = async () => {
- try {
- const payload = await req.json();
- const body = RenderRequest.parse(payload);
-
- await send({ type: "phase", phase: "Creating sandbox..." });
-
- sandbox = await Sandbox.create({
- runtime: "node24",
- timeout: 5 * 60 * 1000,
- source: {
- type: "git",
- url: REPO_URL,
- },
- });
-
- await send({ type: "phase", phase: "Installing system dependencies..." });
-
- const sysInstallCmd = await sandbox.runCommand({
- cmd: "sudo",
- args: [
- "dnf",
- "install",
- "-y",
- "nss",
- "atk",
- "at-spi2-atk",
- "cups-libs",
- "libdrm",
- "libXcomposite",
- "libXdamage",
- "libXrandr",
- "mesa-libgbm",
- "alsa-lib",
- "pango",
- "gtk3",
- ],
- detached: true,
- });
-
- for await (const log of sysInstallCmd.logs()) {
- await send({ type: "log", stream: log.stream, data: log.data });
- }
-
- const sysInstallResult = await sysInstallCmd.wait();
- if (sysInstallResult.exitCode !== 0) {
- throw new Error(
- `System dependencies install failed: ${await sysInstallResult.stderr()}`,
- );
- }
-
- await send({ type: "phase", phase: "Installing npm dependencies..." });
-
- const installCmd = await sandbox.runCommand({
- cmd: "pnpm",
- args: ["install"],
- detached: true,
- });
-
- for await (const log of installCmd.logs()) {
- await send({ type: "log", stream: log.stream, data: log.data });
- }
-
- const installResult = await installCmd.wait();
- if (installResult.exitCode !== 0) {
- throw new Error(`pnpm install failed: ${await installResult.stderr()}`);
- }
-
- await send({ type: "phase", phase: "Rendering video..." });
-
- const renderCmd = await sandbox.runCommand({
- cmd: "pnpm",
- args: [
- "exec",
- "remotion",
- "render",
- "src/remotion/index.ts",
- COMP_NAME,
- "out/video.mp4",
- "--props",
- JSON.stringify(body.inputProps),
- "--width",
- String(VIDEO_WIDTH),
- "--height",
- String(VIDEO_HEIGHT),
- "--fps",
- String(VIDEO_FPS),
- "--frames",
- `0-${DURATION_IN_FRAMES - 1}`,
- ],
- detached: true,
- });
-
- for await (const log of renderCmd.logs()) {
- await send({ type: "log", stream: log.stream, data: log.data });
- }
-
- const renderResult = await renderCmd.wait();
- if (renderResult.exitCode !== 0) {
- const stderr = await renderResult.stderr();
- const stdout = await renderResult.stdout();
- throw new Error(`Render failed: ${stderr || stdout}`);
- }
-
- await send({ type: "phase", phase: "Reading output..." });
-
- const videoBuffer = await sandbox.readFileToBuffer({
- path: "out/video.mp4",
- });
- if (!videoBuffer) {
- throw new Error("Failed to read rendered video");
- }
-
- await send({
- type: "done",
- url: `data:video/mp4;base64,${videoBuffer.toString("base64")}`,
- size: videoBuffer.length,
- });
- } catch (err) {
- await send({ type: "error", message: (err as Error).message });
- } finally {
- if (sandbox) {
- await sandbox.stop().catch(() => {});
- }
- await writer.close();
- }
- };
-
- runRender();
-
- return new Response(stream.readable, {
- headers: {
- "Content-Type": "text/event-stream",
- "Cache-Control": "no-cache",
- Connection: "keep-alive",
- },
- });
+ let sandbox: Sandbox | null = null;
+
+ const encoder = new TextEncoder();
+ const stream = new TransformStream();
+ const writer = stream.writable.getWriter();
+
+ const send = async (message: SSEMessage) => {
+ await writer.write(encoder.encode(formatSSE(message)));
+ };
+
+ const runRender = async () => {
+ try {
+ const payload = await req.json();
+ const body = RenderRequest.parse(payload);
+
+ await send({ type: "phase", phase: "Creating sandbox..." });
+
+ sandbox = await Sandbox.create({
+ runtime: "node24",
+ timeout: 5 * 60 * 1000,
+ source: {
+ type: "git",
+ url: REPO_URL,
+ },
+ });
+
+ await send({ type: "phase", phase: "Installing system dependencies..." });
+
+ const sysInstallCmd = await sandbox.runCommand({
+ cmd: "sudo",
+ args: [
+ "dnf",
+ "install",
+ "-y",
+ "nss",
+ "atk",
+ "at-spi2-atk",
+ "cups-libs",
+ "libdrm",
+ "libXcomposite",
+ "libXdamage",
+ "libXrandr",
+ "mesa-libgbm",
+ "alsa-lib",
+ "pango",
+ "gtk3",
+ ],
+ detached: true,
+ });
+
+ for await (const log of sysInstallCmd.logs()) {
+ await send({ type: "log", stream: log.stream, data: log.data });
+ }
+
+ const sysInstallResult = await sysInstallCmd.wait();
+ if (sysInstallResult.exitCode !== 0) {
+ throw new Error(
+ `System dependencies install failed: ${await sysInstallResult.stderr()}`,
+ );
+ }
+
+ await send({ type: "phase", phase: "Installing npm dependencies..." });
+
+ const installCmd = await sandbox.runCommand({
+ cmd: "pnpm",
+ args: ["install"],
+ detached: true,
+ });
+
+ for await (const log of installCmd.logs()) {
+ await send({ type: "log", stream: log.stream, data: log.data });
+ }
+
+ const installResult = await installCmd.wait();
+ if (installResult.exitCode !== 0) {
+ throw new Error(`pnpm install failed: ${await installResult.stderr()}`);
+ }
+
+ await send({ type: "phase", phase: "Rendering video..." });
+
+ const renderCmd = await sandbox.runCommand({
+ cmd: "pnpm",
+ args: [
+ "exec",
+ "remotion",
+ "render",
+ "src/remotion/index.ts",
+ COMP_NAME,
+ "out/video.mp4",
+ "--props",
+ JSON.stringify(body.inputProps),
+ "--width",
+ String(VIDEO_WIDTH),
+ "--height",
+ String(VIDEO_HEIGHT),
+ "--fps",
+ String(VIDEO_FPS),
+ "--frames",
+ `0-${DURATION_IN_FRAMES - 1}`,
+ ],
+ detached: true,
+ });
+
+ for await (const log of renderCmd.logs()) {
+ await send({ type: "log", stream: log.stream, data: log.data });
+ }
+
+ const renderResult = await renderCmd.wait();
+ if (renderResult.exitCode !== 0) {
+ const stderr = await renderResult.stderr();
+ const stdout = await renderResult.stdout();
+ throw new Error(`Render failed: ${stderr || stdout}`);
+ }
+
+ await send({ type: "phase", phase: "Reading output..." });
+
+ const videoBuffer = await sandbox.readFileToBuffer({
+ path: "out/video.mp4",
+ });
+ if (!videoBuffer) {
+ throw new Error("Failed to read rendered video");
+ }
+
+ await send({
+ type: "done",
+ url: `data:video/mp4;base64,${videoBuffer.toString("base64")}`,
+ size: videoBuffer.length,
+ });
+ } catch (err) {
+ await send({ type: "error", message: (err as Error).message });
+ } finally {
+ if (sandbox) {
+ await sandbox.stop().catch(() => {});
+ }
+ await writer.close();
+ }
+ };
+
+ runRender();
+
+ return new Response(stream.readable, {
+ headers: {
+ "Content-Type": "text/event-stream",
+ "Cache-Control": "no-cache",
+ Connection: "keep-alive",
+ },
+ });
}
diff --git a/packages/template-vercel/src/app/layout.tsx b/packages/template-vercel/src/app/layout.tsx
index e19d2dc5cb..a01c278f12 100644
--- a/packages/template-vercel/src/app/layout.tsx
+++ b/packages/template-vercel/src/app/layout.tsx
@@ -2,24 +2,24 @@ import "../../styles/global.css";
import { Metadata, Viewport } from "next";
export const metadata: Metadata = {
- title: "Remotion and Next.js",
- description: "Remotion and Next.js",
+ title: "Remotion and Next.js",
+ description: "Remotion and Next.js",
};
export const viewport: Viewport = {
- width: "device-width",
- initialScale: 1,
- maximumScale: 1,
+ width: "device-width",
+ initialScale: 1,
+ maximumScale: 1,
};
export default function RootLayout({
- children,
+ children,
}: {
- children: React.ReactNode;
+ children: React.ReactNode;
}) {
- return (
- <html lang="en">
- <body className="bg-background">{children}</body>
- </html>
- );
+ return (
+ <html lang="en">
+ <body className="bg-background">{children}</body>
+ </html>
+ );
}
diff --git a/packages/template-vercel/src/app/page.tsx b/packages/template-vercel/src/app/page.tsx
index 1f92cb246a..fd59b3e31f 100644
--- a/packages/template-vercel/src/app/page.tsx
+++ b/packages/template-vercel/src/app/page.tsx
@@ -5,12 +5,12 @@ import type { NextPage } from "next";
import { useMemo, useState } from "react";
import { z } from "zod";
import {
- defaultMyCompProps,
- CompositionProps,
- DURATION_IN_FRAMES,
- VIDEO_FPS,
- VIDEO_HEIGHT,
- VIDEO_WIDTH,
+ defaultMyCompProps,
+ CompositionProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
} from "../../types/constants";
import { RenderControls } from "../components/RenderControls";
import { Spacing } from "../components/Spacing";
@@ -18,48 +18,48 @@ import { Tips } from "../components/Tips";
import { Main } from "../remotion/MyComp/Main";
const Home: NextPage = () => {
- const [text, setText] = useState<string>(defaultMyCompProps.title);
+ const [text, setText] = useState<string>(defaultMyCompProps.title);
- const inputProps: z.infer<typeof CompositionProps> = useMemo(() => {
- return {
- title: text,
- };
- }, [text]);
+ const inputProps: z.infer<typeof CompositionProps> = useMemo(() => {
+ return {
+ title: text,
+ };
+ }, [text]);
- return (
- <div>
- <div className="max-w-screen-md m-auto mb-5">
- <div className="overflow-hidden rounded-geist shadow-[0_0_200px_rgba(0,0,0,0.15)] mb-10 mt-16">
- <Player
- component={Main}
- inputProps={inputProps}
- durationInFrames={DURATION_IN_FRAMES}
- fps={VIDEO_FPS}
- compositionHeight={VIDEO_HEIGHT}
- compositionWidth={VIDEO_WIDTH}
- style={{
- // Can't use tailwind class for width since player's default styles take presedence over tailwind's,
- // but not over inline styles
- width: "100%",
- }}
- controls
- autoPlay
- loop
- />
- </div>
- <RenderControls
- text={text}
- setText={setText}
- inputProps={inputProps}
- ></RenderControls>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Spacing></Spacing>
- <Tips></Tips>
- </div>
- </div>
- );
+ return (
+ <div>
+ <div className="max-w-screen-md m-auto mb-5">
+ <div className="overflow-hidden rounded-geist shadow-[0_0_200px_rgba(0,0,0,0.15)] mb-10 mt-16">
+ <Player
+ component={Main}
+ inputProps={inputProps}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ compositionHeight={VIDEO_HEIGHT}
+ compositionWidth={VIDEO_WIDTH}
+ style={{
+ // Can't use tailwind class for width since player's default styles take presedence over tailwind's,
+ // but not over inline styles
+ width: "100%",
+ }}
+ controls
+ autoPlay
+ loop
+ />
+ </div>
+ <RenderControls
+ text={text}
+ setText={setText}
+ inputProps={inputProps}
+ ></RenderControls>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Spacing></Spacing>
+ <Tips></Tips>
+ </div>
+ </div>
+ );
};
export default Home;
diff --git a/packages/template-vercel/src/components/AlignEnd.tsx b/packages/template-vercel/src/components/AlignEnd.tsx
index 7ff7ad53bf..adbe3258d6 100644
--- a/packages/template-vercel/src/components/AlignEnd.tsx
+++ b/packages/template-vercel/src/components/AlignEnd.tsx
@@ -1,7 +1,7 @@
import React from "react";
export const AlignEnd: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- return <div className="self-end">{children}</div>;
+ return <div className="self-end">{children}</div>;
};
diff --git a/packages/template-vercel/src/components/Button.tsx b/packages/template-vercel/src/components/Button.tsx
index 4f924f335d..a5d601cd36 100644
--- a/packages/template-vercel/src/components/Button.tsx
+++ b/packages/template-vercel/src/components/Button.tsx
@@ -4,36 +4,36 @@ import { Spinner } from "./Spinner";
import { cn } from "../lib/utils";
const ButtonForward: React.ForwardRefRenderFunction<
- HTMLButtonElement,
- {
- onClick?: () => void;
- disabled?: boolean;
- children: React.ReactNode;
- loading?: boolean;
- secondary?: boolean;
- }
+ HTMLButtonElement,
+ {
+ onClick?: () => void;
+ disabled?: boolean;
+ children: React.ReactNode;
+ loading?: boolean;
+ secondary?: boolean;
+ }
> = ({ onClick, disabled, children, loading, secondary }, ref) => {
- return (
- <button
- ref={ref}
- className={cn(
- "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
- secondary
- ? "bg-background text-foreground border-unfocused-border-color"
- : undefined,
- )}
- onClick={onClick}
- disabled={disabled}
- >
- {loading && (
- <>
- <Spinner size={20}></Spinner>
- <Spacing></Spacing>
- </>
- )}
- {children}
- </button>
- );
+ return (
+ <button
+ ref={ref}
+ className={cn(
+ "border-foreground border rounded-geist bg-foreground text-background px-geist-half font-geist h-10 font-medium transition-all duration-150 ease-in-out inline-flex items-center appearance-none text-sm hover:bg-background hover:text-foreground hover:border-focused-border-color disabled:bg-button-disabled-color disabled:text-disabled-text-color disabled:border-unfocused-border-color disabled:cursor-not-allowed",
+ secondary
+ ? "bg-background text-foreground border-unfocused-border-color"
+ : undefined,
+ )}
+ onClick={onClick}
+ disabled={disabled}
+ >
+ {loading && (
+ <>
+ <Spinner size={20}></Spinner>
+ <Spacing></Spacing>
+ </>
+ )}
+ {children}
+ </button>
+ );
};
export const Button = forwardRef(ButtonForward);
diff --git a/packages/template-vercel/src/components/Container.tsx b/packages/template-vercel/src/components/Container.tsx
index 19cbcb59e5..9d521645dd 100644
--- a/packages/template-vercel/src/components/Container.tsx
+++ b/packages/template-vercel/src/components/Container.tsx
@@ -1,11 +1,11 @@
import React from "react";
export const InputContainer: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- return (
- <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
- {children}
- </div>
- );
+ return (
+ <div className="border border-unfocused-border-color p-geist rounded-geist bg-background flex flex-col">
+ {children}
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/DownloadButton.tsx b/packages/template-vercel/src/components/DownloadButton.tsx
index 0ffa9576ba..22eeee3a75 100644
--- a/packages/template-vercel/src/components/DownloadButton.tsx
+++ b/packages/template-vercel/src/components/DownloadButton.tsx
@@ -4,49 +4,49 @@ import { Button } from "./Button";
import { Spacing } from "./Spacing";
const Megabytes: React.FC<{
- sizeInBytes: number;
+ sizeInBytes: number;
}> = ({ sizeInBytes }) => {
- const megabytes = Intl.NumberFormat("en", {
- notation: "compact",
- style: "unit",
- unit: "byte",
- unitDisplay: "narrow",
- }).format(sizeInBytes);
- return <span className="opacity-60">{megabytes}</span>;
+ const megabytes = Intl.NumberFormat("en", {
+ notation: "compact",
+ style: "unit",
+ unit: "byte",
+ unitDisplay: "narrow",
+ }).format(sizeInBytes);
+ return <span className="opacity-60">{megabytes}</span>;
};
export const DownloadButton: React.FC<{
- state: State;
- undo: () => void;
+ state: State;
+ undo: () => void;
}> = ({ state, undo }) => {
- if (state.status !== "done") {
- throw new Error("Download button should not be rendered when not done");
- }
+ if (state.status !== "done") {
+ throw new Error("Download button should not be rendered when not done");
+ }
- return (
- <div className="flex">
- <Button secondary onClick={undo}>
- <UndoIcon></UndoIcon>
- </Button>
- <Spacing></Spacing>
- <a href={state.url}>
- <Button>
- Download video
- <Spacing></Spacing>
- <Megabytes sizeInBytes={state.size}></Megabytes>
- </Button>
- </a>
- </div>
- );
+ return (
+ <div className="flex">
+ <Button secondary onClick={undo}>
+ <UndoIcon></UndoIcon>
+ </Button>
+ <Spacing></Spacing>
+ <a href={state.url}>
+ <Button>
+ Download video
+ <Spacing></Spacing>
+ <Megabytes sizeInBytes={state.size}></Megabytes>
+ </Button>
+ </a>
+ </div>
+ );
};
const UndoIcon: React.FC = () => {
- return (
- <svg height="1em" viewBox="0 0 512 512">
- <path
- fill="var(--foreground)"
- d="M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"
- />
- </svg>
- );
+ return (
+ <svg height="1em" viewBox="0 0 512 512">
+ <path
+ fill="var(--foreground)"
+ d="M48.5 224H40c-13.3 0-24-10.7-24-24V72c0-9.7 5.8-18.5 14.8-22.2s19.3-1.7 26.2 5.2L98.6 96.6c87.6-86.5 228.7-86.2 315.8 1c87.5 87.5 87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3c-62.2-62.2-162.7-62.5-225.3-1L185 183c6.9 6.9 8.9 17.2 5.2 26.2s-12.5 14.8-22.2 14.8H48.5z"
+ />
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/components/Error.tsx b/packages/template-vercel/src/components/Error.tsx
index 28020e53c2..32309b732c 100644
--- a/packages/template-vercel/src/components/Error.tsx
+++ b/packages/template-vercel/src/components/Error.tsx
@@ -1,25 +1,25 @@
import React from "react";
export const ErrorComp: React.FC<{
- message: string;
+ message: string;
}> = ({ message }) => {
- return (
- <div className="text-geist-error font-geist py-geist-half">
- <svg
- fill="none"
- shapeRendering="geometricPrecision"
- stroke="currentColor"
- strokeLinecap="round"
- strokeLinejoin="round"
- strokeWidth="2"
- viewBox="0 0 24 24"
- className="h-5 align-text-bottom mr-1.5 inline"
- >
- <circle cx="12" cy="12" r="10" fill="var(--geist-fill)"></circle>
- <path d="M12 8v4" stroke="currentColor"></path>
- <path d="M12 16h.01" stroke="currentColor"></path>
- </svg>
- <strong>Error:</strong> {message}
- </div>
- );
+ return (
+ <div className="text-geist-error font-geist py-geist-half">
+ <svg
+ fill="none"
+ shapeRendering="geometricPrecision"
+ stroke="currentColor"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ strokeWidth="2"
+ viewBox="0 0 24 24"
+ className="h-5 align-text-bottom mr-1.5 inline"
+ >
+ <circle cx="12" cy="12" r="10" fill="var(--geist-fill)"></circle>
+ <path d="M12 8v4" stroke="currentColor"></path>
+ <path d="M12 16h.01" stroke="currentColor"></path>
+ </svg>
+ <strong>Error:</strong> {message}
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/Input.tsx b/packages/template-vercel/src/components/Input.tsx
index d6dcc0434d..db948c75dd 100644
--- a/packages/template-vercel/src/components/Input.tsx
+++ b/packages/template-vercel/src/components/Input.tsx
@@ -1,24 +1,24 @@
import React, { useCallback } from "react";
export const Input: React.FC<{
- text: string;
- setText: React.Dispatch<React.SetStateAction<string>>;
- disabled?: boolean;
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ disabled?: boolean;
}> = ({ text, setText, disabled }) => {
- const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
- (e) => {
- setText(e.currentTarget.value);
- },
- [setText],
- );
+ const onChange: React.ChangeEventHandler<HTMLInputElement> = useCallback(
+ (e) => {
+ setText(e.currentTarget.value);
+ },
+ [setText],
+ );
- return (
- <input
- className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
- disabled={disabled}
- name="title"
- value={text}
- onChange={onChange}
- />
- );
+ return (
+ <input
+ className="leading-[1.7] block w-full rounded-geist bg-background p-geist-half text-foreground text-sm border border-unfocused-border-color transition-colors duration-150 ease-in-out focus:border-focused-border-color outline-none"
+ disabled={disabled}
+ name="title"
+ value={text}
+ onChange={onChange}
+ />
+ );
};
diff --git a/packages/template-vercel/src/components/LogViewer.tsx b/packages/template-vercel/src/components/LogViewer.tsx
index 81fae9a93a..0d9c95ed92 100644
--- a/packages/template-vercel/src/components/LogViewer.tsx
+++ b/packages/template-vercel/src/components/LogViewer.tsx
@@ -1,36 +1,36 @@
import { useEffect, useRef } from "react";
export const LogViewer: React.FC<{ logs: string[] }> = ({ logs }) => {
- const containerRef = useRef<HTMLDivElement>(null);
+ const containerRef = useRef<HTMLDivElement>(null);
- useEffect(() => {
- if (containerRef.current) {
- containerRef.current.scrollTop = containerRef.current.scrollHeight;
- }
- }, [logs]);
+ useEffect(() => {
+ if (containerRef.current) {
+ containerRef.current.scrollTop = containerRef.current.scrollHeight;
+ }
+ }, [logs]);
- if (logs.length === 0) return null;
+ if (logs.length === 0) return null;
- return (
- <div
- ref={containerRef}
- style={{
- backgroundColor: "#1a1a1a",
- borderRadius: 8,
- padding: 12,
- maxHeight: 200,
- overflowY: "auto",
- fontFamily: "monospace",
- fontSize: 12,
- lineHeight: 1.4,
- color: "#e0e0e0",
- whiteSpace: "pre-wrap",
- wordBreak: "break-all",
- }}
- >
- {logs.map((log, i) => (
- <span key={i}>{log}</span>
- ))}
- </div>
- );
+ return (
+ <div
+ ref={containerRef}
+ style={{
+ backgroundColor: "#1a1a1a",
+ borderRadius: 8,
+ padding: 12,
+ maxHeight: 200,
+ overflowY: "auto",
+ fontFamily: "monospace",
+ fontSize: 12,
+ lineHeight: 1.4,
+ color: "#e0e0e0",
+ whiteSpace: "pre-wrap",
+ wordBreak: "break-all",
+ }}
+ >
+ {logs.map((log, i) => (
+ <span key={i}>{log}</span>
+ ))}
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/ProgressBar.tsx b/packages/template-vercel/src/components/ProgressBar.tsx
index a4c5886df7..d3f929e9ae 100644
--- a/packages/template-vercel/src/components/ProgressBar.tsx
+++ b/packages/template-vercel/src/components/ProgressBar.tsx
@@ -1,22 +1,22 @@
import React, { useMemo } from "react";
export const ProgressBar: React.FC<{
- progress: number;
+ progress: number;
}> = ({ progress }) => {
- const fill: React.CSSProperties = useMemo(() => {
- return {
- width: `${progress * 100}%`,
- };
- }, [progress]);
+ const fill: React.CSSProperties = useMemo(() => {
+ return {
+ width: `${progress * 100}%`,
+ };
+ }, [progress]);
- return (
- <div>
- <div className="w-full h-2.5 rounded-md appearance-none bg-unfocused-border-color mt-2.5 mb-6">
- <div
- className="bg-foreground h-2.5 rounded-md transition-all ease-in-out duration-100"
- style={fill}
- ></div>
- </div>
- </div>
- );
+ return (
+ <div>
+ <div className="w-full h-2.5 rounded-md appearance-none bg-unfocused-border-color mt-2.5 mb-6">
+ <div
+ className="bg-foreground h-2.5 rounded-md transition-all ease-in-out duration-100"
+ style={fill}
+ ></div>
+ </div>
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/components/RenderControls.tsx b/packages/template-vercel/src/components/RenderControls.tsx
index 2c61945917..f6fff8cc4e 100644
--- a/packages/template-vercel/src/components/RenderControls.tsx
+++ b/packages/template-vercel/src/components/RenderControls.tsx
@@ -12,59 +12,59 @@ import { useRendering } from "../helpers/use-rendering";
import { LogViewer } from "./LogViewer";
export const RenderControls: React.FC<{
- text: string;
- setText: React.Dispatch<React.SetStateAction<string>>;
- inputProps: z.infer<typeof CompositionProps>;
+ text: string;
+ setText: React.Dispatch<React.SetStateAction<string>>;
+ inputProps: z.infer<typeof CompositionProps>;
}> = ({ text, setText, inputProps }) => {
- const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
+ const { renderMedia, state, undo } = useRendering(COMP_NAME, inputProps);
- return (
- <InputContainer>
- {state.status === "init" ||
- state.status === "invoking" ||
- state.status === "error" ? (
- <>
- <Input
- disabled={state.status === "invoking"}
- setText={setText}
- text={text}
- ></Input>
- <Spacing></Spacing>
- <AlignEnd>
- <Button
- disabled={state.status === "invoking"}
- loading={state.status === "invoking"}
- onClick={renderMedia}
- >
- Render video
- </Button>
- </AlignEnd>
- {state.status === "invoking" ? (
- <>
- <Spacing></Spacing>
- <div style={{ fontSize: 14, color: "#666", marginBottom: 8 }}>
- {state.phase}
- </div>
- <LogViewer logs={state.logs} />
- </>
- ) : null}
- {state.status === "error" ? (
- <>
- <LogViewer logs={state.logs} />
- <ErrorComp message={state.error.message}></ErrorComp>
- </>
- ) : null}
- </>
- ) : null}
- {state.status === "done" ? (
- <>
- <ProgressBar progress={1} />
- <Spacing></Spacing>
- <AlignEnd>
- <DownloadButton undo={undo} state={state}></DownloadButton>
- </AlignEnd>
- </>
- ) : null}
- </InputContainer>
- );
+ return (
+ <InputContainer>
+ {state.status === "init" ||
+ state.status === "invoking" ||
+ state.status === "error" ? (
+ <>
+ <Input
+ disabled={state.status === "invoking"}
+ setText={setText}
+ text={text}
+ ></Input>
+ <Spacing></Spacing>
+ <AlignEnd>
+ <Button
+ disabled={state.status === "invoking"}
+ loading={state.status === "invoking"}
+ onClick={renderMedia}
+ >
+ Render video
+ </Button>
+ </AlignEnd>
+ {state.status === "invoking" ? (
+ <>
+ <Spacing></Spacing>
+ <div style={{ fontSize: 14, color: "#666", marginBottom: 8 }}>
+ {state.phase}
+ </div>
+ <LogViewer logs={state.logs} />
+ </>
+ ) : null}
+ {state.status === "error" ? (
+ <>
+ <LogViewer logs={state.logs} />
+ <ErrorComp message={state.error.message}></ErrorComp>
+ </>
+ ) : null}
+ </>
+ ) : null}
+ {state.status === "done" ? (
+ <>
+ <ProgressBar progress={1} />
+ <Spacing></Spacing>
+ <AlignEnd>
+ <DownloadButton undo={undo} state={state}></DownloadButton>
+ </AlignEnd>
+ </>
+ ) : null}
+ </InputContainer>
+ );
};
diff --git a/packages/template-vercel/src/components/Spacing.tsx b/packages/template-vercel/src/components/Spacing.tsx
index c901cfdadb..29b5d1428f 100644
--- a/packages/template-vercel/src/components/Spacing.tsx
+++ b/packages/template-vercel/src/components/Spacing.tsx
@@ -1,5 +1,5 @@
import React from "react";
export const Spacing: React.FC = () => {
- return <div className="w-geist-quarter h-geist-quarter" />;
+ return <div className="w-geist-quarter h-geist-quarter" />;
};
diff --git a/packages/template-vercel/src/components/Spinner.tsx b/packages/template-vercel/src/components/Spinner.tsx
index 405f2260c1..33a03b00f5 100644
--- a/packages/template-vercel/src/components/Spinner.tsx
+++ b/packages/template-vercel/src/components/Spinner.tsx
@@ -7,40 +7,40 @@ const lines = 12;
const width = viewBox * 0.08;
const { path } = makeRect({
- height: viewBox * 0.24,
- width,
- cornerRadius: width / 2,
+ height: viewBox * 0.24,
+ width,
+ cornerRadius: width / 2,
});
const translated = translatePath(path, viewBox / 2 - width / 2, viewBox * 0.03);
export const Spinner: React.FC<{
- size: number;
+ size: number;
}> = ({ size }) => {
- const style = useMemo(() => {
- return {
- width: size,
- height: size,
- };
- }, [size]);
+ const style = useMemo(() => {
+ return {
+ width: size,
+ height: size,
+ };
+ }, [size]);
- return (
- <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
- {new Array(lines).fill(true).map((_, index) => {
- return (
- <path
- className="animate-spinner"
- style={{
- rotate: `${(index * Math.PI * 2) / lines}rad`,
- transformOrigin: "center center",
- animationDelay: `${index * 0.1 - lines * 0.1}s`,
- }}
- key={index}
- d={translated}
- fill="var(--foreground)"
- ></path>
- );
- })}
- </svg>
- );
+ return (
+ <svg style={style} viewBox={`0 0 ${viewBox} ${viewBox}`}>
+ {new Array(lines).fill(true).map((_, index) => {
+ return (
+ <path
+ className="animate-spinner"
+ style={{
+ rotate: `${(index * Math.PI * 2) / lines}rad`,
+ transformOrigin: "center center",
+ animationDelay: `${index * 0.1 - lines * 0.1}s`,
+ }}
+ key={index}
+ d={translated}
+ fill="var(--foreground)"
+ ></path>
+ );
+ })}
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/components/Tips.tsx b/packages/template-vercel/src/components/Tips.tsx
index 3f88e15754..c0ab9b727e 100644
--- a/packages/template-vercel/src/components/Tips.tsx
+++ b/packages/template-vercel/src/components/Tips.tsx
@@ -1,53 +1,53 @@
import React from "react";
const Tip: React.FC<{
- title: React.ReactNode;
- description: React.ReactNode;
- href: string;
+ title: React.ReactNode;
+ description: React.ReactNode;
+ href: string;
}> = ({ title, description, href }) => {
- return (
- <a href={href} target="_blank" rel="noreferrer" className="flex-1">
- <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">
- <div className="flex flex-row items-center justify-start">
- <h4 className="my-3 font-bold text-foreground">{title}</h4>
- <div className="flex-1"></div>
- <svg
- className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"
- height="1em"
- viewBox="0 0 448 512"
- >
- <path
- fill="var(--foreground)"
- d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"
- />
- </svg>
- </div>
- <p className="text-sm leading-normal text-subtitle mb-6">
- {description}
- </p>
- </div>
- </a>
- );
+ return (
+ <a href={href} target="_blank" rel="noreferrer" className="flex-1">
+ <div className="transition-transform duration-200 ease-in-out p-2.5 group hover:-translate-y-0.5">
+ <div className="flex flex-row items-center justify-start">
+ <h4 className="my-3 font-bold text-foreground">{title}</h4>
+ <div className="flex-1"></div>
+ <svg
+ className="opacity-0 transition-opacity duration-200 ease-in-out group-hover:opacity-100"
+ height="1em"
+ viewBox="0 0 448 512"
+ >
+ <path
+ fill="var(--foreground)"
+ d="M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z"
+ />
+ </svg>
+ </div>
+ <p className="text-sm leading-normal text-subtitle mb-6">
+ {description}
+ </p>
+ </div>
+ </a>
+ );
};
export const Tips: React.FC = () => {
- return (
- <div className="flex flex-col md:flex-row font-geist">
- <Tip
- href="https://www.remotion.dev/docs/the-fundamentals"
- title="Learn Remotion"
- description="Learn how to customize this video written in React."
- ></Tip>
- <Tip
- href="https://github.com/remotion-dev/template-vercel"
- title="See source"
- description="Visit the GitHub repository for this app."
- ></Tip>
- <Tip
- href="https://remotion.dev/discord"
- title="Join the community"
- description="Chat with others builders on Discord."
- ></Tip>
- </div>
- );
+ return (
+ <div className="flex flex-col md:flex-row font-geist">
+ <Tip
+ href="https://www.remotion.dev/docs/the-fundamentals"
+ title="Learn Remotion"
+ description="Learn how to customize this video written in React."
+ ></Tip>
+ <Tip
+ href="https://github.com/remotion-dev/template-vercel"
+ title="See source"
+ description="Visit the GitHub repository for this app."
+ ></Tip>
+ <Tip
+ href="https://remotion.dev/discord"
+ title="Join the community"
+ description="Chat with others builders on Discord."
+ ></Tip>
+ </div>
+ );
};
diff --git a/packages/template-vercel/src/helpers/api-response.ts b/packages/template-vercel/src/helpers/api-response.ts
index d4da4ce786..3f80cd99ad 100644
--- a/packages/template-vercel/src/helpers/api-response.ts
+++ b/packages/template-vercel/src/helpers/api-response.ts
@@ -2,35 +2,35 @@ import { NextResponse } from "next/server";
import { z, ZodType } from "zod";
export type ApiResponse<Res> =
- | {
- type: "error";
- message: string;
- }
- | {
- type: "success";
- data: Res;
- };
+ | {
+ type: "error";
+ message: string;
+ }
+ | {
+ type: "success";
+ data: Res;
+ };
export const executeApi =
- <Res, Req extends ZodType>(
- schema: Req,
- handler: (req: Request, body: z.infer<Req>) => Promise<Res>,
- ) =>
- async (req: Request) => {
- try {
- const payload = await req.json();
- const parsed = schema.parse(payload);
- const data = await handler(req, parsed);
- return NextResponse.json({
- type: "success",
- data: data,
- });
- } catch (err) {
- return NextResponse.json(
- { type: "error", message: (err as Error).message },
- {
- status: 500,
- },
- );
- }
- };
+ <Res, Req extends ZodType>(
+ schema: Req,
+ handler: (req: Request, body: z.infer<Req>) => Promise<Res>,
+ ) =>
+ async (req: Request) => {
+ try {
+ const payload = await req.json();
+ const parsed = schema.parse(payload);
+ const data = await handler(req, parsed);
+ return NextResponse.json({
+ type: "success",
+ data: data,
+ });
+ } catch (err) {
+ return NextResponse.json(
+ { type: "error", message: (err as Error).message },
+ {
+ status: 500,
+ },
+ );
+ }
+ };
diff --git a/packages/template-vercel/src/helpers/use-rendering.ts b/packages/template-vercel/src/helpers/use-rendering.ts
index c489d387fd..f74e2caa87 100644
--- a/packages/template-vercel/src/helpers/use-rendering.ts
+++ b/packages/template-vercel/src/helpers/use-rendering.ts
@@ -4,120 +4,120 @@ import { CompositionProps } from "../../types/constants";
import { SSEMessage } from "../../types/schema";
export type State =
- | {
- status: "init";
- }
- | {
- status: "invoking";
- phase: string;
- logs: string[];
- }
- | {
- status: "error";
- error: Error;
- logs: string[];
- }
- | {
- url: string;
- size: number;
- status: "done";
- logs: string[];
- };
+ | {
+ status: "init";
+ }
+ | {
+ status: "invoking";
+ phase: string;
+ logs: string[];
+ }
+ | {
+ status: "error";
+ error: Error;
+ logs: string[];
+ }
+ | {
+ url: string;
+ size: number;
+ status: "done";
+ logs: string[];
+ };
export const useRendering = (
- id: string,
- inputProps: z.infer<typeof CompositionProps>,
+ id: string,
+ inputProps: z.infer<typeof CompositionProps>,
) => {
- const [state, setState] = useState<State>({
- status: "init",
- });
+ const [state, setState] = useState<State>({
+ status: "init",
+ });
- const renderMedia = useCallback(async () => {
- setState({
- status: "invoking",
- phase: "Starting...",
- logs: [],
- });
+ const renderMedia = useCallback(async () => {
+ setState({
+ status: "invoking",
+ phase: "Starting...",
+ logs: [],
+ });
- try {
- const response = await fetch("/api/render", {
- method: "POST",
- headers: { "content-type": "application/json" },
- body: JSON.stringify({ id, inputProps }),
- });
+ try {
+ const response = await fetch("/api/render", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ id, inputProps }),
+ });
- if (!response.ok || !response.body) {
- throw new Error("Failed to start render");
- }
+ if (!response.ok || !response.body) {
+ throw new Error("Failed to start render");
+ }
- const reader = response.body.getReader();
- const decoder = new TextDecoder();
- let buffer = "";
+ const reader = response.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = "";
- while (true) {
- const { done, value } = await reader.read();
- if (done) break;
+ while (true) {
+ const { done, value } = await reader.read();
+ if (done) break;
- buffer += decoder.decode(value, { stream: true });
- const lines = buffer.split("\n\n");
- buffer = lines.pop() || "";
+ buffer += decoder.decode(value, { stream: true });
+ const lines = buffer.split("\n\n");
+ buffer = lines.pop() || "";
- for (const line of lines) {
- if (!line.startsWith("data: ")) continue;
+ for (const line of lines) {
+ if (!line.startsWith("data: ")) continue;
- const json = line.slice(6);
- const message = JSON.parse(json) as SSEMessage;
+ const json = line.slice(6);
+ const message = JSON.parse(json) as SSEMessage;
- if (message.type === "log") {
- setState((prev) => {
- if (prev.status === "init") return prev;
- return {
- ...prev,
- logs: [...prev.logs, message.data],
- };
- });
- } else if (message.type === "phase") {
- setState((prev) => {
- if (prev.status !== "invoking") return prev;
- return {
- ...prev,
- phase: message.phase,
- };
- });
- } else if (message.type === "done") {
- setState((prev) => ({
- status: "done",
- url: message.url,
- size: message.size,
- logs: prev.status !== "init" ? prev.logs : [],
- }));
- } else if (message.type === "error") {
- setState((prev) => ({
- status: "error",
- error: new Error(message.message),
- logs: prev.status !== "init" ? prev.logs : [],
- }));
- }
- }
- }
- } catch (err) {
- setState((prev) => ({
- status: "error",
- error: err as Error,
- logs: prev.status !== "init" ? prev.logs : [],
- }));
- }
- }, [id, inputProps]);
+ if (message.type === "log") {
+ setState((prev) => {
+ if (prev.status === "init") return prev;
+ return {
+ ...prev,
+ logs: [...prev.logs, message.data],
+ };
+ });
+ } else if (message.type === "phase") {
+ setState((prev) => {
+ if (prev.status !== "invoking") return prev;
+ return {
+ ...prev,
+ phase: message.phase,
+ };
+ });
+ } else if (message.type === "done") {
+ setState((prev) => ({
+ status: "done",
+ url: message.url,
+ size: message.size,
+ logs: prev.status !== "init" ? prev.logs : [],
+ }));
+ } else if (message.type === "error") {
+ setState((prev) => ({
+ status: "error",
+ error: new Error(message.message),
+ logs: prev.status !== "init" ? prev.logs : [],
+ }));
+ }
+ }
+ }
+ } catch (err) {
+ setState((prev) => ({
+ status: "error",
+ error: err as Error,
+ logs: prev.status !== "init" ? prev.logs : [],
+ }));
+ }
+ }, [id, inputProps]);
- const undo = useCallback(() => {
- setState({ status: "init" });
- }, []);
+ const undo = useCallback(() => {
+ setState({ status: "init" });
+ }, []);
- return useMemo(() => {
- return {
- renderMedia,
- state,
- undo,
- };
- }, [renderMedia, state, undo]);
+ return useMemo(() => {
+ return {
+ renderMedia,
+ state,
+ undo,
+ };
+ }, [renderMedia, state, undo]);
};
diff --git a/packages/template-vercel/src/lib/utils.ts b/packages/template-vercel/src/lib/utils.ts
index a5ef193506..3200be2844 100644
--- a/packages/template-vercel/src/lib/utils.ts
+++ b/packages/template-vercel/src/lib/utils.ts
@@ -2,5 +2,5 @@ import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
- return twMerge(clsx(inputs));
+ return twMerge(clsx(inputs));
}
diff --git a/packages/template-vercel/src/remotion/MyComp/Main.tsx b/packages/template-vercel/src/remotion/MyComp/Main.tsx
index cf23037a59..4c063ee365 100644
--- a/packages/template-vercel/src/remotion/MyComp/Main.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/Main.tsx
@@ -1,10 +1,10 @@
import { z } from "zod";
import {
- AbsoluteFill,
- Sequence,
- spring,
- useCurrentFrame,
- useVideoConfig,
+ AbsoluteFill,
+ Sequence,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
} from "remotion";
import { CompositionProps } from "../../../types/constants";
import { NextLogo } from "./NextLogo";
@@ -13,46 +13,46 @@ import { Rings } from "./Rings";
import { TextFade } from "./TextFade";
loadFont("normal", {
- subsets: ["latin"],
- weights: ["400", "700"],
+ subsets: ["latin"],
+ weights: ["400", "700"],
});
export const Main = ({ title }: z.infer<typeof CompositionProps>) => {
- const frame = useCurrentFrame();
- const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
- const transitionStart = 2 * fps;
- const transitionDuration = 1 * fps;
+ const transitionStart = 2 * fps;
+ const transitionDuration = 1 * fps;
- const logoOut = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- durationInFrames: transitionDuration,
- delay: transitionStart,
- });
+ const logoOut = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: transitionDuration,
+ delay: transitionStart,
+ });
- return (
- <AbsoluteFill className="bg-white">
- <Sequence durationInFrames={transitionStart + transitionDuration}>
- <Rings outProgress={logoOut}></Rings>
- <AbsoluteFill className="justify-center items-center">
- <NextLogo outProgress={logoOut}></NextLogo>
- </AbsoluteFill>
- </Sequence>
- <Sequence from={transitionStart + transitionDuration / 2}>
- <TextFade>
- <h1
- className="text-[70px] font-bold"
- style={{
- fontFamily,
- }}
- >
- {title}
- </h1>
- </TextFade>
- </Sequence>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill className="bg-white">
+ <Sequence durationInFrames={transitionStart + transitionDuration}>
+ <Rings outProgress={logoOut}></Rings>
+ <AbsoluteFill className="justify-center items-center">
+ <NextLogo outProgress={logoOut}></NextLogo>
+ </AbsoluteFill>
+ </Sequence>
+ <Sequence from={transitionStart + transitionDuration / 2}>
+ <TextFade>
+ <h1
+ className="text-[70px] font-bold"
+ style={{
+ fontFamily,
+ }}
+ >
+ {title}
+ </h1>
+ </TextFade>
+ </Sequence>
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx b/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
index b7f87f6bf2..a3bc9b7a98 100644
--- a/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/NextLogo.tsx
@@ -3,120 +3,120 @@ import React, { useMemo } from "react";
import { interpolate, spring, useCurrentFrame, useVideoConfig } from "remotion";
const nStroke =
- "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
+ "M149.508 157.52L69.142 54H54V125.97H66.1136V69.3836L139.999 164.845C143.333 162.614 146.509 160.165 149.508 157.52Z";
export const NextLogo: React.FC<{
- outProgress: number;
+ outProgress: number;
}> = ({ outProgress }) => {
- const { fps } = useVideoConfig();
- const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
- const evolve1 = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- });
- const evolve2 = spring({
- fps,
- frame: frame - 15,
- config: {
- damping: 200,
- },
- });
- const evolve3 = spring({
- fps,
- frame: frame - 30,
- config: {
- damping: 200,
- mass: 3,
- },
- durationInFrames: 30,
- });
+ const evolve1 = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve2 = spring({
+ fps,
+ frame: frame - 15,
+ config: {
+ damping: 200,
+ },
+ });
+ const evolve3 = spring({
+ fps,
+ frame: frame - 30,
+ config: {
+ damping: 200,
+ mass: 3,
+ },
+ durationInFrames: 30,
+ });
- const style: React.CSSProperties = useMemo(() => {
- return {
- height: 140,
- borderRadius: 70,
- scale: String(1 - outProgress),
- };
- }, [outProgress]);
+ const style: React.CSSProperties = useMemo(() => {
+ return {
+ height: 140,
+ borderRadius: 70,
+ scale: String(1 - outProgress),
+ };
+ }, [outProgress]);
- const firstPath = `M 60.0568 54 v 71.97`;
- const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
- const thirdPath = `M 121 54 L 121 126`;
+ const firstPath = `M 60.0568 54 v 71.97`;
+ const secondPath = `M 63.47956 56.17496 L 144.7535 161.1825`;
+ const thirdPath = `M 121 54 L 121 126`;
- const evolution1 = evolvePath(evolve1, firstPath);
- const evolution2 = evolvePath(evolve2, secondPath);
- const evolution3 = evolvePath(
- interpolate(evolve3, [0, 1], [0, 0.7]),
- thirdPath,
- );
+ const evolution1 = evolvePath(evolve1, firstPath);
+ const evolution2 = evolvePath(evolve2, secondPath);
+ const evolution3 = evolvePath(
+ interpolate(evolve3, [0, 1], [0, 0.7]),
+ thirdPath,
+ );
- return (
- <svg style={style} fill="none" viewBox="0 0 180 180">
- <mask
- height="180"
- id="mask"
- className="[mask-type:alpha]"
- width="180"
- x="0"
- y="0"
- >
- <circle cx="90" cy="90" fill="black" r="90"></circle>
- </mask>
- <mask id="n-mask" className="[mask-type:alpha]">
- <path d={nStroke} fill="black"></path>
- </mask>
- <g mask="url(#mask)">
- <circle cx="90" cy="90" fill="black" r="90"></circle>
- <g stroke="url(#gradient0)" mask="url(#n-mask)">
- <path
- strokeWidth="12.1136"
- d={firstPath}
- strokeDasharray={evolution1.strokeDasharray}
- strokeDashoffset={evolution1.strokeDashoffset}
- ></path>
- <path
- strokeWidth={12.1136}
- d={secondPath}
- strokeDasharray={evolution2.strokeDasharray}
- strokeDashoffset={evolution2.strokeDashoffset}
- ></path>
- </g>
- <path
- stroke="url(#gradient1)"
- d={thirdPath}
- strokeDasharray={evolution3.strokeDasharray}
- strokeDashoffset={evolution3.strokeDashoffset}
- strokeWidth="12"
- ></path>
- </g>
- <defs>
- <linearGradient
- gradientUnits="userSpaceOnUse"
- id="gradient0"
- x1="109"
- x2="144.5"
- y1="116.5"
- y2="160.5"
- >
- <stop stopColor="white"></stop>
- <stop offset="1" stopColor="white" stopOpacity="0"></stop>
- </linearGradient>
- <linearGradient
- gradientUnits="userSpaceOnUse"
- id="gradient1"
- x1="121"
- x2="120.799"
- y1="54"
- y2="106.875"
- >
- <stop stopColor="white"></stop>
- <stop offset="1" stopColor="white" stopOpacity="0"></stop>
- </linearGradient>
- </defs>
- </svg>
- );
+ return (
+ <svg style={style} fill="none" viewBox="0 0 180 180">
+ <mask
+ height="180"
+ id="mask"
+ className="[mask-type:alpha]"
+ width="180"
+ x="0"
+ y="0"
+ >
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ </mask>
+ <mask id="n-mask" className="[mask-type:alpha]">
+ <path d={nStroke} fill="black"></path>
+ </mask>
+ <g mask="url(#mask)">
+ <circle cx="90" cy="90" fill="black" r="90"></circle>
+ <g stroke="url(#gradient0)" mask="url(#n-mask)">
+ <path
+ strokeWidth="12.1136"
+ d={firstPath}
+ strokeDasharray={evolution1.strokeDasharray}
+ strokeDashoffset={evolution1.strokeDashoffset}
+ ></path>
+ <path
+ strokeWidth={12.1136}
+ d={secondPath}
+ strokeDasharray={evolution2.strokeDasharray}
+ strokeDashoffset={evolution2.strokeDashoffset}
+ ></path>
+ </g>
+ <path
+ stroke="url(#gradient1)"
+ d={thirdPath}
+ strokeDasharray={evolution3.strokeDasharray}
+ strokeDashoffset={evolution3.strokeDashoffset}
+ strokeWidth="12"
+ ></path>
+ </g>
+ <defs>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient0"
+ x1="109"
+ x2="144.5"
+ y1="116.5"
+ y2="160.5"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ <linearGradient
+ gradientUnits="userSpaceOnUse"
+ id="gradient1"
+ x1="121"
+ x2="120.799"
+ y1="54"
+ y2="106.875"
+ >
+ <stop stopColor="white"></stop>
+ <stop offset="1" stopColor="white" stopOpacity="0"></stop>
+ </linearGradient>
+ </defs>
+ </svg>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/Rings.tsx b/packages/template-vercel/src/remotion/MyComp/Rings.tsx
index 8e27bae856..f9eadcb954 100644
--- a/packages/template-vercel/src/remotion/MyComp/Rings.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/Rings.tsx
@@ -2,55 +2,55 @@ import React from "react";
import { AbsoluteFill, interpolateColors, useVideoConfig } from "remotion";
const RadialGradient: React.FC<{
- radius: number;
- color: string;
+ radius: number;
+ color: string;
}> = ({ radius, color }) => {
- const height = radius * 2;
- const width = radius * 2;
+ const height = radius * 2;
+ const width = radius * 2;
- return (
- <AbsoluteFill
- style={{
- justifyContent: "center",
- alignItems: "center",
- }}
- >
- <div
- style={{
- height,
- width,
- backgroundColor: color,
- }}
- className="rounded-[50%] absolute shadow-[0px_0px_100px_rgba(0,0,0,0.05)]"
- ></div>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ justifyContent: "center",
+ alignItems: "center",
+ }}
+ >
+ <div
+ style={{
+ height,
+ width,
+ backgroundColor: color,
+ }}
+ className="rounded-[50%] absolute shadow-[0px_0px_100px_rgba(0,0,0,0.05)]"
+ ></div>
+ </AbsoluteFill>
+ );
};
export const Rings: React.FC<{
- outProgress: number;
+ outProgress: number;
}> = ({ outProgress }) => {
- const scale = 1 / (1 - outProgress);
- const { height } = useVideoConfig();
+ const scale = 1 / (1 - outProgress);
+ const { height } = useVideoConfig();
- return (
- <AbsoluteFill
- style={{
- transform: `scale(${scale})`,
- }}
- >
- {new Array(5)
- .fill(true)
- .map((_, i) => {
- return (
- <RadialGradient
- key={i}
- radius={height * 0.3 * i}
- color={interpolateColors(i, [0, 4], ["#fff", "#fff"])}
- />
- );
- })
- .reverse()}
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill
+ style={{
+ transform: `scale(${scale})`,
+ }}
+ >
+ {new Array(5)
+ .fill(true)
+ .map((_, i) => {
+ return (
+ <RadialGradient
+ key={i}
+ radius={height * 0.3 * i}
+ color={interpolateColors(i, [0, 4], ["#fff", "#fff"])}
+ />
+ );
+ })
+ .reverse()}
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/MyComp/TextFade.tsx b/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
index 1b71930a0b..cedb24d6fb 100644
--- a/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
+++ b/packages/template-vercel/src/remotion/MyComp/TextFade.tsx
@@ -1,45 +1,45 @@
import React, { useMemo } from "react";
import {
- AbsoluteFill,
- interpolate,
- spring,
- useCurrentFrame,
- useVideoConfig,
+ AbsoluteFill,
+ interpolate,
+ spring,
+ useCurrentFrame,
+ useVideoConfig,
} from "remotion";
export const TextFade: React.FC<{
- children: React.ReactNode;
+ children: React.ReactNode;
}> = ({ children }) => {
- const { fps } = useVideoConfig();
- const frame = useCurrentFrame();
+ const { fps } = useVideoConfig();
+ const frame = useCurrentFrame();
- const progress = spring({
- fps,
- frame,
- config: {
- damping: 200,
- },
- durationInFrames: 80,
- });
+ const progress = spring({
+ fps,
+ frame,
+ config: {
+ damping: 200,
+ },
+ durationInFrames: 80,
+ });
- const rightStop = interpolate(progress, [0, 1], [200, 0]);
+ const rightStop = interpolate(progress, [0, 1], [200, 0]);
- const leftStop = Math.max(0, rightStop - 60);
+ const leftStop = Math.max(0, rightStop - 60);
- const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
+ const maskImage = `linear-gradient(-45deg, transparent ${leftStop}%, black ${rightStop}%)`;
- const content: React.CSSProperties = useMemo(() => {
- return {
- maskImage,
- WebkitMaskImage: maskImage,
- };
- }, [maskImage]);
+ const content: React.CSSProperties = useMemo(() => {
+ return {
+ maskImage,
+ WebkitMaskImage: maskImage,
+ };
+ }, [maskImage]);
- return (
- <AbsoluteFill>
- <AbsoluteFill className="justify-center items-center">
- <div style={content}>{children}</div>
- </AbsoluteFill>
- </AbsoluteFill>
- );
+ return (
+ <AbsoluteFill>
+ <AbsoluteFill className="justify-center items-center">
+ <div style={content}>{children}</div>
+ </AbsoluteFill>
+ </AbsoluteFill>
+ );
};
diff --git a/packages/template-vercel/src/remotion/Root.tsx b/packages/template-vercel/src/remotion/Root.tsx
index 83276274db..7c1cc22162 100644
--- a/packages/template-vercel/src/remotion/Root.tsx
+++ b/packages/template-vercel/src/remotion/Root.tsx
@@ -1,38 +1,38 @@
import { Composition } from "remotion";
import { Main } from "./MyComp/Main";
import {
- COMP_NAME,
- defaultMyCompProps,
- DURATION_IN_FRAMES,
- VIDEO_FPS,
- VIDEO_HEIGHT,
- VIDEO_WIDTH,
+ COMP_NAME,
+ defaultMyCompProps,
+ DURATION_IN_FRAMES,
+ VIDEO_FPS,
+ VIDEO_HEIGHT,
+ VIDEO_WIDTH,
} from "../../types/constants";
import { NextLogo } from "./MyComp/NextLogo";
export const RemotionRoot: React.FC = () => {
- return (
- <>
- <Composition
- id={COMP_NAME}
- component={Main}
- durationInFrames={DURATION_IN_FRAMES}
- fps={VIDEO_FPS}
- width={VIDEO_WIDTH}
- height={VIDEO_HEIGHT}
- defaultProps={defaultMyCompProps}
- />
- <Composition
- id="NextLogo"
- component={NextLogo}
- durationInFrames={300}
- fps={30}
- width={140}
- height={140}
- defaultProps={{
- outProgress: 0,
- }}
- />
- </>
- );
+ return (
+ <>
+ <Composition
+ id={COMP_NAME}
+ component={Main}
+ durationInFrames={DURATION_IN_FRAMES}
+ fps={VIDEO_FPS}
+ width={VIDEO_WIDTH}
+ height={VIDEO_HEIGHT}
+ defaultProps={defaultMyCompProps}
+ />
+ <Composition
+ id="NextLogo"
+ component={NextLogo}
+ durationInFrames={300}
+ fps={30}
+ width={140}
+ height={140}
+ defaultProps={{
+ outProgress: 0,
+ }}
+ />
+ </>
+ );
};