@remotion/cloudrun 4.1.0-alpha2 → 4.1.0-alpha4

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 (41) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/dist/api/check-if-service-exists.js +0 -1
  3. package/dist/api/get-service-info.js +7 -9
  4. package/dist/api/get-services.js +13 -13
  5. package/dist/api/helpers/parse-service-name.d.ts +8 -0
  6. package/dist/api/helpers/parse-service-name.js +24 -0
  7. package/dist/api/render-media-on-cloudrun.d.ts +9 -1
  8. package/dist/api/render-media-on-cloudrun.js +25 -16
  9. package/dist/api/render-still-on-cloudrun.d.ts +3 -1
  10. package/dist/api/render-still-on-cloudrun.js +8 -5
  11. package/dist/api/test/service-names.test.d.ts +1 -0
  12. package/dist/api/test/service-names.test.js +28 -0
  13. package/dist/cli/commands/render/index.d.ts +1 -1
  14. package/dist/cli/commands/render/index.js +152 -26
  15. package/dist/cli/commands/still.d.ts +2 -0
  16. package/dist/cli/commands/still.js +124 -0
  17. package/dist/cli/help.js +5 -1
  18. package/dist/cli/index.js +4 -0
  19. package/dist/cli/log.d.ts +0 -1
  20. package/dist/functions/helpers/get-composition-from-body.d.ts +1 -0
  21. package/dist/functions/helpers/get-composition-from-body.js +13 -0
  22. package/dist/functions/helpers/io.d.ts +11 -0
  23. package/dist/functions/helpers/io.js +17 -0
  24. package/dist/functions/helpers/payloads.d.ts +277 -0
  25. package/dist/functions/helpers/payloads.js +96 -0
  26. package/dist/functions/index.d.ts +3 -0
  27. package/dist/functions/index.js +39 -0
  28. package/dist/functions/render-media-single-thread.d.ts +3 -0
  29. package/dist/functions/render-media-single-thread.js +96 -0
  30. package/dist/functions/render-still-single-thread.d.ts +3 -0
  31. package/dist/functions/render-still-single-thread.js +76 -0
  32. package/dist/shared/generate-service-name.js +2 -2
  33. package/dist/shared/service-version-string.js +1 -1
  34. package/package.json +9 -12
  35. package/readme.md +2 -305
  36. package/tsconfig.tsbuildinfo +1 -1
  37. package/readmeImages/createSA.png +0 -0
  38. package/readmeImages/downloadEnv.jpg +0 -0
  39. package/readmeImages/downloadEnvFolder.png +0 -0
  40. package/readmeImages/saRole.png +0 -0
  41. package/readmeImages/selectCloudShell.jpg +0 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderMediaSingleThread = void 0;
