Skip to content

Commit 105bb9c

Browse files
authored
Initial commit
0 parents  commit 105bb9c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+16248
-0
lines changed

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REMOTION_AWS_ACCESS_KEY_ID=""
2+
REMOTION_AWS_SECRET_ACCESS_KEY=""

.eslintrc.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "next",
3+
"plugins": ["@remotion"],
4+
"overrides": [
5+
{
6+
"files": ["remotion/**/*.{ts,tsx}"],
7+
"extends": ["plugin:@remotion/recommended"]
8+
}
9+
]
10+
}

.gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env*.local
30+
31+
# vercel
32+
.vercel
33+
34+
# typescript
35+
*.tsbuildinfo
36+
next-env.d.ts
37+
out/
38+
.env

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<img src="https://github.com/remotion-dev/template-next/assets/1629785/9092db5f-7c0c-4d38-97c4-5f5a61f5cc098" />
2+
<br/>
3+
<br/>
4+
5+
This is a Next.js template for building programmatic video apps, with [`@remotion/player`](https://remotion.dev/player) and [`@remotion/lambda`](https://remotion.dev/lambda) built in.
6+
7+
This template uses the Next.js App directory. There is a [Pages directory version](https://github.com/remotion-dev/template-next-pages-dir) of this template available.
8+
9+
<img src="https://github.com/remotion-dev/template-next/assets/1629785/c9c2e5ca-2637-4ec8-8e40-a8feb5740d88" />
10+
11+
## Getting Started
12+
13+
[Use this template](https://github.com/new?template_name=template-next-app-dir&template_owner=remotion-dev) to clone it into your GitHub account. Run
14+
15+
```
16+
npm i
17+
```
18+
19+
afterwards. Alternatively, use this command to scaffold a project:
20+
21+
```
22+
npx create-video@latest --next
23+
```
24+
25+
## Commands
26+
27+
Start the Next.js dev server:
28+
29+
```
30+
npm run dev
31+
```
32+
33+
Open the Remotion Studio:
34+
35+
```
36+
npm run remotion
37+
```
38+
39+
The following script will set up your Remotion Bundle and Lambda function on AWS:
40+
41+
```
42+
node deploy.mjs
43+
```
44+
45+
You should run this script after:
46+
47+
- changing the video template
48+
- changing `config.mjs`
49+
- upgrading Remotion to a newer version
50+
51+
## Set up rendering on AWS Lambda
52+
53+
This template supports rendering the videos via [Remotion Lambda](https://remotion.dev/lambda).
54+
55+
1. Copy the `.env.example` file to `.env` and fill in the values.
56+
Complete the [Lambda setup guide](https://www.remotion.dev/docs/lambda/setup) to get your AWS credentials.
57+
58+
1. Edit the `config.mjs` file to your desired Lambda settings.
59+
60+
1. Run `node deploy.mjs` to deploy your Lambda function and Remotion Bundle.
61+
62+
## Docs
63+
64+
Get started with Remotion by reading the [fundamentals page](https://www.remotion.dev/docs/the-fundamentals).
65+
66+
## Help
67+
68+
We provide help on our [Discord server](https://remotion.dev/discord).
69+
70+
## Issues
71+
72+
Found an issue with Remotion? [File an issue here](https://remotion.dev/issue).
73+
74+
## License
75+
76+
Note that for some entities a company license is needed. [Read the terms here](https://github.com/remotion-dev/remotion/blob/main/LICENSE.md).

app/api/lambda/progress/route.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import {
2+
speculateFunctionName,
3+
AwsRegion,
4+
getRenderProgress,
5+
} from "@remotion/lambda/client";
6+
import { DISK, RAM, REGION, TIMEOUT } from "../../../../config.mjs";
7+
import { executeApi } from "../../../../helpers/api-response";
8+
import { ProgressRequest, ProgressResponse } from "../../../../types/schema";
9+
10+
export const POST = executeApi<ProgressResponse, typeof ProgressRequest>(
11+
ProgressRequest,
12+
async (req, body) => {
13+
const renderProgress = await getRenderProgress({
14+
bucketName: body.bucketName,
15+
functionName: speculateFunctionName({
16+
diskSizeInMb: DISK,
17+
memorySizeInMb: RAM,
18+
timeoutInSeconds: TIMEOUT,
19+
}),
20+
region: REGION as AwsRegion,
21+
renderId: body.id,
22+
});
23+
24+
if (renderProgress.fatalErrorEncountered) {
25+
return {
26+
type: "error",
27+
message: renderProgress.errors[0].message,
28+
};
29+
}
30+
31+
if (renderProgress.done) {
32+
return {
33+
type: "done",
34+
url: renderProgress.outputFile as string,
35+
size: renderProgress.outputSizeInBytes as number,
36+
};
37+
}
38+
39+
return {
40+
type: "progress",
41+
progress: Math.max(0.03, renderProgress.overallProgress),
42+
};
43+
}
44+
);

app/api/lambda/render/route.ts

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { AwsRegion, RenderMediaOnLambdaOutput } from "@remotion/lambda/client";
2+
import {
3+
renderMediaOnLambda,
4+
speculateFunctionName,
5+
} from "@remotion/lambda/client";
6+
import { DISK, RAM, REGION, SITE_NAME, TIMEOUT } from "../../../../config.mjs";
7+
import { executeApi } from "../../../../helpers/api-response";
8+
import { RenderRequest } from "../../../../types/schema";
9+
10+
export const POST = executeApi<RenderMediaOnLambdaOutput, typeof RenderRequest>(
11+
RenderRequest,
12+
async (req, body) => {
13+
if (
14+
!process.env.AWS_ACCESS_KEY_ID &&
15+
!process.env.REMOTION_AWS_ACCESS_KEY_ID
16+
) {
17+
throw new TypeError(
18+
"Set up Remotion Lambda to render videos. See the README.md for how to do so."
19+
);
20+
}
21+
if (
22+
!process.env.AWS_SECRET_ACCESS_KEY &&
23+
!process.env.REMOTION_AWS_SECRET_ACCESS_KEY
24+
) {
25+
throw new TypeError(
26+
"The environment variable REMOTION_AWS_SECRET_ACCESS_KEY is missing. Add it to your .env file."
27+
);
28+
}
29+
30+
const result = await renderMediaOnLambda({
31+
codec: "h264",
32+
functionName: speculateFunctionName({
33+
diskSizeInMb: DISK,
34+
memorySizeInMb: RAM,
35+
timeoutInSeconds: TIMEOUT,
36+
}),
37+
region: REGION as AwsRegion,
38+
serveUrl: SITE_NAME,
39+
composition: body.id,
40+
inputProps: body.inputProps,
41+
framesPerLambda: 10,
42+
downloadBehavior: {
43+
type: "download",
44+
fileName: "video.mp4",
45+
},
46+
});
47+
48+
return result;
49+
}
50+
);

app/favicon.ico

25.3 KB
Binary file not shown.

app/globals.css

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;
4+
5+
@layer base {
6+
:root {
7+
--background: 0 0% 100%;
8+
--foreground: 240 10% 3.9%;
9+
--card: 0 0% 100%;
10+
--card-foreground: 240 10% 3.9%;
11+
--popover: 0 0% 100%;
12+
--popover-foreground: 240 10% 3.9%;
13+
--primary: 142.1 76.2% 36.3%;
14+
--primary-foreground: 355.7 100% 97.3%;
15+
--secondary: 240 4.8% 95.9%;
16+
--secondary-foreground: 240 5.9% 10%;
17+
--muted: 240 4.8% 95.9%;
18+
--muted-foreground: 240 3.8% 46.1%;
19+
--accent: 240 4.8% 95.9%;
20+
--accent-foreground: 240 5.9% 10%;
21+
--destructive: 0 84.2% 60.2%;
22+
--destructive-foreground: 0 0% 98%;
23+
--border: 240 5.9% 90%;
24+
--input: 240 5.9% 90%;
25+
--ring: 142.1 76.2% 36.3%;
26+
--radius: 0.5rem;
27+
}
28+
29+
.dark {
30+
--background: 20 14.3% 4.1%;
31+
--foreground: 0 0% 95%;
32+
--card: 24 9.8% 10%;
33+
--card-foreground: 0 0% 95%;
34+
--popover: 0 0% 9%;
35+
--popover-foreground: 0 0% 95%;
36+
--primary: 142.1 70.6% 45.3%;
37+
--primary-foreground: 144.9 80.4% 10%;
38+
--secondary: 240 3.7% 15.9%;
39+
--secondary-foreground: 0 0% 98%;
40+
--muted: 0 0% 15%;
41+
--muted-foreground: 240 5% 64.9%;
42+
--accent: 12 6.5% 15.1%;
43+
--accent-foreground: 0 0% 98%;
44+
--destructive: 0 62.8% 30.6%;
45+
--destructive-foreground: 0 85.7% 97.3%;
46+
--border: 240 3.7% 15.9%;
47+
--input: 240 3.7% 15.9%;
48+
--ring: 142.4 71.8% 29.2%;
49+
}
50+
}
51+
52+
@layer base {
53+
* {
54+
@apply border-border;
55+
}
56+
body {
57+
@apply bg-background text-foreground;
58+
}
59+
}

app/layout.tsx

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import ThemeProvider from "@/components/ThemeToggle/theme-provider";
2+
import "../styles/global.css";
3+
import "./globals.css";
4+
import { Metadata } from "next";
5+
import Header from "@/components/Header";
6+
import { Toaster } from "@/components/ui/sonner";
7+
8+
export const metadata: Metadata = {
9+
title: "Remotion and Next.js",
10+
description: "Remotion and Next.js",
11+
viewport: "width=device-width, initial-scale=1, maximum-scale=1",
12+
};
13+
14+
export default function RootLayout({
15+
// Layouts must accept a children prop.
16+
// This will be populated with nested layouts or pages
17+
children,
18+
}: {
19+
children: React.ReactNode;
20+
}) {
21+
return (
22+
<html lang="en">
23+
<body>
24+
<ThemeProvider>
25+
<Header />
26+
{children}
27+
<Toaster />
28+
</ThemeProvider>
29+
</body>
30+
</html>
31+
);
32+
}

app/page.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"use client";
2+
3+
import { NextPage } from "next";
4+
import MainSection from "../components/MainSection";
5+
6+
const Home: NextPage = () => {
7+
return (
8+
<>
9+
<MainSection />
10+
</>
11+
);
12+
};
13+
14+
export default Home;

components.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.js",
8+
"css": "app/globals.css",
9+
"baseColor": "slate",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}

components/AlignEnd.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from "react";
2+
3+
const container: React.CSSProperties = {
4+
alignSelf: "flex-end",
5+
};
6+
7+
export const AlignEnd: React.FC<{
8+
children: React.ReactNode;
9+
}> = ({ children }) => {
10+
return <div style={container}>{children}</div>;
11+
};

0 commit comments

Comments
 (0)