@revideo/create 0.3.7-blue.987 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/examples/README.md +39 -0
  2. package/examples/avatar-with-background/package-lock.json +3162 -0
  3. package/examples/avatar-with-background/package.json +26 -0
  4. package/examples/avatar-with-background/src/project.meta +31 -0
  5. package/examples/avatar-with-background/src/project.ts +6 -0
  6. package/examples/avatar-with-background/src/render.ts +36 -0
  7. package/examples/avatar-with-background/src/revideo.d.ts +1 -0
  8. package/examples/avatar-with-background/src/scenes/example.tsx +28 -0
  9. package/examples/avatar-with-background/tsconfig.json +9 -0
  10. package/examples/avatar-with-background/vite.config.ts +8 -0
  11. package/examples/default/package.json +24 -0
  12. package/examples/default/src/project.meta +31 -0
  13. package/examples/default/src/project.ts +7 -0
  14. package/examples/default/src/render.ts +16 -0
  15. package/examples/default/src/revideo.d.ts +1 -0
  16. package/examples/default/src/scenes/example.tsx +38 -0
  17. package/examples/default/tsconfig.json +9 -0
  18. package/examples/default/vite.config.ts +8 -0
  19. package/examples/google-cloud-run/Dockerfile +56 -0
  20. package/examples/google-cloud-run/README.md +35 -0
  21. package/examples/google-cloud-run/package.json +28 -0
  22. package/examples/google-cloud-run/src/index.ts +39 -0
  23. package/examples/google-cloud-run/src/project.meta +31 -0
  24. package/examples/google-cloud-run/src/project.ts +7 -0
  25. package/examples/google-cloud-run/src/revideo.d.ts +1 -0
  26. package/examples/google-cloud-run/src/scenes/example.meta +5 -0
  27. package/examples/google-cloud-run/src/scenes/example.tsx +30 -0
  28. package/examples/google-cloud-run/tsconfig.json +9 -0
  29. package/examples/google-cloud-run/vite.config.ts +9 -0
  30. package/examples/google-cloud-run-parallelized/README.md +127 -0
  31. package/examples/google-cloud-run-parallelized/render-orchestrator/Dockerfile +56 -0
  32. package/examples/google-cloud-run-parallelized/render-orchestrator/package.json +22 -0
  33. package/examples/google-cloud-run-parallelized/render-orchestrator/src/index.ts +72 -0
  34. package/examples/google-cloud-run-parallelized/render-orchestrator/src/revideo.d.ts +1 -0
  35. package/examples/google-cloud-run-parallelized/render-orchestrator/tsconfig.json +10 -0
  36. package/examples/google-cloud-run-parallelized/render-worker/.gcloudignore +17 -0
  37. package/examples/google-cloud-run-parallelized/render-worker/.puppeteerrc.cjs +9 -0
  38. package/examples/google-cloud-run-parallelized/render-worker/package.json +30 -0
  39. package/examples/google-cloud-run-parallelized/render-worker/src/index.ts +39 -0
  40. package/examples/google-cloud-run-parallelized/render-worker/src/project.ts +6 -0
  41. package/examples/google-cloud-run-parallelized/render-worker/src/revideo.d.ts +1 -0
  42. package/examples/google-cloud-run-parallelized/render-worker/src/scenes/example.tsx +30 -0
  43. package/examples/google-cloud-run-parallelized/render-worker/tsconfig.json +13 -0
  44. package/examples/google-cloud-run-parallelized/render-worker/vite.config.ts +9 -0
  45. package/examples/logo.svg +6 -0
  46. package/examples/logo_dark.svg +6 -0
  47. package/examples/marketing-templates/README.md +10 -0
  48. package/examples/marketing-templates/marketing-template/package-lock.json +3824 -0
  49. package/examples/marketing-templates/marketing-template/package.json +24 -0
  50. package/examples/marketing-templates/marketing-template/src/globals.css +0 -0
  51. package/examples/marketing-templates/marketing-template/src/project.meta +31 -0
  52. package/examples/marketing-templates/marketing-template/src/project.ts +9 -0
  53. package/examples/marketing-templates/marketing-template/src/render.ts +17 -0
  54. package/examples/marketing-templates/marketing-template/src/revideo.d.ts +1 -0
  55. package/examples/marketing-templates/marketing-template/src/scenes/example.meta +5 -0
  56. package/examples/marketing-templates/marketing-template/src/scenes/example.tsx +67 -0
  57. package/examples/marketing-templates/marketing-template/tsconfig.json +9 -0
  58. package/examples/marketing-templates/marketing-template/vite.config.ts +9 -0
  59. package/examples/marketing-templates/multiple-videos-in-one/package-lock.json +3824 -0
  60. package/examples/marketing-templates/multiple-videos-in-one/package.json +24 -0
  61. package/examples/marketing-templates/multiple-videos-in-one/src/project.meta +31 -0
  62. package/examples/marketing-templates/multiple-videos-in-one/src/project.ts +9 -0
  63. package/examples/marketing-templates/multiple-videos-in-one/src/render.ts +17 -0
  64. package/examples/marketing-templates/multiple-videos-in-one/src/revideo.d.ts +1 -0
  65. package/examples/marketing-templates/multiple-videos-in-one/src/scenes/example.meta +5 -0
  66. package/examples/marketing-templates/multiple-videos-in-one/src/scenes/example.tsx +122 -0
  67. package/examples/marketing-templates/multiple-videos-in-one/tsconfig.json +9 -0
  68. package/examples/marketing-templates/multiple-videos-in-one/vite.config.ts +9 -0
  69. package/examples/saas-template/.prettierrc +9 -0
  70. package/examples/saas-template/README.md +28 -0
  71. package/examples/saas-template/next/app/actions.tsx +113 -0
  72. package/examples/saas-template/next/app/api/render/route.ts +22 -0
  73. package/examples/saas-template/next/app/globals.css +3 -0
  74. package/examples/saas-template/next/app/layout.tsx +25 -0
  75. package/examples/saas-template/next/app/page.tsx +182 -0
  76. package/examples/saas-template/next/next.config.mjs +4 -0
  77. package/examples/saas-template/next/package.json +34 -0
  78. package/examples/saas-template/next/postcss.config.js +6 -0
  79. package/examples/saas-template/next/public/favicon.ico +0 -0
  80. package/examples/saas-template/next/public/next.svg +1 -0
  81. package/examples/saas-template/next/public/vercel.svg +1 -0
  82. package/examples/saas-template/next/tailwind.config.ts +30 -0
  83. package/examples/saas-template/next/tsconfig.json +26 -0
  84. package/examples/saas-template/next/utils/parse.ts +35 -0
  85. package/examples/saas-template/revideo/package.json +24 -0
  86. package/examples/saas-template/revideo/src/global.css +1 -0
  87. package/examples/saas-template/revideo/src/project.meta +31 -0
  88. package/examples/saas-template/revideo/src/project.ts +9 -0
  89. package/examples/saas-template/revideo/src/render.ts +15 -0
  90. package/examples/saas-template/revideo/src/revideo.d.ts +1 -0
  91. package/examples/saas-template/revideo/src/scenes/example.meta +5 -0
  92. package/examples/saas-template/revideo/src/scenes/example.tsx +178 -0
  93. package/examples/saas-template/revideo/tsconfig.json +9 -0
  94. package/examples/saas-template/revideo/vite.config.ts +6 -0
  95. package/examples/stitching-videos/README.md +7 -0
  96. package/examples/stitching-videos/package-lock.json +2801 -0
  97. package/examples/stitching-videos/package.json +23 -0
  98. package/examples/stitching-videos/src/project.meta +31 -0
  99. package/examples/stitching-videos/src/project.ts +26 -0
  100. package/examples/stitching-videos/src/render.ts +58 -0
  101. package/examples/stitching-videos/src/revideo.d.ts +1 -0
  102. package/examples/stitching-videos/src/scenes/example.tsx +30 -0
  103. package/examples/stitching-videos/tsconfig.json +9 -0
  104. package/examples/stitching-videos/vite.config.ts +8 -0
  105. package/examples/youtube-shorts/README.md +65 -0
  106. package/examples/youtube-shorts/package-lock.json +3914 -0
  107. package/examples/youtube-shorts/package.json +30 -0
  108. package/examples/youtube-shorts/src/global.css +3 -0
  109. package/examples/youtube-shorts/src/metadata.json +635 -0
  110. package/examples/youtube-shorts/src/project.meta +31 -0
  111. package/examples/youtube-shorts/src/project.ts +9 -0
  112. package/examples/youtube-shorts/src/render.ts +40 -0
  113. package/examples/youtube-shorts/src/revideo.d.ts +1 -0
  114. package/examples/youtube-shorts/src/scenes/example.tsx +211 -0
  115. package/examples/youtube-shorts/src/utils.ts +123 -0
  116. package/examples/youtube-shorts/tsconfig.json +9 -0
  117. package/examples/youtube-shorts/vite.config.ts +8 -0
  118. package/index.js +0 -25
  119. package/package.json +9 -9