4
+ const storage_1 = require("@google-cloud/storage");
5
+ const renderer_1 = require("@remotion/renderer");
6
+ const random_hash_1 = require("../shared/random-hash");
7
+ const get_composition_from_body_1 = require("./helpers/get-composition-from-body");
8
+ const renderMediaSingleThread = async (body, res) => {
9
+ var _a, _b, _c, _d, _e, _f;
10
+ if (body.type !== 'media') {
11
+ throw new Error('expected type media');
12
+ }
13
+ const composition = await (0, get_composition_from_body_1.getCompositionFromBody)(body.serveUrl, body.composition);
14
+ const tempFilePath = '/tmp/output.mp4';
15
+ const renderId = (0, random_hash_1.randomHash)({ randomInTests: true });
16
+ let previousProgress = 2;
17
+ const onProgress = ({ progress }) => {
18
+ if (previousProgress !== progress) {
19
+ res.write(JSON.stringify({ onProgress: progress }));
20
+ previousProgress = progress;
21
+ }
22
+ };
23
+ res.writeHead(200, { 'Content-Type': 'text/html' });
24
+ const actualChromiumOptions = {
25
+ ...body.chromiumOptions,
26
+ // Override the `null` value, which might come from CLI with swANGLE
27
+ gl: (_b = (_a = body.chromiumOptions) === null || _a === void 0 ? void 0 : _a.gl) !== null && _b !== void 0 ? _b : 'swangle',
28
+ };
29
+ await renderer_1.RenderInternals.internalRenderMedia({
30
+ composition: {
31
+ ...composition,
32
+ height: (_c = body.forceHeight) !== null && _c !== void 0 ? _c : composition.height,
33
+ width: (_d = body.forceWidth) !== null && _d !== void 0 ? _d : composition.width,
34
+ },
35
+ serveUrl: body.serveUrl,
36
+ codec: body.codec,
37
+ outputLocation: tempFilePath,
38
+ inputProps: body.inputProps,
39
+ jpegQuality: body.jpegQuality,
40
+ audioCodec: body.audioCodec,
41
+ audioBitrate: body.audioBitrate,
42
+ videoBitrate: body.videoBitrate,
43
+ crf: body.crf,
44
+ pixelFormat: body.pixelFormat,
45
+ imageFormat: body.imageFormat,
46
+ scale: body.scale,
47
+ proResProfile: (_e = body.proResProfile) !== null && _e !== void 0 ? _e : undefined,
48
+ everyNthFrame: body.everyNthFrame,
49
+ numberOfGifLoops: body.numberOfGifLoops,
50
+ onProgress,
51
+ frameRange: body.frameRange,
52
+ envVariables: body.envVariables,
53
+ chromiumOptions: actualChromiumOptions,
54
+ muted: body.muted,
55
+ logLevel: body.logLevel,
56
+ browserExecutable: null,
57
+ timeoutInMilliseconds: body.delayRenderTimeoutInMilliseconds,
58
+ cancelSignal: undefined,
59
+ concurrency: body.concurrency,
60
+ disallowParallelEncoding: false,
61
+ enforceAudioTrack: body.enforceAudioTrack,
62
+ ffmpegOverride: undefined,
63
+ indent: false,
64
+ onBrowserLog: null,
65
+ onCtrlCExit: () => undefined,
66
+ onDownload: () => undefined,
67
+ onStart: () => undefined,
68
+ overwrite: true,
69
+ port: null,
70
+ preferLossless: body.preferLossless,
71
+ puppeteerInstance: undefined,
72
+ server: undefined,
73
+ });
74
+ const storage = new storage_1.Storage();
75
+ const publicUpload = body.privacy === 'public' || !body.privacy;
76
+ const uploadedResponse = await storage
77
+ .bucket(body.outputBucket)
78
+ .upload(tempFilePath, {
79
+ destination: `renders/${renderId}/${(_f = body.outName) !== null && _f !== void 0 ? _f : 'out.mp4'}`,
80
+ predefinedAcl: publicUpload ? 'publicRead' : 'projectPrivate',
81
+ });
82
+ const uploadedFile = uploadedResponse[0];
83
+ const renderMetadata = await uploadedFile.getMetadata();
84
+ const responseData = {
85
+ status: 'success',
86
+ publicUrl: publicUpload ? uploadedFile.publicUrl() : null,
87
+ cloudStorageUri: uploadedFile.cloudStorageURI.href,
88
+ size: renderMetadata[0].size,
89
+ bucketName: body.outputBucket,
90
+ renderId,
91
+ privacy: publicUpload ? 'public-read' : 'project-private',
92
+ };
93
+ renderer_1.RenderInternals.Log.info('Render Completed:', responseData);
94
+ res.end(JSON.stringify({ response: responseData }));
95
+ };
96
+ exports.renderMediaSingleThread = renderMediaSingleThread;
@@ -0,0 +1,3 @@
1
+ import type * as ff from '@google-cloud/functions-framework';
2
+ import type { CloudRunPayloadType } from './helpers/payloads';
3
+ export declare const renderStillSingleThread: (body: CloudRunPayloadType, res: ff.Response) => Promise<void>;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderStillSingleThread = void 0;
4
+ const storage_1 = require("@google-cloud/storage");
5
+ const renderer_1 = require("@remotion/renderer");
6
+ const log_1 = require("../cli/log");
7
+ const random_hash_1 = require("../shared/random-hash");
8
+ const get_composition_from_body_1 = require("./helpers/get-composition-from-body");
9
+ const renderStillSingleThread = async (body, res) => {
10
+ var _a, _b, _c, _d, _e, _f;
11
+ if (body.type !== 'still') {
12
+ throw new Error('expected type still');
13
+ }
14
+ log_1.Log.verbose('Rendering still frame', body);
15
+ const composition = await (0, get_composition_from_body_1.getCompositionFromBody)(body.serveUrl, body.composition);
16
+ log_1.Log.verbose('Composition loaded', composition);
17
+ const tempFilePath = '/tmp/still.png';
18
+ const renderId = (0, random_hash_1.randomHash)({ randomInTests: true });
19
+ const actualChromiumOptions = {
20
+ ...body.chromiumOptions,
21
+ // Override the `null` value, which might come from CLI with swANGLE
22
+ gl: (_b = (_a = body.chromiumOptions) === null || _a === void 0 ? void 0 : _a.gl) !== null && _b !== void 0 ? _b : 'swangle',
23
+ };
24
+ await renderer_1.RenderInternals.internalRenderStill({
25
+ composition: {
26
+ ...composition,
27
+ height: (_c = body.forceHeight) !== null && _c !== void 0 ? _c : composition.height,
28
+ width: (_d = body.forceWidth) !== null && _d !== void 0 ? _d : composition.width,
29
+ },
30
+ serveUrl: body.serveUrl,
31
+ output: tempFilePath,
32
+ inputProps: body.inputProps,
33
+ jpegQuality: (_e = body.jpegQuality) !== null && _e !== void 0 ? _e : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
34
+ imageFormat: body.imageFormat,
35
+ scale: body.scale,
36
+ envVariables: body.envVariables,
37
+ chromiumOptions: actualChromiumOptions,
38
+ frame: body.frame,
39
+ logLevel: body.logLevel,
40
+ browserExecutable: null,
41
+ cancelSignal: null,
42
+ indent: false,
43
+ timeoutInMilliseconds: body.delayRenderTimeoutInMilliseconds,
44
+ onBrowserLog: null,
45
+ onDownload: null,
46
+ overwrite: true,
47
+ port: null,
48
+ puppeteerInstance: null,
49
+ server: undefined,
50
+ });
51
+ log_1.Log.info('Still rendered');
52
+ const storage = new storage_1.Storage();
53
+ const publicUpload = body.privacy === 'public' || !body.privacy;
54
+ const uploadedResponse = await storage
55
+ .bucket(body.outputBucket)
56
+ .upload(tempFilePath, {
57
+ destination: `renders/${renderId}/${(_f = body.outName) !== null && _f !== void 0 ? _f : 'out.png'}`,
58
+ predefinedAcl: publicUpload ? 'publicRead' : 'projectPrivate',
59
+ });
60
+ log_1.Log.info('Still uploaded');
61
+ const uploadedFile = uploadedResponse[0];
62
+ const renderMetadata = await uploadedFile.getMetadata();
63
+ const responseData = {
64
+ publicUrl: uploadedFile.publicUrl(),
65
+ cloudStorageUri: uploadedFile.cloudStorageURI.href,
66
+ size: renderMetadata[0].size,
67
+ bucketName: body.outputBucket,
68
+ renderId,
69
+ status: 'success',
70
+ privacy: publicUpload ? 'public-read' : 'project-private',
71
+ };
72
+ renderer_1.RenderInternals.Log.info('Render Completed:', responseData);
73
+ const jsonContent = JSON.stringify(responseData);
74
+ res.end(jsonContent);
75
+ };
76
+ exports.renderStillSingleThread = renderStillSingleThread;
@@ -14,7 +14,7 @@ const generateServiceName = ({ memoryLimit, cpuLimit, timeoutSeconds, }) => {
14
14
  (0, service_version_string_1.serviceVersionString)(),
15
15
  `mem${sanitisedMem}`,
16
16
  `cpu${sanitisedCPU}`,
17
- `t-${String(timeoutSeconds)}`,
18
- ].join('--');
17
+ `t${String(timeoutSeconds)}`,
18
+ ].join('-');
19
19
  };
