@revideo/create 0.5.11-alpha.1102 → 0.5.11-alpha.1104

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 (185) hide show
  1. package/examples/README.md +43 -0
  2. package/examples/avatar-with-background/package.json +27 -0
  3. package/examples/avatar-with-background/src/project.meta +31 -0
  4. package/examples/avatar-with-background/src/project.ts +6 -0
  5. package/examples/avatar-with-background/src/render.ts +14 -0
  6. package/examples/avatar-with-background/src/revideo.d.ts +1 -0
  7. package/examples/avatar-with-background/src/scenes/example.meta +5 -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/README.md +19 -0
  12. package/examples/default/package.json +20 -0
  13. package/examples/default/src/project.tsx +56 -0
  14. package/examples/default/src/render.ts +15 -0
  15. package/examples/default/tsconfig.json +10 -0
  16. package/examples/github-stars-celebration/package-lock.json +3833 -0
  17. package/examples/github-stars-celebration/package.json +24 -0
  18. package/examples/github-stars-celebration/src/global.css +1 -0
  19. package/examples/github-stars-celebration/src/project.meta +28 -0
  20. package/examples/github-stars-celebration/src/project.ts +8 -0
  21. package/examples/github-stars-celebration/src/render.ts +15 -0
  22. package/examples/github-stars-celebration/src/revideo.d.ts +1 -0
  23. package/examples/github-stars-celebration/src/scenes/example.meta +5 -0
  24. package/examples/github-stars-celebration/src/scenes/example.tsx +51 -0
  25. package/examples/github-stars-celebration/tsconfig.json +9 -0
  26. package/examples/github-stars-celebration/vite.config.ts +8 -0
  27. package/examples/google-cloud-run-parallelized/README.md +127 -0
  28. package/examples/google-cloud-run-parallelized/render-orchestrator/Dockerfile +56 -0
  29. package/examples/google-cloud-run-parallelized/render-orchestrator/package.json +22 -0
  30. package/examples/google-cloud-run-parallelized/render-orchestrator/src/index.ts +72 -0
  31. package/examples/google-cloud-run-parallelized/render-orchestrator/src/revideo.d.ts +1 -0
  32. package/examples/google-cloud-run-parallelized/render-orchestrator/tsconfig.json +10 -0
  33. package/examples/google-cloud-run-parallelized/render-worker/.gcloudignore +17 -0
  34. package/examples/google-cloud-run-parallelized/render-worker/.puppeteerrc.cjs +9 -0
  35. package/examples/google-cloud-run-parallelized/render-worker/package.json +30 -0
  36. package/examples/google-cloud-run-parallelized/render-worker/src/index.ts +45 -0
  37. package/examples/google-cloud-run-parallelized/render-worker/src/project.meta +31 -0
  38. package/examples/google-cloud-run-parallelized/render-worker/src/project.ts +6 -0
  39. package/examples/google-cloud-run-parallelized/render-worker/src/render.ts +14 -0
  40. package/examples/google-cloud-run-parallelized/render-worker/src/revideo.d.ts +1 -0
  41. package/examples/google-cloud-run-parallelized/render-worker/src/scenes/example.tsx +30 -0
  42. package/examples/google-cloud-run-parallelized/render-worker/tsconfig.json +13 -0
  43. package/examples/google-cloud-run-parallelized/render-worker/vite.config.ts +9 -0
  44. package/examples/logo.svg +6 -0
  45. package/examples/logo_dark.svg +6 -0
  46. package/examples/marketing-templates/README.md +10 -0
  47. package/examples/marketing-templates/marketing-template/package.json +24 -0
  48. package/examples/marketing-templates/marketing-template/src/globals.css +0 -0
  49. package/examples/marketing-templates/marketing-template/src/project.meta +28 -0
  50. package/examples/marketing-templates/marketing-template/src/project.ts +9 -0
  51. package/examples/marketing-templates/marketing-template/src/render.ts +15 -0
  52. package/examples/marketing-templates/marketing-template/src/revideo.d.ts +1 -0
  53. package/examples/marketing-templates/marketing-template/src/scenes/example.meta +5 -0
  54. package/examples/marketing-templates/marketing-template/src/scenes/example.tsx +67 -0
  55. package/examples/marketing-templates/marketing-template/tsconfig.json +9 -0
  56. package/examples/marketing-templates/marketing-template/vite.config.ts +9 -0
  57. package/examples/marketing-templates/multiple-videos-in-one/package.json +24 -0
  58. package/examples/marketing-templates/multiple-videos-in-one/src/project.meta +28 -0
  59. package/examples/marketing-templates/multiple-videos-in-one/src/project.ts +9 -0
  60. package/examples/marketing-templates/multiple-videos-in-one/src/render.ts +15 -0
  61. package/examples/marketing-templates/multiple-videos-in-one/src/revideo.d.ts +1 -0
  62. package/examples/marketing-templates/multiple-videos-in-one/src/scenes/example.meta +5 -0
  63. package/examples/marketing-templates/multiple-videos-in-one/src/scenes/example.tsx +122 -0
  64. package/examples/marketing-templates/multiple-videos-in-one/tsconfig.json +9 -0
  65. package/examples/marketing-templates/multiple-videos-in-one/vite.config.ts +9 -0
  66. package/examples/minimal-drag-drop/README.md +29 -0
  67. package/examples/minimal-drag-drop/next/app/api/render/route.ts +22 -0
  68. package/examples/minimal-drag-drop/next/app/globals.css +3 -0
  69. package/examples/minimal-drag-drop/next/app/layout.tsx +25 -0
  70. package/examples/minimal-drag-drop/next/app/page.tsx +277 -0
  71. package/examples/minimal-drag-drop/next/next-env.d.ts +5 -0
  72. package/examples/minimal-drag-drop/next/next.config.mjs +4 -0
  73. package/examples/minimal-drag-drop/next/package-lock.json +5577 -0
  74. package/examples/minimal-drag-drop/next/package.json +35 -0
  75. package/examples/minimal-drag-drop/next/postcss.config.js +6 -0
  76. package/examples/minimal-drag-drop/next/public/favicon.ico +0 -0
  77. package/examples/minimal-drag-drop/next/public/next.svg +1 -0
  78. package/examples/minimal-drag-drop/next/public/vercel.svg +1 -0
  79. package/examples/minimal-drag-drop/next/tailwind.config.ts +30 -0
  80. package/examples/minimal-drag-drop/next/tsconfig.json +26 -0
  81. package/examples/minimal-drag-drop/next/utils/parse.ts +35 -0
  82. package/examples/minimal-drag-drop/revideo/package-lock.json +3771 -0
  83. package/examples/minimal-drag-drop/revideo/package.json +24 -0
  84. package/examples/minimal-drag-drop/revideo/src/global.css +1 -0
  85. package/examples/minimal-drag-drop/revideo/src/project.meta +28 -0
  86. package/examples/minimal-drag-drop/revideo/src/project.ts +9 -0
  87. package/examples/minimal-drag-drop/revideo/src/render.ts +15 -0
  88. package/examples/minimal-drag-drop/revideo/src/revideo.d.ts +1 -0
  89. package/examples/minimal-drag-drop/revideo/src/scenes/example.meta +5 -0
  90. package/examples/minimal-drag-drop/revideo/src/scenes/example.tsx +44 -0
  91. package/examples/minimal-drag-drop/revideo/tsconfig.json +9 -0
  92. package/examples/minimal-drag-drop/revideo/vite.config.ts +6 -0
  93. package/examples/parallelized-aws-lambda/.dockerignore +3 -0
  94. package/examples/parallelized-aws-lambda/Dockerfile +21 -0
  95. package/examples/parallelized-aws-lambda/Dockerfile.base +64 -0
  96. package/examples/parallelized-aws-lambda/README.md +197 -0
  97. package/examples/parallelized-aws-lambda/revideo-project/.puppeteerrc.cjs +9 -0
  98. package/examples/parallelized-aws-lambda/revideo-project/package-lock.json +4133 -0
  99. package/examples/parallelized-aws-lambda/revideo-project/package.json +28 -0
  100. package/examples/parallelized-aws-lambda/revideo-project/src/lambda.ts +157 -0
  101. package/examples/parallelized-aws-lambda/revideo-project/src/project.meta +28 -0
  102. package/examples/parallelized-aws-lambda/revideo-project/src/project.ts +7 -0
  103. package/examples/parallelized-aws-lambda/revideo-project/src/render.ts +17 -0
  104. package/examples/parallelized-aws-lambda/revideo-project/src/revideo.d.ts +1 -0
  105. package/examples/parallelized-aws-lambda/revideo-project/src/scenes/example.meta +5 -0
  106. package/examples/parallelized-aws-lambda/revideo-project/src/scenes/example.tsx +30 -0
  107. package/examples/parallelized-aws-lambda/revideo-project/tsconfig.json +10 -0
  108. package/examples/parallelized-aws-lambda/revideo-project/vite.config.ts +9 -0
  109. package/examples/reddit-post-video/README.md +84 -0
  110. package/examples/reddit-post-video/package-lock.json +2941 -0
  111. package/examples/reddit-post-video/package.json +27 -0
  112. package/examples/reddit-post-video/src/global.css +1 -0
  113. package/examples/reddit-post-video/src/metadata.json +576 -0
  114. package/examples/reddit-post-video/src/project.meta +31 -0
  115. package/examples/reddit-post-video/src/project.ts +9 -0
  116. package/examples/reddit-post-video/src/render.ts +157 -0
  117. package/examples/reddit-post-video/src/revideo.d.ts +1 -0
  118. package/examples/reddit-post-video/src/scenes/example.meta +5 -0
  119. package/examples/reddit-post-video/src/scenes/example.tsx +74 -0
  120. package/examples/reddit-post-video/tsconfig.json +9 -0
  121. package/examples/reddit-post-video/vite.config.ts +6 -0
  122. package/examples/rive-explanation-video/README.md +9 -0
  123. package/examples/rive-explanation-video/package.json +25 -0
  124. package/examples/rive-explanation-video/src/global.css +1 -0
  125. package/examples/rive-explanation-video/src/project.meta +31 -0
  126. package/examples/rive-explanation-video/src/project.ts +8 -0
  127. package/examples/rive-explanation-video/src/render.ts +15 -0
  128. package/examples/rive-explanation-video/src/revideo.d.ts +1 -0
  129. package/examples/rive-explanation-video/src/scenes/example.meta +5 -0
  130. package/examples/rive-explanation-video/src/scenes/example.tsx +218 -0
  131. package/examples/rive-explanation-video/tsconfig.json +9 -0
  132. package/examples/rive-explanation-video/vite.config.ts +8 -0
  133. package/examples/saas-template/.prettierrc +9 -0
  134. package/examples/saas-template/README.md +26 -0
  135. package/examples/saas-template/app/actions.tsx +114 -0
  136. package/examples/saas-template/app/api/render/route.ts +23 -0
  137. package/examples/saas-template/app/globals.css +3 -0
  138. package/examples/saas-template/app/layout.tsx +25 -0
  139. package/examples/saas-template/app/page.tsx +204 -0
  140. package/examples/saas-template/next.config.mjs +4 -0
  141. package/examples/saas-template/package.json +40 -0
  142. package/examples/saas-template/postcss.config.js +6 -0
  143. package/examples/saas-template/revideo/global.css +1 -0
  144. package/examples/saas-template/revideo/project.ts +9 -0
  145. package/examples/saas-template/revideo/scene.tsx +179 -0
  146. package/examples/saas-template/tailwind.config.ts +30 -0
  147. package/examples/saas-template/tsconfig.json +27 -0
  148. package/examples/saas-template/utils/parse.ts +35 -0
  149. package/examples/stitching-videos/README.md +7 -0
  150. package/examples/stitching-videos/package.json +23 -0
  151. package/examples/stitching-videos/src/project.meta +28 -0
  152. package/examples/stitching-videos/src/project.ts +20 -0
  153. package/examples/stitching-videos/src/render.ts +27 -0
  154. package/examples/stitching-videos/src/revideo.d.ts +1 -0
  155. package/examples/stitching-videos/src/scenes/example.tsx +30 -0
  156. package/examples/stitching-videos/tsconfig.json +9 -0
  157. package/examples/stitching-videos/vite.config.ts +8 -0
  158. package/examples/three-js-example/README.md +8 -0
  159. package/examples/three-js-example/package-lock.json +2753 -0
  160. package/examples/three-js-example/package.json +25 -0
  161. package/examples/three-js-example/src/components/Three.ts +166 -0
  162. package/examples/three-js-example/src/global.css +1 -0
  163. package/examples/three-js-example/src/project.meta +31 -0
  164. package/examples/three-js-example/src/project.ts +8 -0
  165. package/examples/three-js-example/src/render.ts +15 -0
  166. package/examples/three-js-example/src/revideo.d.ts +1 -0
  167. package/examples/three-js-example/src/scenes/basic3D.meta +5 -0
  168. package/examples/three-js-example/src/scenes/basic3D.tsx +89 -0
  169. package/examples/three-js-example/tsconfig.json +9 -0
  170. package/examples/three-js-example/vite.config.ts +6 -0
  171. package/examples/youtube-shorts/README.md +65 -0
  172. package/examples/youtube-shorts/package-lock.json +3881 -0
  173. package/examples/youtube-shorts/package.json +30 -0
  174. package/examples/youtube-shorts/src/get-assets.ts +34 -0
  175. package/examples/youtube-shorts/src/global.css +3 -0
  176. package/examples/youtube-shorts/src/metadata.json +635 -0
  177. package/examples/youtube-shorts/src/project.meta +28 -0
  178. package/examples/youtube-shorts/src/project.ts +9 -0
  179. package/examples/youtube-shorts/src/render.ts +12 -0
  180. package/examples/youtube-shorts/src/revideo.d.ts +1 -0
  181. package/examples/youtube-shorts/src/scenes/example.tsx +224 -0
  182. package/examples/youtube-shorts/src/utils.ts +123 -0
  183. package/examples/youtube-shorts/tsconfig.json +9 -0
  184. package/examples/youtube-shorts/vite.config.ts +8 -0
  185. package/package.json +9 -9
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "revideo",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "scripts": {
6
+ "start": "vite",
7
+ "serve": "vite",
8
+ "build": "tsc && vite build",
9
+ "render": "tsc && node dist/render.js"
10
+ },
11
+ "dependencies": {
12
+ "@revideo/core": "0.5.10",
13
+ "@revideo/2d": "0.5.10",
14
+ "@revideo/renderer": "0.5.10",
15
+ "@revideo/vite-plugin": "0.5.10",
16
+ "@revideo/ffmpeg": "0.5.10"
17
+ },
18
+ "devDependencies": {
19
+ "@revideo/ui": "0.5.10",
20
+ "@revideo/cli": "0.5.10",
21
+ "typescript": "5.5.4",
22
+ "vite": "^4.5"
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
@@ -0,0 +1,28 @@
1
+ {
2
+ "version": 0,
3
+ "shared": {
4
+ "background": null,
5
+ "range": [
6
+ 0,
7
+ null
8
+ ],
9
+ "size": {
10
+ "x": 1920,
11
+ "y": 1080
12
+ },
13
+ "audioOffset": 0
14
+ },
15
+ "preview": {
16
+ "fps": 30,
17
+ "resolutionScale": 1
18
+ },
19
+ "rendering": {
20
+ "fps": 30,
21
+ "resolutionScale": 1,
22
+ "colorSpace": "srgb",
23
+ "exporter": {
24
+ "name": "@revideo/core/wasm",
25
+ "options": {}
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,9 @@
1
+ import {makeProject} from '@revideo/core';
2
+
3
+ import './global.css';
4
+
5
+ import example from './scenes/example?scene';
6
+
7
+ export default makeProject({
8
+ scenes: [example],
9
+ });
@@ -0,0 +1,15 @@
1
+ import {renderVideo} from '@revideo/renderer';
2
+
3
+ async function render() {
4
+ console.log('Rendering video...');
5
+
6
+ // This is the main function that renders the video
7
+ const file = await renderVideo({
8
+ projectFile: './src/project.ts',
9
+ settings: { logProgress: true }
10
+ });
11
+
12
+ console.log(`Rendered video to ${file}`);
13
+ }
14
+
15
+ render();
@@ -0,0 +1 @@
1
+ /// <reference types="@revideo/core/project" />
@@ -0,0 +1,5 @@
1
+ {
2
+ "version": 0,
3
+ "timeEvents": [],
4
+ "seed": 2330707904
5
+ }
@@ -0,0 +1,44 @@
1
+ import {Video, Txt, makeScene2D} from '@revideo/2d';
2
+ import {
3
+ createRef,
4
+ Reference,
5
+ useScene, chain,
6
+ waitFor,
7
+ } from '@revideo/core';
8
+
9
+ export default makeScene2D(function* (view) {
10
+ const nodesObj = useScene().variables.get("nodes", {})() as Record<string, any>;
11
+ const nodes = new Map(Object.entries(nodesObj));
12
+
13
+ yield view.add(
14
+ <Video
15
+ src="https://revideo-example-assets.s3.amazonaws.com/stars.mp4"
16
+ size={"100%"}
17
+ key={'data-video'}
18
+ play={true}
19
+ />
20
+ );
21
+
22
+ const refs: Array<Reference<Txt>> = [];
23
+ if (nodes.size > 0) {
24
+ for (const [key, node] of nodes) {
25
+ const ref = createRef<Txt>();
26
+ yield view.add(
27
+ <Txt
28
+ key={key}
29
+ text={node.text}
30
+ fontSize={100}
31
+ fontWeight={800}
32
+ fontFamily={"Roboto"}
33
+ fill={"white"}
34
+ x={() => node.x}
35
+ y={() => node.y}
36
+ ref={ref}
37
+ />
38
+ )
39
+ refs.push(ref);
40
+ }
41
+ }
42
+
43
+ yield* waitFor(5);
44
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "@revideo/2d/tsconfig.project.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "noEmit": false,
6
+ "outDir": "dist",
7
+ "module": "CommonJS"
8
+ }
9
+ }
@@ -0,0 +1,6 @@
1
+ import {defineConfig} from 'vite';
2
+ import motionCanvas from '@revideo/vite-plugin';
3
+
4
+ export default defineConfig({
5
+ plugins: [motionCanvas()],
6
+ });
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ package-lock.json
@@ -0,0 +1,21 @@
1
+ FROM docker.io/revideo/aws-lambda-base-image:latest
2
+
3
+ COPY ./revideo-project/ ./
4
+
5
+ RUN npm install
6
+
7
+ RUN node node_modules/puppeteer/install.mjs
8
+
9
+ RUN npx tsc && cp dist/lambda.js ./
10
+
11
+ ENV ROLLUP_CACHE=/tmp/rollup_cache
12
+
13
+ RUN npm run build
14
+
15
+ ENV FFMPEG_PATH=/var/task/node_modules/@ffmpeg-installer/linux-x64/ffmpeg
16
+
17
+ ENV HOME=/tmp
18
+
19
+ ENV DONT_WRITE_TO_META_FILES=true
20
+
21
+ CMD ["lambda.handler"]
@@ -0,0 +1,64 @@
1
+ FROM public.ecr.aws/lambda/nodejs:18
2
+
3
+ RUN yum update -y && yum 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
+ libxfixes3
20
+
21
+ RUN yum update -y && yum install -y \
22
+ alsa-lib \
23
+ at-spi2-atk \
24
+ atk \
25
+ cups-libs \
26
+ gtk3 \
27
+ ipa-gothic-fonts \
28
+ libXcomposite \
29
+ libXcursor \
30
+ libXdamage \
31
+ libXext \
32
+ libXi \
33
+ libXrandr \
34
+ libXScrnSaver \
35
+ libXtst \
36
+ pango \
37
+ xorg-x11-fonts-100dpi \
38
+ xorg-x11-fonts-75dpi \
39
+ xorg-x11-fonts-cyrillic \
40
+ xorg-x11-fonts-misc \
41
+ xorg-x11-fonts-Type1 \
42
+ xorg-x11-utils \
43
+ nss \
44
+ libX11 \
45
+ GConf2 \
46
+ dbus-glib \
47
+ dbus-libs \
48
+ libXrender \
49
+ libxcb \
50
+ libdrm \
51
+ libxshmfence \
52
+ mesa-libgbm \
53
+ libatk \
54
+ libxkbcommon
55
+
56
+ RUN curl -L https://github.com/eugeneware/ffmpeg-static/releases/download/b6.0/ffprobe-linux-x64 -o ffprobe-linux-x64
57
+
58
+ RUN chmod +x ffprobe-linux-x64
59
+
60
+ RUN mv ffprobe-linux-x64 ffprobe
61
+
62
+ RUN mv ffprobe /usr/local/bin/
63
+
64
+ ENV FFPROBE_PATH=ffprobe
@@ -0,0 +1,197 @@
1
+ # Parallelized Rendering with AWS Lambda
2
+
3
+ This example project demonstrates how you can perform parallelized rendering of Revideo projects using AWS Lambda and comes with docker images for Revideo (specifically for running Revideo on Lambda).
4
+
5
+ The code inside of `/revideo-project` has the same structure as any revideo project. Additionally, it contains the `src/lambda.ts` file which defines a handler for a lambda function. Within this repository, we also have two Docker images:
6
+
7
+ - `Dockerfile.base` is a base image that sets up the environment required to run Revideo on Lambda. A built image can already be found at `docker.io/revideo/aws-lambda-base-image:latest`, the Dockerfile is only included for reference.
8
+ - `Dockerfile` uses `Dockerfile.base` as a base image and builds the Revideo project inside of `revideo-project`. You should build this image yourself to use it with AWS Lambda.
9
+
10
+
11
+ ## How it works
12
+
13
+ The handler that gets executed when the lambda function is invoked can be found in `./src/lambda.ts`. This handler does the following:
14
+
15
+ - when the handler receives a request with a `"jobType": "fullRender"` argument, it invokes itself `numWorkers` of times with `"jobType": "partialRender"`.
16
+ - each lambda function called with `"jobType": "partialRender"` will call `renderPartialVideo` to render a part of the video. The result will be uploaded to an AWS bucket.
17
+ - the main lambda function will await all partial render jobs and then merge their results. The resulting full video gets uploaded to the same AWS bucket.
18
+
19
+ ## Getting Started
20
+
21
+ To deploy the example project to AWS Lambda, clone this repository and make sure that you have the AWS CLI and Docker installed. Then, follow these steps:
22
+
23
+ ### Create a public AWS bucket
24
+
25
+ First, create a bucket:
26
+
27
+ ```
28
+ aws s3api create-bucket --bucket your-bucket-name --region your-region
29
+ ```
30
+
31
+ Now apply a bucket policy that makes the bucket public and lets your user write to it:
32
+
33
+ ```
34
+ aws s3api put-bucket-policy --bucket your-bucket-name --policy file://policy.json
35
+ ```
36
+
37
+ Here, `policy.json` refers to a file that contains the configuration below - note that `<your-user-arn>` should be replaced with the ARN of your user:
38
+
39
+ ```json
40
+ {
41
+ "Version": "2012-10-17",
42
+ "Statement": [
43
+ {
44
+ "Sid": "AddPerm",
45
+ "Effect": "Allow",
46
+ "Principal": "*",
47
+ "Action": "s3:GetObject",
48
+ "Resource": "arn:aws:s3:::your-bucket-name/*"
49
+ },
50
+ {
51
+ "Sid": "AllowUserToWriteObjects",
52
+ "Effect": "Allow",
53
+ "Principal": {
54
+ "AWS": "<your-user-arn>"
55
+ },
56
+ "Action": "s3:PutObject",
57
+ "Resource": "arn:aws:s3:::your-bucket-name/*"
58
+ }
59
+
60
+ ]
61
+ }
62
+ ```
63
+
64
+ ### Configure an IAM role for your user
65
+
66
+ You want to give the user the permission to write to buckets, invoke lambda functions and create logs in CloudWatch (in order to monitor the logs of your lambda function).
67
+
68
+ To do so, create a role with the following policy attached:
69
+
70
+ ```json
71
+ {
72
+ "Version": "2012-10-17",
73
+ "Statement": [
74
+ {
75
+ "Sid": "0",
76
+ "Effect": "Allow",
77
+ "Action": [
78
+ "s3:ListAllMyBuckets"
79
+ ],
80
+ "Resource": [
81
+ "*"
82
+ ]
83
+ },
84
+ {
85
+ "Sid": "1",
86
+ "Effect": "Allow",
87
+ "Action": [
88
+ "s3:CreateBucket",
89
+ "s3:ListBucket",
90
+ "s3:PutBucketAcl",
91
+ "s3:GetObject",
92
+ "s3:DeleteObject",
93
+ "s3:PutObjectAcl",
94
+ "s3:PutObject",
95
+ "s3:GetBucketLocation"
96
+ ],
97
+ "Resource": [
98
+ "arn:aws:s3:::*"
99
+ ]
100
+ },
101
+ {
102
+ "Sid": "2",
103
+ "Effect": "Allow",
104
+ "Action": [
105
+ "lambda:InvokeFunction"
106
+ ],
107
+ "Resource": [
108
+ "arn:aws:lambda:*:*:function:*"
109
+ ]
110
+ },
111
+ {
112
+ "Sid": "3",
113
+ "Effect": "Allow",
114
+ "Action": [
115
+ "logs:CreateLogGroup"
116
+ ],
117
+ "Resource": [
118
+ "*"
119
+ ]
120
+ },
121
+ {
122
+ "Sid": "4",
123
+ "Effect": "Allow",
124
+ "Action": [
125
+ "logs:CreateLogStream",
126
+ "logs:PutLogEvents"
127
+ ],
128
+ "Resource": [
129
+ "*"
130
+ ]
131
+ }
132
+ ]
133
+ }
134
+ ```
135
+
136
+ Attach this role to the user that you have previously given the permission to write to your bucket.
137
+
138
+ ### Build the docker image and push it to ECR
139
+
140
+ We want to upload our docker image to Amazon's container registry so that it is close to our lambda function. To create an ECR repository, run the following command:
141
+
142
+ ```
143
+ aws ecr create-repository --repository-name my-revideo-project --region us-east-1
144
+ ```
145
+
146
+ This will give you the URI of your ECR repository `<your-ecr-uri>`, which looks something like `0123456789.dkr.ecr.us-east-1.amazonaws.com/your-repo-name`.
147
+
148
+ Now you can build the docker image. To do so, head to the folder in which our `Dockerfile` is present and run:
149
+
150
+ ```
151
+ docker buildx build --progress=plain --platform linux/amd64 -t my-revideo-project:latest .
152
+ ```
153
+
154
+ Now tag the image to upload it to ECR:
155
+
156
+ ```
157
+ docker tag my-revideo-project:latest <your-ecr-uri>:latest
158
+ ```
159
+
160
+ Finally, push the image to your repository:
161
+ ```
162
+ docker push <your-ecr-uri>:latest
163
+ ```
164
+
165
+ ### Create a Lambda function from your docker image
166
+
167
+ Finally, create a lambda function from your docker image:
168
+
169
+ ```
170
+ aws lambda create-function \
171
+ --function-name my-revideo-render-function \
172
+ --package-type Image \
173
+ --code ImageUri=<your-ecr-uri>:latest \
174
+ --role <your-lambda-role-arn> \
175
+ --timeout 600 \
176
+ --memory-size 4096 \
177
+ --environment Variables={REVIDEO_BUCKET_NAME=your-bucket-name}
178
+ ```
179
+
180
+ You should get a response in your terminal indicating that your function is being created.
181
+
182
+ ### Test your function
183
+
184
+ To test your function, head to the Lambda tab in the AWS console. Now create a test event with the following arguments and use it to invoke your function:
185
+
186
+ ```
187
+ {
188
+ "jobId": "12345",
189
+ "numWorkers": 25,
190
+ "jobType": "fullRender",
191
+ "variables": {"message": "Hello from Revideo!"}
192
+ }
193
+ ```
194
+
195
+ The function should run and return a url to the rendered video inside your bucket.
196
+
197
+ **Note: The first time after an image is uploaded to ECR, the function may take longer to execute, but after the first time, executions are faster, even when you have long breaks between executions. You can read more about why this happens [here](https://brooker.co.za/blog/2023/05/23/snapshot-loading.html).**
@@ -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]