@@ -0,0 +1,127 @@
1
+ # Parallel Rendering with Cloud Functions
2
+
3
+ This project shows you how you can parallelize rendering across multiple Google Cloud functions to get much faster rendering speeds. Instead of rendering, say, 60 seconds of video in one process, we can also use 30 cloud functions to render 2s of video each, and afterwards stitch together the resulting partial videos.
4
+
5
+ In this example, we are going to deploy two services to Google Cloud:
6
+
7
+ - `/render-worker`: This is a Google Cloud Function that is responsible for rendering a partial video. It has access to your video template (`/render-worker/src/scenes`) and receives the number of total workers as well as its worker ID as an input. It accordingly exports the audio and visuals of the partial video.
8
+
9
+ - `/render-orchestrator`: This is a minimal Google Cloud Run service that manages the render workers and is your entrypoint to start rendering jobs. It receives rendering requests along with the number of desired workers, accordingly sends partial render requests to the render workers and merges their results together to obtain the final video
10
+
11
+ ## Getting Started
12
+
13
+ To get started, clone the `revideo-examples` repository and navigate to the `google-cloud-run-parallelized` directory.
14
+
15
+ ### Enable gcloud services
16
+
17
+ To set up your Google Cloud services, ensure that you have the gcloud CLI installed ([guide](https://cloud.google.com/sdk/docs/install)). Then, enable the required services to deploy Cloud Functions:
18
+
19
+ ```
20
+ gcloud services enable run.googleapis.com
21
+ gcloud services enable cloudfunctions.googleapis.com
22
+ gcloud services enable storage.googleapis.com
23
+ gcloud services enable cloudbuild.googleapis.com
24
+ ```
25
+
26
+ ### Create Storage Bucket
27
+
28
+ You'll need a storage bucket to save your videos as well as partial videos to. To create one, run the following command and replace `<your-region>` with your desired region (e.g. `us-east1`):
29
+
30
+ ```
31
+ gsutil mb -l <your-region> gs://<your-bucket-name>/
32
+ ```
33
+
34
+ Now enable public read access by running the following command:
35
+
36
+ ```
37
+ gsutil iam ch allUsers:objectViewer gs://<your-bucket-name>/
38
+ ```
39
+
40
+ Finally, you need to modify the CORS settings of your bucket. To do so, create the following file `cors_config.json`:
41
+
42
+ ```
43
+ [
44
+ {
45
+ "origin": ["*"],
46
+ "responseHeader": ["Content-Type"],
47
+ "method": ["GET", "HEAD", "DELETE"],
48
+ "maxAgeSeconds": 3600
49
+ }
50
+ ]
51
+ ```
52
+
53
+ Now run:
54
+
55
+ ```
56
+ gsutil cors set cors_config.json gs://<your-bucket-name>/
57
+ ```
58
+
59
+ Now you can deploy your render worker cloud function.
60
+
61
+
62
+ ### Deploy Render Worker Cloud Function
63
+
64
+ To deploy the render worker cloud function, navigate to `/render-worker` and run `npm install`. Now run the following command:
65
+
66
+ 🚨 **Note:** In the commands below, make sure to select the same region (<your-region>) as the bucket you just created. Otherwise, your render jobs will run much slower.
67
+
68
+ ```
69
+ gcloud functions deploy render-worker \
70
+ --runtime nodejs18 \
71
+ --trigger-http \
72
+ --allow-unauthenticated \
73
+ --gen2 \
74
+ --memory 4Gi \
75
+ --cpu 2 \
76
+ --concurrency=1 \
77
+ --timeout=3600s \
78
+ --region=<your-region> \
79
+ --set-env-vars=FFMPEG_PATH=ffmpeg,FFPROBE_PATH=ffprobe,GCP_BUCKET_NAME=<your-bucket-name>
80
+ ```
81
+
82
+ You'll now have to wait some time for the deployment. Once your cloud function is deployed, its URL will be logged to the terminal (we will reference it as `<your-render-function-url>`). You will need this URL to configure your cloud run service that calls the cloud function you just deployed.
83
+
84
+
85
+ ### Deploy Render Orchestrator Cloud Run Service
86
+
87
+ To deploy the service that orchestrates the cloud functions, navigate to `/render-orchestrator`, then run `npm install` and the following command:
88
+
89
+ ```
90
+ gcloud run deploy render-orchestrator \
91
+ --source . \
92
+ --memory 8Gi \
93
+ --cpu 4 \
94
+ --allow-unauthenticated \
95
+ --concurrency=1 \
96
+ --timeout=3600s \
97
+ --region <your-region> \
98
+ --set-env-vars=FFMPEG_PATH=ffmpeg,FFPROBE_PATH=ffprobe,GCP_BUCKET_NAME=<your-bucket-name>,RENDER_WORKER_URL=<your-render-function-url>
99
+ ```
100
+
101
+ Again, you'll have to wait a bit for the service to be deployed. Once that is done, you can send a request to its url `<your-render-orchestrator-url>`.
102
+
103
+ ### Sending a Request
104
+
105
+ Once the render worker and orchestrator are running, you can send a render request as follows:
106
+
107
+ ```
108
+ curl -X POST <your-render-orchestrator-url>/render \
109
+ -H "Content-Type: application/json" \
110
+ -d '{"variables": {"username": "John"}, "numWorkers": 5}'
111
+ ```
112
+
113
+ This will distribute the rendering work across five cloud functions. You can check out the logs and rendering progress in the Google Cloud Function logs.
114
+
115
+
116
+ ## Usage Notes
117
+
118
+ Some useful information, as well as considerations on what parameters to use:
119
+
120
+ **Cold Start times:**
121
+ Depending on your previous usage, your Google Cloud account & project might not be prioritized for cold start times, and thus the bottleneck of your render speeds might be cold start tiems. You can check the logs of your render worker function to see how fast the render workers spin up after sending the request. For example, we have noticed that after creating a new Google Cloud project, we sometimes had to wait for 30s+ for a render worker to spin up, whereas cold start times were very fast on a project that we had been using for a lot of time already.
122
+
123
+ **Video Duration:**
124
+ Parallel rendering is especially effective for longer videos (>1 min). For short videos, the overhead of waiting for a bunch of cloud functions to cold boot may not be worth it
125
+
126
+ **Choosing the number of workers:**
127
+ Depending on the length of the video you're going to render, you might want to adjust the `numWorkers` parameter. A single worker should not render less than a second of video
@@ -0,0 +1,56 @@
1
+ FROM node:18-bullseye
2
+
3
+ RUN apt-get update && apt-get install -y \
4
+ nscd \
5
+ libnss3 \
6
+ libdbus-1-3 \
7
+ libatk1.0-0 \
8
+ libatk-bridge2.0-0 \
9
+ libcups2 \
10
+ libxkbcommon0 \
11
+ libxcomposite1 \
12
+ libxdamage1 \
13
+ libxrandr2 \
14
+ libgbm1 \
15
+ libpango-1.0-0 \
16
+ libcairo2 \
17
+ libasound2 \
18
+ libatspi2.0-0
19
+
20
+ RUN apt-get install -y libxfixes3
21
+
22
+ WORKDIR /usr/src/app
23
+
24
+ RUN wget https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffmpeg-linux-x64
25
+
26
+ RUN chmod +x ffmpeg-linux-x64
27
+
28
+ RUN mv ffmpeg-linux-x64 ffmpeg
29
+
30
+ RUN mv ffmpeg /usr/local/bin/
31
+
32
+ ENV FFMPEG_PATH=ffmpeg
33
+
34
+ RUN wget https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffprobe-linux-x64
35
+
36
+ RUN chmod +x ffprobe-linux-x64
37
+
38
+ RUN mv ffprobe-linux-x64 ffprobe
39
+
40
+ RUN mv ffprobe /usr/local/bin/
41
+
42
+ ENV FFPROBE_PATH=ffprobe
43
+
44
+ COPY package*.json ./
45
+
46
+ COPY . ./
47
+
48
+ RUN npm install
49
+
50
+ RUN npx puppeteer browsers install chrome
51
+
52
+ RUN apt-get update && apt-get install -y nscd libnss3
53
+
54
+ RUN ffmpeg -version
55
+
56
+ CMD service nscd start && npm run serve
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "google-cloud-run",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "scripts": {
6
+ "start": "tsc && node dist/index.js"
7
+ },
8
+ "dependencies": {
9
+ "@google-cloud/storage": "^7.11.0",
10
+ "@revideo/2d": "0.3.6",
11
+ "@revideo/core": "0.3.6",
12
+ "@revideo/ffmpeg": "0.3.6",
13
+ "express": "^4.19.2",
14
+ "uuid": "^9.0.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/express": "^4.17.21",
18
+ "@types/uuid": "^9.0.8",
19
+ "typescript": "^5.4.5",
20
+ "vite": "^4.5"
21
+ }
22
+ }
@@ -0,0 +1,72 @@
1
+ import { mergeAudioWithVideo, concatenateMedia } from '@revideo/ffmpeg';
2
+ import { Storage } from '@google-cloud/storage';
3
+ import * as express from 'express';
4
+ import * as fs from 'fs';
5
+ import axios from 'axios';
6
+ import { v4 as uuidv4 } from 'uuid';
7
+
8
+ const storage = new Storage();
9
+
10
+ const app = express();
11
+ app.use(express.json());
12
+
13
+ app.get('/', (req, res) => {
14
+ res.status(200).send(`Hello World!`);
15
+ });
16
+
17
+ app.post('/render', async (req, res) => {
18
+ try {
19
+ const { variables, numWorkers } = req.body;
20
+ const jobId = uuidv4();
21
+
22
+ const renderPromises = [];
23
+ for (let i = 0; i < numWorkers; i++) {
24
+ renderPromises.push(makeRenderRequest(variables, i, numWorkers));
25
+ }
26
+
27
+ const results = await Promise.all(renderPromises);
28
+ const audios = results.map(result => result.audioUrl);
29
+ const videos = results.map(result => result.videoUrl);
30
+
31
+ await Promise.all([
32
+ concatenateMedia(audios, `${jobId}-audio.wav`),
33
+ concatenateMedia(videos, `${jobId}-visuals.mp4`)
34
+ ]);
35
+
36
+ await mergeAudioWithVideo(`${jobId}-audio.wav`, `${jobId}-visuals.mp4`, `${jobId}.mp4`);
37
+
38
+ const resultFileBuffer = fs.readFileSync(`${jobId}.mp4`);
39
+ await storage.bucket(process.env.GCP_BUCKET_NAME).file(`${jobId}.mp4`).save(resultFileBuffer);
40
+
41
+ res.status(200).json({
42
+ file: `https://storage.googleapis.com/${process.env.GCP_BUCKET_NAME}/${`${jobId}.mp4`}`
43
+ });
44
+ } catch (err) {
45
+ console.error('Error rendering video:', err);
46
+ res.status(500).send(`Error rendering video: ${err}`);
47
+ }
48
+ });
49
+
50
+ const port = parseInt(process.env.PORT) || 8080;
51
+ app.listen(port, () => {
52
+ console.log(`listening on port ${port}`);
53
+ });
54
+
55
+ async function makeRenderRequest(variables: any, workerId: number, numWorkers: number) {
56
+ try {
57
+ const response = await axios.post(`${process.env.RENDER_WORKER_URL}`, {
58
+ variables,
59
+ workerId,
60
+ numWorkers
61
+ }, {
62
+ headers: {
63
+ 'Content-Type': 'application/json'
64
+ }
65
+ });
66
+
67
+ return response.data;
68
+ } catch (error) {
69
+ console.error('Error making render request:', error);
70
+ }
71
+ }
72
+
@@ -0,0 +1 @@
1
+ /// <reference types="@revideo/core/project" />
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@revideo/2d/tsconfig.project.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "noEmit": false,
6
+ "outDir": "dist",
7
+ "module": "CommonJS"
8
+ }
9
+ }
10
+
@@ -0,0 +1,17 @@
1
+ # This file specifies files that are *not* uploaded to Google Cloud
2
+ # using gcloud. It follows the same syntax as .gitignore, with the addition of
3
+ # "#!include" directives (which insert the entries of the given .gitignore-style
4
+ # file at that point).
5
+ #
6
+ # For more information, run:
7
+ # $ gcloud topic gcloudignore
8
+ #
9
+ .gcloudignore
10
+ # If you would like to upload your .git directory, .gitignore file or files
11
+ # from your .gitignore file, remove the corresponding line
12
+ # below:
13
+ .git
14
+ .gitignore
15
+
16
+ node_modules
17
+ #!include:.gitignore
@@ -0,0 +1,9 @@
1
+ const { join } = require('path');
2
+
3
+ /**
4
+ * @type {import("puppeteer").Configuration}
5
+ */
6
+ module.exports = {
7
+ cacheDirectory: join(__dirname, '.cache', 'puppeteer'),
8
+ };
9
+ // [END monitoring_synthetic_monitoring_custom_puppeteer_cjs]
@@ -0,0 +1,30 @@
1
+ {
2
+ "main": "dist/index.js",
3
+ "scripts": {
4
+ "editor": "vite",
5
+ "build": "tsc",
6
+ "start": "functions-framework --target=TypescriptFunction",
7
+ "prestart": "npm run build",
8
+ "gcp-build": "node node_modules/puppeteer/install.mjs && npm run build"
9
+ },
10
+ "dependencies": {
11
+ "@ffmpeg-installer/ffmpeg": "^1.1.0",
12
+ "@ffprobe-installer/ffprobe": "^2.1.2",
13
+ "@google-cloud/functions-framework": "^3.4.0",
14
+ "@google-cloud/storage": "^7.11.0",
15
+ "@revideo/2d": "0.3.6",
16
+ "@revideo/cli": "^0.3.6",
17
+ "@revideo/core": "0.3.6",
18
+ "@revideo/ffmpeg": "0.3.6",
19
+ "@revideo/renderer": "0.3.6",
20
+ "@revideo/ui": "0.3.6",
21
+ "@revideo/vite-plugin": "0.3.6",
22
+ "@types/express": "^4.17.21",
23
+ "@types/uuid": "^9.0.8",
24
+ "express": "^4.19.2",
25
+ "puppeteer": "^22.9.0",
26
+ "typescript": "^5.2.2",
27
+ "uuid": "^9.0.1",
28
+ "vite": "^4.5"
29
+ }
30
+ }
@@ -0,0 +1,39 @@
1
+ import * as ff from '@google-cloud/functions-framework';
2
+ import { renderPartialVideo } from '@revideo/renderer';
3
+ import { Storage } from '@google-cloud/storage';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+ import * as fs from 'fs';
6
+
7
+ const storage = new Storage();
8
+
9
+ ff.http('render-worker', async (req: ff.Request, res: ff.Response) => {
10
+ try {
11
+ const { workerId, numWorkers, variables } = req.body;
12
+ const jobId = uuidv4();
13
+
14
+ console.log("Rendering video...")
15
+ const {audioFile, videoFile} = await renderPartialVideo("./vite.config.ts", workerId, numWorkers, variables, () => {}, { name: jobId, logProgress: true, puppeteer: { args: ['--no-sandbox', '--disable-setuid-sandbox'] }});
16
+
17
+ const audioFileName = `${jobId}-audio.mp3`;
18
+ const audioFileBuffer = fs.readFileSync(audioFile);
19
+ const audioFileUploadPromise = storage.bucket(process.env.GCP_BUCKET_NAME || "").file(audioFileName).save(audioFileBuffer);
20
+
21
+ const videoFileName = `${jobId}-video.mp4`;
22
+ const videoFileBuffer = fs.readFileSync(videoFile);
23
+ const videoFileUploadPromise = storage.bucket(process.env.GCP_BUCKET_NAME || "").file(videoFileName).save(videoFileBuffer);
24
+
25
+ await Promise.all([audioFileUploadPromise, videoFileUploadPromise]);
26
+ const audioFileUrl = `https://storage.googleapis.com/${process.env.GCP_BUCKET_NAME || ""}/${audioFileName}`;
27
+ const videoFileUrl = `https://storage.googleapis.com/${process.env.GCP_BUCKET_NAME || ""}/${videoFileName}`;
28
+
29
+ console.log("done");
30
+ res.status(200).json({
31
+ audioUrl: audioFileUrl,
32
+ videoUrl: videoFileUrl
33
+ });
34
+
35
+ } catch (err) {
36
+ console.error('Error rendering video:', err);
37
+ res.status(500).send(`Error rendering video: ${err}`);
38
+ }
39
+ });
@@ -0,0 +1,6 @@
1
+ import {makeProject} from '@revideo/core';
2
+ import example from './scenes/example?scene';
3
+
4
+ export default makeProject({
5
+ scenes: [example],
6
+ });
@@ -0,0 +1 @@
1
+ /// <reference types="@revideo/core/project" />
@@ -0,0 +1,30 @@
1
+ import {Audio, Txt, Video, makeScene2D} from '@revideo/2d';
2
+ import {all, chain, createRef, waitFor, useScene} from '@revideo/core';
3
+
4
+ export default makeScene2D(function* (view) {
5
+ const textRef = createRef<Txt>();
6
+
7
+ yield view.add(
8
+ <>
9
+ <Video
10
+ src={'https://revideo-example-assets.s3.amazonaws.com/beach-3.mp4'}
11
+ size={['100%', '100%']}
12
+ play={true}
13
+ />
14
+ <Audio
15
+ src={'https://revideo-example-assets.s3.amazonaws.com/chill-beat.mp3'}
16
+ play={true}
17
+ time={17.0}
18
+ />
19
+ </>,
20
+ );
21
+
22
+ yield* waitFor(1);
23
+
24
+ view.add(
25
+ <Txt fontFamily={"Sans-Serif"} fill={"white"} fontSize={10} ref={textRef}>Hello {useScene().variables.get("username", "user")()}</Txt>
26
+ );
27
+
28
+ yield* textRef().scale(10, 1);
29
+ yield* waitFor(30);
30
+ });
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "@revideo/2d/tsconfig.project.json",
3
+ "compilerOptions": {
4
+ "target": "es2016",
5
+ "module": "commonjs",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "outDir": "dist",
9
+ "noEmit": false
10
+ },
11
+ "include": ["src/**/*"],
12
+ "exclude": ["node_modules"]
13
+ }
@@ -0,0 +1,9 @@
1
+ import {defineConfig} from 'vite';
2
+ import motionCanvas from '@revideo/vite-plugin';
3
+
4
+
5
+ export default defineConfig({
6
+ plugins: [
7
+ motionCanvas(),
8
+ ],
9
+ });
@@ -0,0 +1,6 @@
1
+ <svg width="1498" height="363" viewBox="0 0 1498 363" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M444.3 294V134.7H489.9L492 186.6L483 176.7C485.4 168.1 489.3 160.4 494.7 153.6C500.3 146.8 506.8 141.4 514.2 137.4C521.6 133.4 529.5 131.4 537.9 131.4C541.5 131.4 544.8 131.7 547.8 132.3C551 132.9 553.9 133.6 556.5 134.4L543.3 187.5C541.1 186.1 538.1 185 534.3 184.2C530.7 183.2 526.9 182.7 522.9 182.7C518.5 182.7 514.4 183.5 510.6 185.1C506.8 186.5 503.6 188.6 501 191.4C498.4 194.2 496.3 197.5 494.7 201.3C493.3 205.1 492.6 209.4 492.6 214.2V294H444.3ZM637.985 297C620.385 297 605.085 293.5 592.085 286.5C579.085 279.3 568.985 269.6 561.785 257.4C554.585 245 550.985 230.9 550.985 215.1C550.985 202.9 552.985 191.7 556.985 181.5C560.985 171.3 566.585 162.5 573.785 155.1C580.985 147.5 589.485 141.7 599.285 137.7C609.285 133.5 620.185 131.4 631.985 131.4C643.185 131.4 653.385 133.4 662.585 137.4C671.985 141.4 680.085 147 686.885 154.2C693.685 161.4 698.885 169.9 702.485 179.7C706.085 189.5 707.685 200.2 707.285 211.8L706.985 224.7H580.085L573.185 197.7H667.985L662.885 203.4V197.4C662.485 192.4 660.885 188 658.085 184.2C655.485 180.2 651.985 177.1 647.585 174.9C643.185 172.7 638.185 171.6 632.585 171.6C624.785 171.6 618.085 173.2 612.485 176.4C607.085 179.4 602.985 183.9 600.185 189.9C597.385 195.7 595.985 202.9 595.985 211.5C595.985 220.3 597.785 228 601.385 234.6C605.185 241 610.585 246 617.585 249.6C624.785 253.2 633.285 255 643.085 255C649.885 255 655.885 254 661.085 252C666.485 250 672.285 246.6 678.485 241.8L700.985 273.6C694.785 279 688.185 283.4 681.185 286.8C674.185 290.2 666.985 292.7 659.585 294.3C652.385 296.1 645.185 297 637.985 297ZM771.837 294L705.237 134.7H758.337L797.937 253.8L786.237 255L827.037 134.7H879.537L809.637 294H771.837ZM895.277 294V134.7H943.277V294H895.277ZM919.277 103.2C910.277 103.2 903.177 101.1 897.977 96.9C892.977 92.5 890.477 86.3 890.477 78.3C890.477 71.1 893.077 65.2 898.277 60.6C903.477 56 910.477 53.7 919.277 53.7C928.277 53.7 935.277 55.9 940.277 60.3C945.277 64.5 947.777 70.5 947.777 78.3C947.777 85.7 945.177 91.7 939.977 96.3C934.977 100.9 928.077 103.2 919.277 103.2ZM1036.68 297.3C1022.88 297.3 1010.58 293.8 999.778 286.8C989.178 279.6 980.778 269.8 974.578 257.4C968.378 244.8 965.278 230.5 965.278 214.5C965.278 198.5 968.378 184.3 974.578 171.9C980.778 159.3 989.278 149.4 1000.08 142.2C1010.88 135 1023.28 131.4 1037.28 131.4C1044.48 131.4 1051.38 132.5 1057.98 134.7C1064.58 136.9 1070.58 139.9 1075.98 143.7C1081.38 147.5 1085.78 151.9 1089.18 156.9C1092.58 161.7 1094.58 166.7 1095.18 171.9L1083.78 174.6V72H1132.08V294H1087.38L1084.68 257.7L1094.28 259.2C1093.68 264.2 1091.68 269 1088.28 273.6C1085.08 278.2 1080.88 282.3 1075.68 285.9C1070.48 289.3 1064.48 292 1057.68 294C1051.08 296.2 1044.08 297.3 1036.68 297.3ZM1048.98 257.4C1056.38 257.4 1062.78 255.6 1068.18 252C1073.58 248.4 1077.68 243.4 1080.48 237C1083.48 230.6 1084.98 223.1 1084.98 214.5C1084.98 205.7 1083.48 198.1 1080.48 191.7C1077.68 185.3 1073.58 180.3 1068.18 176.7C1062.78 173.1 1056.38 171.3 1048.98 171.3C1041.58 171.3 1035.18 173.1 1029.78 176.7C1024.58 180.3 1020.48 185.3 1017.48 191.7C1014.48 198.1 1012.98 205.7 1012.98 214.5C1012.98 223.1 1014.48 230.6 1017.48 237C1020.48 243.4 1024.58 248.4 1029.78 252C1035.18 255.6 1041.58 257.4 1048.98 257.4ZM1236.57 297C1218.97 297 1203.67 293.5 1190.67 286.5C1177.67 279.3 1167.57 269.6 1160.37 257.4C1153.17 245 1149.57 230.9 1149.57 215.1C1149.57 202.9 1151.57 191.7 1155.57 181.5C1159.57 171.3 1165.17 162.5 1172.37 155.1C1179.57 147.5 1188.07 141.7 1197.87 137.7C1207.87 133.5 1218.77 131.4 1230.57 131.4C1241.77 131.4 1251.97 133.4 1261.17 137.4C1270.57 141.4 1278.67 147 1285.47 154.2C1292.27 161.4 1297.47 169.9 1301.07 179.7C1304.67 189.5 1306.27 200.2 1305.87 211.8L1305.57 224.7H1178.67L1171.77 197.7H1266.57L1261.47 203.4V197.4C1261.07 192.4 1259.47 188 1256.67 184.2C1254.07 180.2 1250.57 177.1 1246.17 174.9C1241.77 172.7 1236.77 171.6 1231.17 171.6C1223.37 171.6 1216.67 173.2 1211.07 176.4C1205.67 179.4 1201.57 183.9 1198.77 189.9C1195.97 195.7 1194.57 202.9 1194.57 211.5C1194.57 220.3 1196.37 228 1199.97 234.6C1203.77 241 1209.17 246 1216.17 249.6C1223.37 253.2 1231.87 255 1241.67 255C1248.47 255 1254.47 254 1259.67 252C1265.07 250 1270.87 246.6 1277.07 241.8L1299.57 273.6C1293.37 279 1286.77 283.4 1279.77 286.8C1272.77 290.2 1265.57 292.7 1258.17 294.3C1250.97 296.1 1243.77 297 1236.57 297ZM1399.45 297C1382.85 297 1368.05 293.4 1355.05 286.2C1342.25 279 1332.05 269.2 1324.45 256.8C1317.05 244.4 1313.35 230.2 1313.35 214.2C1313.35 198.2 1317.05 184 1324.45 171.6C1332.05 159.2 1342.25 149.4 1355.05 142.2C1368.05 135 1382.85 131.4 1399.45 131.4C1416.05 131.4 1430.75 135 1443.55 142.2C1456.55 149.4 1466.75 159.2 1474.15 171.6C1481.55 184 1485.25 198.2 1485.25 214.2C1485.25 230.2 1481.55 244.4 1474.15 256.8C1466.75 269.2 1456.55 279 1443.55 286.2C1430.75 293.4 1416.05 297 1399.45 297ZM1399.45 255.6C1406.65 255.6 1413.05 253.8 1418.65 250.2C1424.25 246.6 1428.65 241.7 1431.85 235.5C1435.05 229.3 1436.55 222.2 1436.35 214.2C1436.55 206.2 1435.05 199.1 1431.85 192.9C1428.65 186.5 1424.25 181.5 1418.65 177.9C1413.05 174.3 1406.65 172.5 1399.45 172.5C1392.25 172.5 1385.75 174.3 1379.95 177.9C1374.35 181.5 1369.95 186.5 1366.75 192.9C1363.55 199.1 1362.05 206.2 1362.25 214.2C1362.05 222.2 1363.55 229.3 1366.75 235.5C1369.95 241.7 1374.35 246.6 1379.95 250.2C1385.75 253.8 1392.25 255.6 1399.45 255.6Z" fill="#101010"/>
3
+ <rect y="74" width="180" height="59.7841" rx="9.34127" fill="#101010"/>
4
+ <path d="M70 163.341C70 158.182 74.1822 154 79.3413 154H240.659C245.818 154 250 158.182 250 163.341V204.659C250 209.818 245.818 214 240.659 214H79.3413C74.1822 214 70 209.818 70 204.659V163.341Z" fill="#101010"/>
5
+ <rect x="140" y="234" width="180" height="60.2381" rx="9.34127" fill="#101010"/>
6
+ </svg>
@@ -0,0 +1,6 @@
1
+ <svg width="1498" height="363" viewBox="0 0 1498 363" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M444.3 294V134.7H489.9L492 186.6L483 176.7C485.4 168.1 489.3 160.4 494.7 153.6C500.3 146.8 506.8 141.4 514.2 137.4C521.6 133.4 529.5 131.4 537.9 131.4C541.5 131.4 544.8 131.7 547.8 132.3C551 132.9 553.9 133.6 556.5 134.4L543.3 187.5C541.1 186.1 538.1 185 534.3 184.2C530.7 183.2 526.9 182.7 522.9 182.7C518.5 182.7 514.4 183.5 510.6 185.1C506.8 186.5 503.6 188.6 501 191.4C498.4 194.2 496.3 197.5 494.7 201.3C493.3 205.1 492.6 209.4 492.6 214.2V294H444.3ZM637.985 297C620.385 297 605.085 293.5 592.085 286.5C579.085 279.3 568.985 269.6 561.785 257.4C554.585 245 550.985 230.9 550.985 215.1C550.985 202.9 552.985 191.7 556.985 181.5C560.985 171.3 566.585 162.5 573.785 155.1C580.985 147.5 589.485 141.7 599.285 137.7C609.285 133.5 620.185 131.4 631.985 131.4C643.185 131.4 653.385 133.4 662.585 137.4C671.985 141.4 680.085 147 686.885 154.2C693.685 161.4 698.885 169.9 702.485 179.7C706.085 189.5 707.685 200.2 707.285 211.8L706.985 224.7H580.085L573.185 197.7H667.985L662.885 203.4V197.4C662.485 192.4 660.885 188 658.085 184.2C655.485 180.2 651.985 177.1 647.585 174.9C643.185 172.7 638.185 171.6 632.585 171.6C624.785 171.6 618.085 173.2 612.485 176.4C607.085 179.4 602.985 183.9 600.185 189.9C597.385 195.7 595.985 202.9 595.985 211.5C595.985 220.3 597.785 228 601.385 234.6C605.185 241 610.585 246 617.585 249.6C624.785 253.2 633.285 255 643.085 255C649.885 255 655.885 254 661.085 252C666.485 250 672.285 246.6 678.485 241.8L700.985 273.6C694.785 279 688.185 283.4 681.185 286.8C674.185 290.2 666.985 292.7 659.585 294.3C652.385 296.1 645.185 297 637.985 297ZM771.837 294L705.237 134.7H758.337L797.937 253.8L786.237 255L827.037 134.7H879.537L809.637 294H771.837ZM895.277 294V134.7H943.277V294H895.277ZM919.277 103.2C910.277 103.2 903.177 101.1 897.977 96.9C892.977 92.5 890.477 86.3 890.477 78.3C890.477 71.1 893.077 65.2 898.277 60.6C903.477 56 910.477 53.7 919.277 53.7C928.277 53.7 935.277 55.9 940.277 60.3C945.277 64.5 947.777 70.5 947.777 78.3C947.777 85.7 945.177 91.7 939.977 96.3C934.977 100.9 928.077 103.2 919.277 103.2ZM1036.68 297.3C1022.88 297.3 1010.58 293.8 999.778 286.8C989.178 279.6 980.778 269.8 974.578 257.4C968.378 244.8 965.278 230.5 965.278 214.5C965.278 198.5 968.378 184.3 974.578 171.9C980.778 159.3 989.278 149.4 1000.08 142.2C1010.88 135 1023.28 131.4 1037.28 131.4C1044.48 131.4 1051.38 132.5 1057.98 134.7C1064.58 136.9 1070.58 139.9 1075.98 143.7C1081.38 147.5 1085.78 151.9 1089.18 156.9C1092.58 161.7 1094.58 166.7 1095.18 171.9L1083.78 174.6V72H1132.08V294H1087.38L1084.68 257.7L1094.28 259.2C1093.68 264.2 1091.68 269 1088.28 273.6C1085.08 278.2 1080.88 282.3 1075.68 285.9C1070.48 289.3 1064.48 292 1057.68 294C1051.08 296.2 1044.08 297.3 1036.68 297.3ZM1048.98 257.4C1056.38 257.4 1062.78 255.6 1068.18 252C1073.58 248.4 1077.68 243.4 1080.48 237C1083.48 230.6 1084.98 223.1 1084.98 214.5C1084.98 205.7 1083.48 198.1 1080.48 191.7C1077.68 185.3 1073.58 180.3 1068.18 176.7C1062.78 173.1 1056.38 171.3 1048.98 171.3C1041.58 171.3 1035.18 173.1 1029.78 176.7C1024.58 180.3 1020.48 185.3 1017.48 191.7C1014.48 198.1 1012.98 205.7 1012.98 214.5C1012.98 223.1 1014.48 230.6 1017.48 237C1020.48 243.4 1024.58 248.4 1029.78 252C1035.18 255.6 1041.58 257.4 1048.98 257.4ZM1236.57 297C1218.97 297 1203.67 293.5 1190.67 286.5C1177.67 279.3 1167.57 269.6 1160.37 257.4C1153.17 245 1149.57 230.9 1149.57 215.1C1149.57 202.9 1151.57 191.7 1155.57 181.5C1159.57 171.3 1165.17 162.5 1172.37 155.1C1179.57 147.5 1188.07 141.7 1197.87 137.7C1207.87 133.5 1218.77 131.4 1230.57 131.4C1241.77 131.4 1251.97 133.4 1261.17 137.4C1270.57 141.4 1278.67 147 1285.47 154.2C1292.27 161.4 1297.47 169.9 1301.07 179.7C1304.67 189.5 1306.27 200.2 1305.87 211.8L1305.57 224.7H1178.67L1171.77 197.7H1266.57L1261.47 203.4V197.4C1261.07 192.4 1259.47 188 1256.67 184.2C1254.07 180.2 1250.57 177.1 1246.17 174.9C1241.77 172.7 1236.77 171.6 1231.17 171.6C1223.37 171.6 1216.67 173.2 1211.07 176.4C1205.67 179.4 1201.57 183.9 1198.77 189.9C1195.97 195.7 1194.57 202.9 1194.57 211.5C1194.57 220.3 1196.37 228 1199.97 234.6C1203.77 241 1209.17 246 1216.17 249.6C1223.37 253.2 1231.87 255 1241.67 255C1248.47 255 1254.47 254 1259.67 252C1265.07 250 1270.87 246.6 1277.07 241.8L1299.57 273.6C1293.37 279 1286.77 283.4 1279.77 286.8C1272.77 290.2 1265.57 292.7 1258.17 294.3C1250.97 296.1 1243.77 297 1236.57 297ZM1399.45 297C1382.85 297 1368.05 293.4 1355.05 286.2C1342.25 279 1332.05 269.2 1324.45 256.8C1317.05 244.4 1313.35 230.2 1313.35 214.2C1313.35 198.2 1317.05 184 1324.45 171.6C1332.05 159.2 1342.25 149.4 1355.05 142.2C1368.05 135 1382.85 131.4 1399.45 131.4C1416.05 131.4 1430.75 135 1443.55 142.2C1456.55 149.4 1466.75 159.2 1474.15 171.6C1481.55 184 1485.25 198.2 1485.25 214.2C1485.25 230.2 1481.55 244.4 1474.15 256.8C1466.75 269.2 1456.55 279 1443.55 286.2C1430.75 293.4 1416.05 297 1399.45 297ZM1399.45 255.6C1406.65 255.6 1413.05 253.8 1418.65 250.2C1424.25 246.6 1428.65 241.7 1431.85 235.5C1435.05 229.3 1436.55 222.2 1436.35 214.2C1436.55 206.2 1435.05 199.1 1431.85 192.9C1428.65 186.5 1424.25 181.5 1418.65 177.9C1413.05 174.3 1406.65 172.5 1399.45 172.5C1392.25 172.5 1385.75 174.3 1379.95 177.9C1374.35 181.5 1369.95 186.5 1366.75 192.9C1363.55 199.1 1362.05 206.2 1362.25 214.2C1362.05 222.2 1363.55 229.3 1366.75 235.5C1369.95 241.7 1374.35 246.6 1379.95 250.2C1385.75 253.8 1392.25 255.6 1399.45 255.6Z" fill="#F5F5F5"/>
3
+ <rect y="74" width="180" height="59.7841" rx="9.34127" fill="#F5F5F5"/>
4
+ <path d="M70 163.341C70 158.182 74.1822 154 79.3413 154H240.659C245.818 154 250 158.182 250 163.341V204.659C250 209.818 245.818 214 240.659 214H79.3413C74.1822 214 70 209.818 70 204.659V163.341Z" fill="#F5F5F5"/>
5
+ <rect x="140" y="234" width="180" height="60.2381" rx="9.34127" fill="#F5F5F5"/>
6
+ </svg>
@@ -0,0 +1,10 @@
1
+ # Marketing Templates
2
+
3
+ This project contains the implementation of a template for a social media post advertising Black Friday discounts. The implementation can be found in `/marketing-template`.
4
+
5
+ https://github.com/redotvideo/examples/assets/122226645/e0b8ef10-737e-4ea7-8a1e-cc2edca676eb
6
+
7
+ The folder `multiple-videos-in-one` contains the following variation:
8
+
9
+ https://github.com/redotvideo/examples/assets/122226645/52b5c42d-ffd3-4bb4-bb08-bfb5c8283e03
10
+