20
20
  exports.generateServiceName = generateServiceName;
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serviceVersionString = void 0;
4
4
  const version_1 = require("remotion/version");
5
5
  const serviceVersionString = () => {
6
- return version_1.VERSION.replace(/\./g, '-').replace(/\+/g, '-').substring(0, 10);
6
+ return version_1.VERSION.replace(/\./g, '-').replace(/\+/g, '-');
7
7
  };
8
8
  exports.serviceVersionString = serviceVersionString;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remotion/cloudrun",
3
- "version": "4.1.0-alpha2",
3
+ "version": "4.1.0-alpha4",
4
4
  "description": "GCP Cloud Run alternative to lambda rendering",
5
5
  "main": "dist/index.js",
6
6
  "dependencies": {
@@ -11,22 +11,22 @@
11
11
  "@google-cloud/resource-manager": "^4.3.0",
12
12
  "google-auth-library": "^8.7.0",
13
13
  "zod": "^3.21.4",
14
- "@remotion/bundler": "4.1.0-alpha2",
15
- "@remotion/cli": "4.1.0-alpha2",
16
- "@remotion/renderer": "4.1.0-alpha2",
17
- "remotion": "4.1.0-alpha2"
14
+ "@remotion/bundler": "4.1.0-alpha4",
15
+ "@remotion/cli": "4.1.0-alpha4",
16
+ "remotion": "4.1.0-alpha4",
17
+ "@remotion/renderer": "4.1.0-alpha4"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@jonny/eslint-config": "3.0.266",
21
21
  "@types/node": "^18.11.2",
22
22
  "@types/minimist": "1.2.2",
23
- "eslint": "8.25.0",
23
+ "eslint": "8.42.0",
24
24
  "prettier": "^2.7.1",
25
25
  "prettier-plugin-organize-imports": "^3.2.2",
26
26
  "ts-node": "^10.8.0",
27
27
  "typescript": "4.7.2",
28
28
  "vitest": "0.24.3",
29
- "@remotion/compositor-linux-x64-gnu": "4.1.0-alpha2"
29
+ "@remotion/compositor-linux-x64-gnu": "4.1.0-alpha4"
30
30
  },
31
31
  "exports": {
32
32
  "./package.json": "./package.json",
@@ -45,15 +45,12 @@
45
45
  ]
46
46
  }
47
47
  },
48
- "publishConfig": {
49
- "access": "public"
50
- },
51
48
  "scripts": {
52
49
  "build": "tsc -d && cp src/shared/sa-permissions.json dist/shared/sa-permissions.json && pnpm run buildContainer && pnpm run tarInstaller",
53
50
  "buildContainer": "ts-node src/admin/bundle-renderLogic.ts",
54
51
  "tarInstaller": "ts-node src/admin/bundle-installer.ts",
55
- "start": "functions-framework --target=TypescriptFunction",
56
52
  "watch": "tsc -w",
57
- "lint": "eslint src --ext ts,tsx"
53
+ "lint": "eslint src --ext ts,tsx",
54
+ "test": "vitest --run"
58
55
  }
59
56
  }
package/readme.md CHANGED
@@ -1,306 +1,3 @@
1
- from the root, `pnpm i && pnpm build` will trigger a build command for all packages. For the GCP package, this will bundle the required code into `cloudrun/container`.
1
+ # @remotion/cloudrun
2
2
 
3
- The /container folder contains a package.json that lists functions-framework as a dependency, and a Dockerfile that will build the container. Functions-framework is a nodejs framework that allows you to run nodejs code in a containerized environment.
4
-
5
- This can be built and deployed to Cloud Run. Cloud Run is a serverless container platform that allows you to run containers in a managed environment.
6
-
7
- ## Deploying new artifact repo in GCP for new Remotion versions
8
-
9
- Public artifact registry that contains the container images
10
- us-docker.pkg.dev/remotion-dev/cloud-run/render
11
- Image is tagged with the same semver as the remotion packages
12
- us-docker.pkg.dev/remotion-dev/cloud-run/render:3.3.36-alpha
13
- Part of the CI/CD pipeline should be to push a new container image to the artifact registry, with the right version:
14
- `gcloud builds submit --tag us-docker.pkg.dev/remotion-dev/cloud-run/render:${version}`
15
-
16
- # How to use the GCP CLI commands
17
-
18
- ## 1. Create a project in the Google Cloud Console
19
-
20
- Navigate to the [Manage Resources](https://console.cloud.google.com/cloud-resource-manager?walkthrough_id=resource-manager--create-project&start_index=1#step_index=1) screen in Google Cloud Console.
21
-
22
- - On the Select organization drop-down list at the top of the page, select the organization resource in which you want to create a project. If you are a free trial user, skip this step, as this list does not appear.
23
- - Click Create Project.
24
- - In the New Project window that appears, enter a project name and select a billing account as applicable. A project name can contain only letters, numbers, single quotes, hyphens, spaces, or exclamation points, and must be between 4 and 30 characters.
25
- - Enter the parent organization or folder resource in the Location box. That resource will be the hierarchical parent of the new project. If No organization is an option, you can select it to create your new project as the top level of its own resource hierarchy.
26
- - When you're finished entering new project details, click Create.
27
-
28
- ## 2. Enable billing in the GCP Project
29
-
30
- In order to enable the Cloud Run API, billing must be enabled in this project. Navigate to the [Billing](https://console.cloud.google.com/billing) screen in Google Cloud Console. Follow the on-screen prompts to create a billing account, and then link the new project to this billing account.
31
-
32
- ## 3. Setup Permissions / APIs / Service Account in GCP
33
-
34
- This can be achieved by either following the instructions for using Terraform within GCP Cloud Shell (recommended) or following the instructions for clicking through the GCP Console. The former is the preferred method as it minimises the risk of missing an instruction.
35
-
36
- ### Using Terraform within GCP Cloud Shell:
37
-
38
- _Note, this process does not require an understanding of Terraform._
39
-
40
- **What is Google Cloud Shell?**
41
- Google Cloud Shell is a browser-based command-line interface (CLI) for managing resources and applications hosted on Google Cloud Platform (GCP). It provides a virtual machine with pre-installed command-line tools and utilities, including the Google Cloud SDK and Terraform.
42
-
43
- Google Cloud Shell is fully integrated with GCP, which means that you can access your projects, resources, and services directly from the command line without having to switch between multiple interfaces. Additionally, Cloud Shell offers a persistent disk for storing your data and files, as well as a web-based code editor for editing files and running scripts.
44
-
45
- This means that you can clone a github repo, run a couple of Terraform commands, and have a Remotion ready GCP project in minutes 🚀.
46
-
47
- 1. In the top right hand corner of the screen, click the Activate Cloud Shell icon
48
- <img src="readmeImages/selectCloudShell.jpg" width="200" />
49
- 2. Within the Cloud Shell, type
50
- `git clone https://github.com/UmungoBungo/remotion-gcp-terraform.git remotion-gcp-terraform/`
51
- <!-- ToDo - host this in the official Remotion repo -->
52
- 3. Change directory into the new folder
53
- `cd remotion-gcp-terraform/`
54
- 4. Within the terraform file, there is a variable named project_id. This needs to be set to your newly created Remotion project. Because we are already authenticated with GCP when using the Cloud Shell, we can set this variable using the following command:
55
- `export TF_VAR_project_id=$(gcloud config get-value project)`
56
- 5. As terraform is natively available in Cloud Shell, we can begin using terraform commands without further installation. Run the following command;
57
- `terraform init`
58
- _Explanation: When you run `terraform init`, Terraform will download any required provider plugins and modules and create a .terraform directory in your working directory._
59
- 6. Run the following command;
60
- `terraform plan`
61
- _Explanation: When you run `terraform plan`, Terraform checks your code to see what resources you're trying to create, update or delete, and then shows you what it will do without actually making any changes._
62
- 7. Check the output from the above to ensure you are happy with the changes about to be made to your project. If so, run the following command;
63
- `terraform apply`
64
- _Explanation: When you run `terraform apply`, Terraform deploys the resources as defined in the .tf files._
65
- 8. When the apply is complete, it will output a script to run in the command line. Running this will create a key for the service account and store it on the virtual machine. **Note that these keys need to remain secret.** The command should look similar to the following;
66
- `gcloud iam service-accounts keys create key.json --iam-account=remotion-sa@<project_name>.iam.gserviceaccount.com`
67
- 9. The key file has been generated on the virtual machine. You can now build the .env file that is needed at the root of your Remotion project in order to interact with GCP. Run the following command;
68
- ```
69
- echo "REMOTION_GCP_PRIVATE_KEY=$(jq '.private_key' key.json)" >> .env && \
70
- echo "REMOTION_GCP_CLIENT_EMAIL=$(jq '.client_email' key.json)" >> .env && \
71
- echo "REMOTION_GCP_PROJECT_ID=$(gcloud config get-value project)" >> .env
72
- ```
73
- 10. Download the .env file by clicking the vertical ellipsis, in the top right of the cloud shell window, and selecting Download. Then type .env at the end of the prefilled path, and click DOWNLOAD;
74
- <img src="readmeImages/downloadEnv.jpg" width="350" />
75
-
76
- <img src="readmeImages/downloadEnvFolder.png" width="300" />
77
-
78
- 11. Remove the .env file and key.json from the virtual machine, using this command;
79
- `rm key.json .env`
80
-
81
- 12. Place the .env file you've downloaded into the root of your Remotion project. You may need to rename it from `env.txt`, to `.env`.
82
-
83
- ### Clicking through the console:
84
-
85
- ### 1. Create a new role with permissions required by the service account
86
-
87
- Navigate to the [Role](https://console.cloud.google.com/iam-admin/roles) screen in Google Cloud Console, within IAM & Admin.
88
-
89
- - Select the Cloud project created in the previous step.
90
- - Click + CREATE ROLE in the top menu.
91
- - Under Title, type: `Remotion API Service Account`
92
- - Under Description, type: `Allow the service account to manage necessary resources for Remotion Cloud Run rendering.`
93
- - Under ID, type: `RemotionSA`
94
- - For Role launch stage, select `General Availability`
95
- - Click + Add Permissions, and add the following;
96
- - iam.serviceAccounts.actAs
97
- - run.operations.get
98
- - run.routes.invoke
99
- - run.services.create
100
- - run.services.list
101
- - run.services.update
102
- - storage.buckets.get
103
- - storage.buckets.list
104
- - storage.objects.create
105
- - storage.objects.delete
106
- - storage.objects.list
107
- - run.services.getIamPolicy
108
- - run.services.setIamPolicy
109
- - Click the CREATE button
110
-
111
- #### 1a. Permission reasons
112
-
113
- For information only, here are the reasons for the above permissions
114
-
115
- - iam.serviceAccounts.actAs
116
- - When deploying, act as the default service account, which will grant further permissions required during deployment.
117
- - run.operations.get
118
- - Required during deployment to confirm that deployment was successful.
119
- - run.routes.invoke
120
- - Call the deployed Cloud Run services, in order to perform a render.
121
- - run.services.create
122
- - Deploy new, and edit existing, Cloud Run services
123
- - run.services.list
124
- - Get a list of existing Cloud Run services, to ensure no unintended overwriting.
125
- - run.services.update
126
- - Update a Cloud Run service, for instance providing it with more Memory or CPU.
127
- - storage.buckets.get
128
- - ToDo...
129
- - storage.buckets.list
130
- - Get a list of existing Cloud Storage resources, to ensure no unintended overwriting of storage buckets.
131
- - storage.objects.create
132
- - Create new objects in storage. This could be bundled sites, or renders, or logs.
133
- - storage.objects.delete
134
- - ToDo...
135
- - storage.objects.list
136
- - ToDo...
137
- - run.services.getIamPolicy
138
- - used to check the existing IAM policy on a service
139
- - run.services.setIamPolicy
140
- - used to set the IAM policy on a service
141
-
142
- ### 2. Create a service account in the Google Cloud Console
143
-
144
- Navigate to the [Service Accounts](https://console.cloud.google.com/projectselector2/iam-admin/serviceaccounts/create) screen in Google Cloud Console, within IAM & Admin.
145
-
146
- - Select the Cloud project created in the previous step.
147
- - Enter a service account name to display in the Google Cloud console.
148
- - The Google Cloud console generates a service account ID based on this name. Edit the ID if necessary. You cannot change the ID later.
149
- - Optional: Enter a description of the service account.
150
- - Click 'Create and continue' and continue to the next step.
151
- - Give the Service Account the role created in the previous step, Remotion API Service Account.
152
- <img src="readmeImages/saRole.png" width="450" />
153
- - Click Done to finish creating the service account.
154
-
155
- ### 3. Save Service Account credentials
156
-
157
- Navigate to the [Service Accounts](https://console.cloud.google.com/iam-admin/serviceaccounts) screen in Google Cloud Console, within IAM & Admin.
158
-
159
- - Select the Cloud project created in the previous step.
160
- - Click on the ellipsis under 'Actions', in the final column, and click 'Manage keys'.
161
- - On the next screen, click ADD KEY, and then Create new key.
162
- - select JSON, and click Create.
163
- - Save the JSON file to your computer, and open it.
164
- - Create/edit a .env file in the root of your Remotion project.
165
- - Create a REMOTION*GCP_CLIENT_EMAIL key, and copy over the client_email value, \_including the quotation marks*.
166
- - Create a REMOTION*GCP_PRIVATE_KEY key, and copy over the private_key value, \_including the quotation marks*.
167
-
168
- ### 5. Set Remotion Project ID in .env
169
-
170
- - Within the previously edited .env file in the root of your Remotion project, create a REMOTION_GCP_PROJECT_ID key, and set the key as the ID from the [Dashboard](https://console.cloud.google.com/home/dashboard), under the Project Info card.
171
-
172
- ### 4. Enable required APIs in the project
173
-
174
- - Enable the Cloud Run API. Navigate to the [Cloud Run API](https://console.cloud.google.com/apis/library/run.googleapis.com) screen in Google Cloud Console, and click ENABLE. Make sure the correct project is selected in the dropdown in the top left. This is required in order to use Cloud Run.
175
-
176
- # Available commands from the CLI:
177
-
178
- This command will deploy a cloud-run service, and return the URL of the service. This cloud run service is what will be invoked to render media.
179
- <br><br>
180
-
181
- ### Command: `npx remotion gcp cloud-run deploy`
182
-
183
- Options:
184
-
185
- - --project-id (required):
186
- - The project-id is the name of the project in which to deploy the service. The ID can be retrieved by navigating to the [Dashboard](https://console.cloud.google.com/home/dashboard) screen in Google Cloud Console, and selecting the project from the drop-down menu in the top left corner. The ID is under Project Info in the top left corner.
187
- - --service-name (required):
188
- - the name of the Cloud Run service to deploy or update. Service names must be 49 characters or less and must be unique per region and project. A service name cannot be changed later and is publicly visible. The service does not need to exist yet. If it does exist, a new revision will be deployed.
189
- - --region: the region of the service
190
- - --overwrite-service (optional, default to false):
191
- - if an existing service is found with the same name, a prompt will come up asking if a new revision should be deployed. If this flag is set to true, the prompt will be skipped and a new revision will be deployed automatically.
192
-
193
- Taking the above into account, a valid command would be:
194
- `npx remotion gcp cloud-run deploy --service-name=cloud-run-render --project-id=new-remotion-project`
195
-
196
- To view the deployed service, navigate to the [Cloud Run](https://console.cloud.google.com/run) screen in Google Cloud Console, and selecting the project from the drop-down menu in the top left corner.
197
-
198
- - The URL is visible at the top of the screen. This is where to send POST requests for rendering.
199
- - Revisions are listed under the revisions tab. You can also manage traffic splitting, and view resource limits for each revision.
200
- - Logs are available under the logs tab. For troubleshooting, it is best to click on the new tab icon to open the Logs Explorer, and then click on Stream Logs in the top right to have a live view of logs.
201
-
202
- <br><br>
203
-
204
- ### Command: `npx remotion gcp sites create`
205
-
206
- Options:
207
-
208
- - tbc
209
-
210
- This command will bundle the site and upload it to a GCP bucket. To view storage buckets in your project, navigate to the [Storage](https://console.cloud.google.com/storage/browser) screen in Google Cloud Console, and select the project from the drop-down menu in the top left corner.
211
-
212
- # Render media on GCP
213
-
214
- This command will render media on the deployed cloud-run service, and return metadata of the rendered file.
215
-
216
- ### Command: `pnpm exec remotion gcp render media <serve-url> <cloud-run-url> <composition-name> --output-bucket=<GCS-bucket-name>`
217
-
218
- ## Manually, making a post request
219
-
220
- Within the Cloud Run service, you can see the URL of the service. Distributed rendering is not yet supported, but rendering a still or media in a single-threaded instance is available.
221
-
222
- To render media, send a POST request to the URL with the following body:
223
-
224
- - type: the type of render. For media, this should be set to `media`.
225
- - composition: the name of the composition to render. This must be available in the bundle that has been deployed to GCP.
226
- - serveUrl: the URL of the site that has been deployed to GCP.
227
- - inputProps: the props to pass to the composition.
228
- - outputBucket: bucket for the output to be uploaded to. The bucket must exist, and the service account running the service must have access to the bucket.
229
- - outputFile: The path and filename to upload the output to.
230
-
231
- ```
232
- {
233
- "type": "media",
234
- "composition": "HelloWorld",
235
- "serveUrl": "https://storage.googleapis.com/remotioncloudrun-n8x4pc7dz3/sites/e97ngid3n3/index.html",
236
- "codec": "h264",
237
- "inputProps": {
238
- "titleText": "Welcome to Remotion",
239
- "titleColor": "black"
240
- },
241
- "outputBucket": "remotionlambda-test",
242
- "outputFile": "outFolder/mediaOutput.mp4"
243
- }
244
- ```
245
-
246
- # Render still on GCP
247
-
248
- This command will render media on the deployed cloud-run service, and return metadata of the rendered file.
249
-
250
- ### Command: `pnpm exec remotion gcp render still <serve-url> <cloud-run-url> <composition-name> --output-bucket=<GCS-bucket-name>`
251
-
252
- ## Manually, making a post request
253
-
254
- To render a still, send a POST request to the URL with the following body:
255
-
256
- - type: the type of render. For a still, this should be set to `still`.
257
- - composition: the name of the composition to render. This must be available in the bundle that has been deployed to GCP.
258
- - serveUrl: the URL of the site that has been deployed to GCP.
259
- - inputProps: the props to pass to the composition.
260
- - outputBucket: bucket for the output to be uploaded to. The bucket must exist, and the service account running the service must have access to the bucket.
261
- - outputFile: The path and filename to upload the output to.
262
-
263
- ```
264
- {
265
- "type": "still",
266
- "composition": "StillRender",
267
- "serveUrl": "https://storage.googleapis.com/remotioncloudrun-n8x4pc7dz3/sites/e97ngid3n3/index.html",
268
- "inputProps": {
269
- "text": "Created on Cloud Run™️"
270
- },
271
- "outputBucket": "remotionlambda-test",
272
- "outputFile": "outFolder/stillOutput.png"
273
- }
274
- ```
275
-
276
- ## Using the CLI command, WIP
277
-
278
- - 🟩 Render Media is largely finished
279
- - 🟩 Address comments within
280
- - 🟩 Render Still command written
281
- - 🟩 Address comments within
282
- - 🟩 Cloud Run render only ever puts the output in a bucket, not available for download.
283
- <br><br><br><br>
284
-
285
- # To Do
286
-
287
- ### deploy cloud-run command
288
-
289
- - add cpu and memory limit arguments
290
- - returning error from deployNewCloudRun - typed as any, can I get a type from the protos?
291
- - sprinkle quietFlagProvided() throughout
292
- - when deploying a cloud run instance, should include the remotion version in the revision name
293
- - add new service account as runner of the service, so the permissions can stay tight.
294
- - allow outputBucket and outputFile to be optional. After that, update readme with details.
295
- - add LS, RM, RMALL subcommands
296
-
297
- ### create sites command
298
-
299
- - sprinkle quietFlagProvided() throughout
300
- - time for uploading to GCP Storage Bucket is always 0ms
301
- - add LS, RM, RMALL subcommands
302
-
303
- ### Render command
304
-
305
- - Create API that just makes a post request to Cloud Run, to perform render
306
- - Use lambda one for inspiration
3
+ This package provides Node.JS APIs and a CLI for rendering Remotion videos on GCP Cloud Run. See https://remotion.dev/docs/cloudrun for documentation.