@remotion/cloudrun 4.1.0-alpha2 → 4.1.0-alpha3

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 (35) hide show
  1. package/dist/api/get-service-info.js +7 -9
  2. package/dist/api/get-services.js +13 -13
  3. package/dist/api/helpers/parse-service-name.d.ts +8 -0
  4. package/dist/api/helpers/parse-service-name.js +24 -0
  5. package/dist/api/test/service-names.test.d.ts +1 -0
  6. package/dist/api/test/service-names.test.js +28 -0
  7. package/dist/cli/commands/render/index.d.ts +1 -1
  8. package/dist/cli/commands/render/index.js +146 -26
  9. package/dist/cli/commands/still.d.ts +2 -0
  10. package/dist/cli/commands/still.js +123 -0
  11. package/dist/cli/help.js +5 -1
  12. package/dist/cli/index.js +4 -0
  13. package/dist/cli/log.d.ts +3 -3
  14. package/dist/functions/helpers/get-composition-from-body.d.ts +1 -0
  15. package/dist/functions/helpers/get-composition-from-body.js +13 -0
  16. package/dist/functions/helpers/io.d.ts +11 -0
  17. package/dist/functions/helpers/io.js +17 -0
  18. package/dist/functions/helpers/payloads.d.ts +262 -0
  19. package/dist/functions/helpers/payloads.js +91 -0
  20. package/dist/functions/index.d.ts +3 -0
  21. package/dist/functions/index.js +38 -0
  22. package/dist/functions/render-media-single-thread.d.ts +3 -0
  23. package/dist/functions/render-media-single-thread.js +79 -0
  24. package/dist/functions/render-still-single-thread.d.ts +3 -0
  25. package/dist/functions/render-still-single-thread.js +66 -0
  26. package/dist/shared/generate-service-name.js +2 -2
  27. package/dist/shared/service-version-string.js +1 -1
  28. package/package.json +8 -10
  29. package/readme.md +2 -305
  30. package/tsconfig.tsbuildinfo +1 -1
  31. package/readmeImages/createSA.png +0 -0
  32. package/readmeImages/downloadEnv.jpg +0 -0
  33. package/readmeImages/downloadEnvFolder.png +0 -0
  34. package/readmeImages/saRole.png +0 -0
  35. package/readmeImages/selectCloudShell.jpg +0 -0
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getServiceInfo = void 0;
4
- const constants_1 = require("../shared/constants");
5
4
  const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
5
+ const parse_service_name_1 = require("./helpers/parse-service-name");
6
6
  /**
7
7
  * @description Given a region and service name, returns information about the service such as version, memory limit and timeout.
8
8
  * @see [Documentation](https://remotion.dev/docs/cloudrun/getserviceinfo)
@@ -11,7 +11,7 @@ const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
11
11
  * @returns {Promise<ServiceInfo[]>} An array with the objects containing information about the deployed services.
12
12
  */
13
13
  const getServiceInfo = async ({ region, serviceName, }) => {
14
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
15
15
  const cloudRunClient = (0, get_cloud_run_client_1.getCloudRunClient)();
16
16
  const [service] = await cloudRunClient.getService({
17
17
  name: `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${region}/services/${serviceName}`,
@@ -19,15 +19,13 @@ const getServiceInfo = async ({ region, serviceName, }) => {
19
19
  if (!service) {
20
20
  throw new Error(`Service ${serviceName} not found`);
21
21
  }
22
- const parent = `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${region}`;
23
- const deployedRegion = (_a = service.name) === null || _a === void 0 ? void 0 : _a.split('/')[3];
24
- const deployedServiceName = (_b = service.name) === null || _b === void 0 ? void 0 : _b.replace(parent + '/services/', '');
22
+ const { region: deployedRegion, remotionVersion, serviceName: deployedServiceName, } = (0, parse_service_name_1.parseServiceName)(service.name, region);
25
23
  return {
26
24
  serviceName: deployedServiceName,
27
- timeoutInSeconds: (_d = (_c = service.template) === null || _c === void 0 ? void 0 : _c.timeout) === null || _d === void 0 ? void 0 : _d.seconds,
28
- memoryLimit: (_h = (_g = (_f = (_e = service.template) === null || _e === void 0 ? void 0 : _e.containers) === null || _f === void 0 ? void 0 : _f[0].resources) === null || _g === void 0 ? void 0 : _g.limits) === null || _h === void 0 ? void 0 : _h.memory,
29
- cpuLimit: (_m = (_l = (_k = (_j = service.template) === null || _j === void 0 ? void 0 : _j.containers) === null || _k === void 0 ? void 0 : _k[0].resources) === null || _l === void 0 ? void 0 : _l.limits) === null || _m === void 0 ? void 0 : _m.cpu,
30
- remotionVersion: (_o = service.name) === null || _o === void 0 ? void 0 : _o.replace(parent + '/services/' + constants_1.RENDER_SERVICE_PREFIX + '--', '').split('--')[0].replace(/-/g, '.'),
25
+ timeoutInSeconds: (_b = (_a = service.template) === null || _a === void 0 ? void 0 : _a.timeout) === null || _b === void 0 ? void 0 : _b.seconds,
26
+ memoryLimit: (_f = (_e = (_d = (_c = service.template) === null || _c === void 0 ? void 0 : _c.containers) === null || _d === void 0 ? void 0 : _d[0].resources) === null || _e === void 0 ? void 0 : _e.limits) === null || _f === void 0 ? void 0 : _f.memory,
27
+ cpuLimit: (_k = (_j = (_h = (_g = service.template) === null || _g === void 0 ? void 0 : _g.containers) === null || _h === void 0 ? void 0 : _h[0].resources) === null || _j === void 0 ? void 0 : _j.limits) === null || _k === void 0 ? void 0 : _k.cpu,
28
+ remotionVersion,
31
29
  uri: service.uri,
32
30
  region: deployedRegion,
33
31
  consoleUrl: `https://console.cloud.google.com/run/detail/${deployedRegion}/${deployedServiceName}/logs`,
@@ -4,6 +4,7 @@ exports.getServices = void 0;
4
4
  const constants_1 = require("../shared/constants");
5
5
  const service_version_string_1 = require("../shared/service-version-string");
6
6
  const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
7
+ const parse_service_name_1 = require("./helpers/parse-service-name");
7
8
  /**
8
9
  * @description Lists Remotion Cloud Run render services deployed to GCP Cloud Run.
9
10
  * @see [Documentation](https://remotion.dev/docs/cloudrun/getservices)
@@ -13,7 +14,7 @@ const get_cloud_run_client_1 = require("./helpers/get-cloud-run-client");
13
14
  */
14
15
  const getServices = async (params) => {
15
16
  const cloudRunClient = (0, get_cloud_run_client_1.getCloudRunClient)();
16
- const parent = `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${params.region}`;
17
+ const parent = (0, parse_service_name_1.getGcpParent)(params.region);
17
18
  const [services] = await cloudRunClient.listServices({
18
19
  parent,
19
20
  });
@@ -21,28 +22,27 @@ const getServices = async (params) => {
21
22
  if (params.compatibleOnly) {
22
23
  remotionServices = services.filter((s) => {
23
24
  var _a;
24
- return (_a = s.name) === null || _a === void 0 ? void 0 : _a.startsWith(`${parent}/services/${constants_1.RENDER_SERVICE_PREFIX}--${(0, service_version_string_1.serviceVersionString)()}--`);
25
+ return (_a = s.name) === null || _a === void 0 ? void 0 : _a.startsWith(`${parent}/services/${constants_1.RENDER_SERVICE_PREFIX}-${(0, service_version_string_1.serviceVersionString)()}-`);
25
26
  });
26
27
  }
27
28
  else {
28
29
  remotionServices = services.filter((s) => {
29
30
  var _a;
30
- return (_a = s.name) === null || _a === void 0 ? void 0 : _a.startsWith(`${parent}/services/${constants_1.RENDER_SERVICE_PREFIX}--`);
31
+ return (_a = s.name) === null || _a === void 0 ? void 0 : _a.startsWith(`${parent}/services/${constants_1.RENDER_SERVICE_PREFIX}-`);
31
32
  });
32
33
  }
33
34
  return remotionServices.map((service) => {
34
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
35
- const deployedServiceName = (_a = service.name) === null || _a === void 0 ? void 0 : _a.replace(parent + '/services/', '');
36
- const deployedRegion = (_b = service.name) === null || _b === void 0 ? void 0 : _b.split('/')[3];
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
36
+ const { consoleUrl, region, remotionVersion, serviceName } = (0, parse_service_name_1.parseServiceName)(service.name, params.region);
37
37
  return {
38
- serviceName: deployedServiceName,
39
- timeoutInSeconds: (_d = (_c = service.template) === null || _c === void 0 ? void 0 : _c.timeout) === null || _d === void 0 ? void 0 : _d.seconds,
40
- memoryLimit: (_h = (_g = (_f = (_e = service.template) === null || _e === void 0 ? void 0 : _e.containers) === null || _f === void 0 ? void 0 : _f[0].resources) === null || _g === void 0 ? void 0 : _g.limits) === null || _h === void 0 ? void 0 : _h.memory,
41
- cpuLimit: (_m = (_l = (_k = (_j = service.template) === null || _j === void 0 ? void 0 : _j.containers) === null || _k === void 0 ? void 0 : _k[0].resources) === null || _l === void 0 ? void 0 : _l.limits) === null || _m === void 0 ? void 0 : _m.cpu,
42
- remotionVersion: (_o = service.name) === null || _o === void 0 ? void 0 : _o.replace(parent + '/services/' + constants_1.RENDER_SERVICE_PREFIX + '--', '').split('--')[0].replace(/-/g, '.'),
38
+ consoleUrl,
39
+ region,
40
+ remotionVersion,
41
+ serviceName,
42
+ timeoutInSeconds: (_b = (_a = service.template) === null || _a === void 0 ? void 0 : _a.timeout) === null || _b === void 0 ? void 0 : _b.seconds,
43
+ memoryLimit: (_f = (_e = (_d = (_c = service.template) === null || _c === void 0 ? void 0 : _c.containers) === null || _d === void 0 ? void 0 : _d[0].resources) === null || _e === void 0 ? void 0 : _e.limits) === null || _f === void 0 ? void 0 : _f.memory,
44
+ cpuLimit: (_k = (_j = (_h = (_g = service.template) === null || _g === void 0 ? void 0 : _g.containers) === null || _h === void 0 ? void 0 : _h[0].resources) === null || _j === void 0 ? void 0 : _j.limits) === null || _k === void 0 ? void 0 : _k.cpu,
43
45
  uri: service.uri,
44
- region: deployedRegion,
45
- consoleUrl: `https://console.cloud.google.com/run/detail/${deployedRegion}/${deployedServiceName}/logs`,
46
46
  };
47
47
  });
48
48
  };
@@ -0,0 +1,8 @@
1
+ import { GcpRegion } from '../../pricing/gcp-regions';
2
+ export declare const getGcpParent: (region: GcpRegion) => string;
3
+ export declare const parseServiceName: (fullServiceName: string, region: GcpRegion) => {
4
+ serviceName: string;
5
+ remotionVersion: string;
6
+ region: "asia-east1" | "asia-east2" | "asia-northeast1" | "asia-northeast2" | "asia-northeast3" | "asia-south1" | "asia-south2" | "asia-southeast1" | "asia-southeast2" | "australia-southeast1" | "australia-southeast2" | "europe-central2" | "europe-north1" | "europe-southwest1" | "europe-west1" | "europe-west2" | "europe-west3" | "europe-west4" | "europe-west6" | "europe-west8" | "europe-west9" | "me-west1" | "northamerica-northeast1" | "northamerica-northeast2" | "southamerica-east1" | "southamerica-west1" | "us-central1" | "us-east1" | "us-east4" | "us-east5" | "us-south1" | "us-west1" | "us-west2" | "us-west3" | "us-west4";
7
+ consoleUrl: string;
8
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseServiceName = exports.getGcpParent = void 0;
4
+ const getGcpParent = (region) => {
5
+ const parent = `projects/${process.env.REMOTION_GCP_PROJECT_ID}/locations/${region}`;
6
+ return parent;
7
+ };
8
+ exports.getGcpParent = getGcpParent;
9
+ const parseServiceName = (fullServiceName, region) => {
10
+ const parent = (0, exports.getGcpParent)(region);
11
+ const shortServiceName = fullServiceName.replace(parent + '/services/', '');
12
+ const deployedRegion = fullServiceName.split('/')[3];
13
+ const matched = shortServiceName.match(/remotion\-(.*)\-mem([0-9])/);
14
+ if (!matched) {
15
+ throw new Error(`Could not parse service name ${shortServiceName}`);
16
+ }
17
+ return {
18
+ serviceName: shortServiceName,
19
+ remotionVersion: matched[1],
20
+ region: deployedRegion,
21
+ consoleUrl: `https://console.cloud.google.com/run/detail/${deployedRegion}/${shortServiceName}/logs`,
22
+ };
23
+ };
24
+ exports.parseServiceName = parseServiceName;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const remotion_1 = require("remotion");
4
+ const vitest_1 = require("vitest");
5
+ const parse_service_name_1 = require("../helpers/parse-service-name");
6
+ const speculate_service_name_1 = require("../speculate-service-name");
7
+ const dashedVersion = remotion_1.VERSION.replace(/\./g, '-');
8
+ const region = 'asia-east1';
9
+ process.env.REMOTION_GCP_PROJECT_ID = 'remotion-test-project';
10
+ (0, vitest_1.test)('Parse service names', () => {
11
+ const shortServiceName = (0, speculate_service_name_1.speculateServiceName)({
12
+ cpuLimit: '8.0',
13
+ memoryLimit: '100000k',
14
+ // max timeout
15
+ timeoutSeconds: 3600,
16
+ });
17
+ (0, vitest_1.expect)(shortServiceName).toBe(`remotion-${remotion_1.VERSION.replace(/\./g, '-')}-mem100000k-cpu8-0-t3600`);
18
+ const fullServiceName = `${(0, parse_service_name_1.getGcpParent)(region)}/services/${shortServiceName}`;
19
+ const parsed = (0, parse_service_name_1.parseServiceName)(fullServiceName, region);
20
+ (0, vitest_1.expect)(parsed).toEqual({
21
+ consoleUrl: `https://console.cloud.google.com/run/detail/asia-east1/remotion-${dashedVersion}-mem100000k-cpu8-0-t3600/logs`,
22
+ region: 'asia-east1',
23
+ remotionVersion: '4-1-0-alpha2',
24
+ serviceName: `remotion-${dashedVersion}-mem100000k-cpu8-0-t3600`,
25
+ });
26
+ // Max length of service name is 49 characters, asking for less in case the version string gets longer
27
+ (0, vitest_1.expect)(shortServiceName.length).toBeLessThanOrEqual(47);
28
+ });
@@ -1,2 +1,2 @@
1
1
  export declare const RENDER_COMMAND = "render";
2
- export declare const renderCommand: (args: string[], remotionRoot: string) => Promise<void> | undefined;
2
+ export declare const renderCommand: (args: string[], remotionRoot: string) => Promise<void>;
@@ -2,35 +2,155 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderCommand = exports.RENDER_COMMAND = void 0;
4
4
  const cli_1 = require("@remotion/cli");
5
- const constants_1 = require("../../../shared/constants");
6
- const quit_1 = require("../../helpers/quit");
5
+ const render_media_on_cloudrun_1 = require("../../../api/render-media-on-cloudrun");
6
+ // import {validateMaxRetries} from '../../../shared/validate-retries';
7
+ const config_1 = require("@remotion/cli/config");
8
+ const renderer_1 = require("@remotion/renderer");
9
+ const download_file_1 = require("../../../api/download-file");
10
+ const validate_serveurl_1 = require("../../../shared/validate-serveurl");
11
+ const args_1 = require("../../args");
7
12
  const log_1 = require("../../log");
8
- const renderMedia_1 = require("./renderMedia");
9
- const renderStill_1 = require("./renderStill");
13
+ const renderArgsCheck_1 = require("./helpers/renderArgsCheck");
10
14
  exports.RENDER_COMMAND = 'render';
11
- const printCloudRunHelp = () => {
12
- log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.RENDER_COMMAND} <subcommand>`);
13
- log_1.Log.info();
14
- log_1.Log.info('Available subcommands:');
15
- log_1.Log.info('');
16
- log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.RENDER_COMMAND} ${renderMedia_1.RENDER_MEDIA_SUBCOMMAND}`);
17
- log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Media on Cloud Run'));
18
- log_1.Log.info('');
19
- log_1.Log.info(`${constants_1.BINARY_NAME} ${exports.RENDER_COMMAND} ${renderStill_1.RENDER_STILL_SUBCOMMAND}`);
20
- log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Still on Cloud Run'));
21
- };
22
- const renderCommand = (args, remotionRoot) => {
23
- if (args[0] === renderMedia_1.RENDER_MEDIA_SUBCOMMAND) {
24
- return (0, renderMedia_1.renderMediaSubcommand)(args.slice(1), remotionRoot);
15
+ const renderCommand = async (args, remotionRoot) => {
16
+ var _a;
17
+ const { serveUrl, cloudRunUrl, outName, forceBucketName, downloadName, privacy, region, } = await (0, renderArgsCheck_1.renderArgsCheck)(exports.RENDER_COMMAND, args);
18
+ const { codec, reason: codecReason } = cli_1.CliInternals.getFinalOutputCodec({
19
+ cliFlag: cli_1.CliInternals.parsedCli.codec,
20
+ downloadName,
21
+ outName: outName !== null && outName !== void 0 ? outName : null,
22
+ configFile: (_a = config_1.ConfigInternals.getOutputCodecOrUndefined()) !== null && _a !== void 0 ? _a : null,
23
+ uiCodec: null,
24
+ });
25
+ const imageFormat = args_1.parsedCloudrunCli['image-format'];
26
+ const audioCodec = args_1.parsedCloudrunCli['audio-codec'];
27
+ const { chromiumOptions, crf, envVariables, frameRange, inputProps, logLevel, puppeteerTimeout, pixelFormat, proResProfile, jpegQuality, scale, everyNthFrame, numberOfGifLoops, muted, audioBitrate, videoBitrate, height, width, browserExecutable, port, } = await cli_1.CliInternals.getCliOptions({
28
+ type: 'series',
29
+ isLambda: true,
30
+ remotionRoot,
31
+ });
32
+ let composition = args[1];
33
+ if (!composition) {
34
+ log_1.Log.info('No compositions passed. Fetching compositions...');
35
+ (0, validate_serveurl_1.validateServeUrl)(serveUrl);
36
+ const server = renderer_1.RenderInternals.prepareServer({
37
+ concurrency: 1,
38
+ indent: false,
39
+ port,
40
+ remotionRoot,
41
+ verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
42
+ webpackConfigOrServeUrl: serveUrl,
43
+ });
44
+ const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
45
+ args,
46
+ compositionIdFromUi: null,
47
+ browserExecutable,
48
+ chromiumOptions,
49
+ envVariables,
50
+ height,
51
+ indent: false,
52
+ inputProps,
53
+ port,
54
+ puppeteerInstance: undefined,
55
+ serveUrlOrWebpackUrl: serveUrl,
56
+ timeoutInMilliseconds: puppeteerTimeout,
57
+ verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
58
+ width,
59
+ server: await server,
60
+ });
61
+ composition = compositionId;
25
62
  }
26
- if (args[0] === renderStill_1.RENDER_STILL_SUBCOMMAND) {
27
- return (0, renderStill_1.renderStillSubcommand)(args.slice(1), remotionRoot);
28
- }
29
- if (args[0]) {
30
- log_1.Log.error(`Subcommand ${args[0]} not found.`);
31
- printCloudRunHelp();
32
- (0, quit_1.quit)(1);
63
+ // Todo: Check cloudRunUrl is valid, as the error message is obtuse
64
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray(`
65
+ Cloud Run Service URL = ${cloudRunUrl}
66
+ Region = ${region}
67
+ Type = media
68
+ Composition = ${composition}
69
+ Codec = ${codec}
70
+ Output Bucket = ${forceBucketName}
71
+ Output File = ${outName !== null && outName !== void 0 ? outName : 'out.mp4'}
72
+ Output File Privacy = ${privacy}
73
+ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
74
+ `.trim()));
75
+ log_1.Log.info();
76
+ const renderStart = Date.now();
77
+ const progressBar = cli_1.CliInternals.createOverwriteableCliOutput({
78
+ quiet: cli_1.CliInternals.quietFlagProvided(),
79
+ cancelSignal: null,
80
+ updatesDontOverwrite: false,
81
+ indent: false,
82
+ });
83
+ const renderProgress = {
84
+ doneIn: null,
85
+ progress: 0,
86
+ };
87
+ const updateProgress = () => {
88
+ progressBar.update([
89
+ `Rendering on Cloud Run: `,
90
+ cli_1.CliInternals.makeProgressBar(renderProgress.progress),
91
+ `${renderProgress.doneIn === null ? 'Rendering' : 'Rendered'}`,
92
+ renderProgress.doneIn === null
93
+ ? `${Math.round(renderProgress.progress * 100)}%`
94
+ : cli_1.CliInternals.chalk.gray(`${renderProgress.doneIn}ms`),
95
+ ].join(' '), false);
96
+ };
97
+ const updateRenderProgress = (progress) => {
98
+ renderProgress.progress = progress;
99
+ updateProgress();
100
+ };
101
+ const res = await (0, render_media_on_cloudrun_1.renderMediaOnCloudrun)({
102
+ cloudRunUrl,
103
+ serveUrl,
104
+ region,
105
+ inputProps,
106
+ codec: codec,
107
+ imageFormat,
108
+ crf: crf !== null && crf !== void 0 ? crf : undefined,
109
+ envVariables,
110
+ pixelFormat,
111
+ proResProfile,
112
+ jpegQuality,
113
+ composition,
114
+ privacy,
115
+ frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : undefined,
116
+ outName,
117
+ chromiumOptions,
118
+ scale,
119
+ numberOfGifLoops,
120
+ everyNthFrame,
121
+ muted,
122
+ audioBitrate,
123
+ videoBitrate,
124
+ forceHeight: height,
125
+ forceWidth: width,
126
+ audioCodec,
127
+ forceBucketName,
128
+ updateRenderProgress,
129
+ logLevel: config_1.ConfigInternals.Logging.getLogLevel(),
130
+ });
131
+ renderProgress.doneIn = Date.now() - renderStart;
132
+ updateProgress();
133
+ log_1.Log.info(`
134
+
135
+ `);
136
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`
137
+ ${res.publicUrl ? `Public URL = ${decodeURIComponent(res.publicUrl)}` : ``}
138
+ Cloud Storage Uri = ${res.cloudStorageUri}
139
+ Size (KB) = ${Math.round(Number(res.size) / 1000)}
140
+ Bucket Name = ${res.bucketName}
141
+ Privacy = ${res.privacy}
142
+ Render ID = ${res.renderId}
143
+ Codec = ${codec} (${codecReason})
144
+ `.trim()));
145
+ if (downloadName) {
146
+ log_1.Log.info('');
147
+ log_1.Log.info('downloading file...');
148
+ const destination = await (0, download_file_1.downloadFile)({
149
+ bucketName: res.bucketName,
150
+ gsutilURI: res.cloudStorageUri,
151
+ downloadName,
152
+ });
153
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`));
33
154
  }
34
- printCloudRunHelp();
35
155
  };
36
156
  exports.renderCommand = renderCommand;
@@ -0,0 +1,2 @@
1
+ export declare const STILL_COMMAND = "still";
2
+ export declare const stillCommand: (args: string[], remotionRoot: string) => Promise<void>;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stillCommand = exports.STILL_COMMAND = void 0;
4
+ const cli_1 = require("@remotion/cli");
5
+ const config_1 = require("@remotion/cli/config");
6
+ const renderer_1 = require("@remotion/renderer");
7
+ const download_file_1 = require("../../api/download-file");
8
+ const render_still_on_cloudrun_1 = require("../../api/render-still-on-cloudrun");
9
+ const validate_serveurl_1 = require("../../shared/validate-serveurl");
10
+ const log_1 = require("../log");
11
+ const renderArgsCheck_1 = require("./render/helpers/renderArgsCheck");
12
+ exports.STILL_COMMAND = 'still';
13
+ const stillCommand = async (args, remotionRoot) => {
14
+ var _a, _b;
15
+ const { serveUrl, cloudRunUrl, outName, forceBucketName, privacy, downloadName, region, } = await (0, renderArgsCheck_1.renderArgsCheck)(exports.STILL_COMMAND, args);
16
+ const { chromiumOptions, envVariables, inputProps, logLevel, puppeteerTimeout, jpegQuality, stillFrame, scale, height, width, browserExecutable, port, } = await cli_1.CliInternals.getCliOptions({
17
+ type: 'still',
18
+ isLambda: true,
19
+ remotionRoot,
20
+ });
21
+ let composition = args[1];
22
+ if (!composition) {
23
+ log_1.Log.info('No compositions passed. Fetching compositions...');
24
+ (0, validate_serveurl_1.validateServeUrl)(serveUrl);
25
+ const server = renderer_1.RenderInternals.prepareServer({
26
+ concurrency: 1,
27
+ indent: false,
28
+ port,
29
+ remotionRoot,
30
+ verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
31
+ webpackConfigOrServeUrl: serveUrl,
32
+ });
33
+ const { compositionId } = await cli_1.CliInternals.getCompositionWithDimensionOverride({
34
+ args,
35
+ compositionIdFromUi: null,
36
+ indent: false,
37
+ serveUrlOrWebpackUrl: serveUrl,
38
+ verbose: renderer_1.RenderInternals.isEqualOrBelowLogLevel(logLevel, 'verbose'),
39
+ browserExecutable,
40
+ chromiumOptions,
41
+ envVariables,
42
+ inputProps,
43
+ port,
44
+ puppeteerInstance: undefined,
45
+ timeoutInMilliseconds: puppeteerTimeout,
46
+ height,
47
+ width,
48
+ server: await server,
49
+ });
50
+ composition = compositionId;
51
+ }
52
+ const { format: imageFormat, source: imageFormatReason } = cli_1.CliInternals.determineFinalStillImageFormat({
53
+ downloadName,
54
+ outName: outName !== null && outName !== void 0 ? outName : null,
55
+ cliFlag: (_a = cli_1.CliInternals.parsedCli['image-format']) !== null && _a !== void 0 ? _a : null,
56
+ isLambda: true,
57
+ fromUi: null,
58
+ configImageFormat: (_b = config_1.ConfigInternals.getUserPreferredStillImageFormat()) !== null && _b !== void 0 ? _b : null,
59
+ });
60
+ log_1.Log.verbose(`Image format: (${imageFormat}), ${imageFormatReason}`);
61
+ // Todo: Check cloudRunUrl is valid, as the error message is obtuse
62
+ cli_1.CliInternals.Log.info(cli_1.CliInternals.chalk.gray(`
63
+ Cloud Run Service URL = ${cloudRunUrl}
64
+ Region = ${region}
65
+ Type = still
66
+ Composition = ${composition}
67
+ Output Bucket = ${forceBucketName}
68
+ Output File = ${outName !== null && outName !== void 0 ? outName : 'out.png'}
69
+ Output File Privacy = ${privacy}
70
+ ${downloadName ? ` Downloaded File = ${downloadName}` : ''}
71
+ `.trim()));
72
+ log_1.Log.info();
73
+ const renderStart = Date.now();
74
+ const progressBar = cli_1.CliInternals.createOverwriteableCliOutput({
75
+ quiet: cli_1.CliInternals.quietFlagProvided(),
76
+ cancelSignal: null,
77
+ updatesDontOverwrite: false,
78
+ indent: false,
79
+ });
80
+ let doneIn = null;
81
+ const updateProgress = (newline) => {
82
+ progressBar.update([
83
+ `Rendering on Cloud Run:`,
84
+ `${doneIn === null ? '...' : `Rendered in ${doneIn}ms`}`,
85
+ ].join(' '), newline);
86
+ };
87
+ const res = await (0, render_still_on_cloudrun_1.renderStillOnCloudrun)({
88
+ cloudRunUrl,
89
+ serveUrl,
90
+ region,
91
+ inputProps,
92
+ imageFormat,
93
+ composition,
94
+ privacy,
95
+ envVariables,
96
+ frame: stillFrame,
97
+ jpegQuality,
98
+ chromiumOptions,
99
+ scale,
100
+ forceHeight: height,
101
+ forceWidth: width,
102
+ forceBucketName,
103
+ outName,
104
+ logLevel: config_1.ConfigInternals.Logging.getLogLevel(),
105
+ });
106
+ doneIn = Date.now() - renderStart;
107
+ updateProgress(true);
108
+ log_1.Log.info(cli_1.CliInternals.chalk.gray(`Cloud Storage Uri = ${res.cloudStorageUri}`));
109
+ log_1.Log.info(cli_1.CliInternals.chalk.gray(`Render ID = ${res.renderId}`));
110
+ log_1.Log.info(cli_1.CliInternals.chalk.gray(`${Math.round(Number(res.size) / 1000)} KB, Privacy: ${res.privacy}, Bucket: ${res.bucketName}`));
111
+ log_1.Log.info(cli_1.CliInternals.chalk.blue(`○ ${res.publicUrl}`));
112
+ if (downloadName) {
113
+ log_1.Log.info('');
114
+ log_1.Log.info('downloading file...');
115
+ const destination = await (0, download_file_1.downloadFile)({
116
+ bucketName: res.bucketName,
117
+ gsutilURI: res.cloudStorageUri,
118
+ downloadName,
119
+ });
120
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`));
121
+ }
122
+ };
123
+ exports.stillCommand = stillCommand;
package/dist/cli/help.js CHANGED
@@ -8,6 +8,7 @@ const regions_1 = require("./commands/regions");
8
8
  const render_1 = require("./commands/render");
9
9
  const services_1 = require("./commands/services");
10
10
  const sites_1 = require("./commands/sites");
11
+ const still_1 = require("./commands/still");
11
12
  const log_1 = require("./log");
12
13
  const packagejson = require('../../package.json');
13
14
  const printHelp = () => {
@@ -17,7 +18,10 @@ const printHelp = () => {
17
18
  log_1.Log.info('');
18
19
  log_1.Log.info();
19
20
  log_1.Log.info(`${constants_1.BINARY_NAME} ${render_1.RENDER_COMMAND}`);
20
- log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Remotion media/still on GCP Cloud Run.'));
21
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Remotion media on GCP Cloud Run.'));
22
+ log_1.Log.info();
23
+ log_1.Log.info(`${constants_1.BINARY_NAME} ${still_1.STILL_COMMAND}`);
24
+ log_1.Log.info(cli_1.CliInternals.chalk.gray('Render Remotion still on GCP Cloud Run.'));
21
25
  log_1.Log.info();
22
26
  log_1.Log.info(`${constants_1.BINARY_NAME} ${services_1.SERVICES_COMMAND}`);
23
27
  log_1.Log.info(cli_1.CliInternals.chalk.gray('Deploy and manage Cloud Run services on GCP.'));
package/dist/cli/index.js CHANGED
@@ -5,6 +5,7 @@ const args_1 = require("./args");
5
5
  const permissions_1 = require("./commands/permissions");
6
6
  const regions_1 = require("./commands/regions");
7
7
  const render_1 = require("./commands/render");
8
+ const still_1 = require("./commands/still");
8
9
  const services_1 = require("./commands/services");
9
10
  const sites_1 = require("./commands/sites");
10
11
  const help_1 = require("./help");
@@ -18,6 +19,9 @@ const matchCommand = (args, remotionRoot) => {
18
19
  if (args[0] === render_1.RENDER_COMMAND) {
19
20
  return (0, render_1.renderCommand)(args.slice(1), remotionRoot);
20
21
  }
22
+ if (args[0] === still_1.STILL_COMMAND) {
23
+ return (0, still_1.stillCommand)(args.slice(1), remotionRoot);
24
+ }
21
25
  if (args[0] === services_1.SERVICES_COMMAND) {
22
26
  return (0, services_1.servicesCommand)(args.slice(1));
23
27
  }
package/dist/cli/log.d.ts CHANGED
@@ -2,7 +2,7 @@ export declare const Log: {
2
2
  verbose: (message?: any, ...optionalParams: any[]) => void;
3
3
  verboseAdvanced: (options: {
4
4
  indent: boolean;
5
- logLevel: "error" | "verbose" | "info" | "warn";
5
+ logLevel: "verbose" | "info" | "warn" | "error";
6
6
  } & {
7
7
  tag?: string | undefined;
8
8
  secondTag?: string | undefined;
@@ -10,12 +10,12 @@ export declare const Log: {
10
10
  info: (message?: any, ...optionalParams: any[]) => void;
11
11
  infoAdvanced: (options: {
12
12
  indent: boolean;
13
- logLevel: "error" | "verbose" | "info" | "warn";
13
+ logLevel: "verbose" | "info" | "warn" | "error";
14
14
  }, message?: any, ...optionalParams: any[]) => void;
15
15
  warn: (message?: any, ...optionalParams: any[]) => void;
16
16
  warnAdvanced: (options: {
17
17
  indent: boolean;
18
- logLevel: "error" | "verbose" | "info" | "warn";
18
+ logLevel: "verbose" | "info" | "warn" | "error";
19
19
  }, message?: any, ...optionalParams: any[]) => void;
20
20
  error: (message?: any, ...optionalParams: any[]) => void;
21
21
  };
@@ -0,0 +1 @@
1
+ export declare const getCompositionFromBody: (serveUrl: string, compositionName: string) => Promise<import("remotion").AnyCompMetadata>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCompositionFromBody = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
5
+ const getCompositionFromBody = async (serveUrl, compositionName) => {
6
+ const comps = await (0, renderer_1.getCompositions)(serveUrl);
7
+ const composition = comps.find((comp) => comp.id === compositionName);
8
+ if (composition) {
9
+ return composition;
10
+ }
11
+ throw new Error(`Composition not found: ${compositionName}`);
12
+ };
13
+ exports.getCompositionFromBody = getCompositionFromBody;
@@ -0,0 +1,11 @@
1
+ import type { File } from '@google-cloud/storage';
2
+ export declare type CloudrunLSInput = {
3
+ bucketName: string;
4
+ prefix: string;
5
+ };
6
+ export declare type CloudrunLsReturnType = Promise<File[]>;
7
+ export declare const cloudrunLs: ({ bucketName, prefix, }: CloudrunLSInput) => CloudrunLsReturnType;
8
+ export declare const cloudrunDeleteFile: ({ bucketName, key, }: {
9
+ bucketName: string;
10
+ key: string;
11
+ }) => Promise<void>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cloudrunDeleteFile = exports.cloudrunLs = void 0;
4
+ const get_cloud_storage_client_1 = require("../../api/helpers/get-cloud-storage-client");
5
+ const cloudrunLs = async ({ bucketName, prefix, }) => {
6
+ const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
7
+ const [files] = await cloudStorageClient
8
+ .bucket(bucketName)
9
+ .getFiles({ prefix, autoPaginate: true });
10
+ return files;
11
+ };
12
+ exports.cloudrunLs = cloudrunLs;
13
+ const cloudrunDeleteFile = async ({ bucketName, key, }) => {
14
+ const cloudStorageClient = (0, get_cloud_storage_client_1.getCloudStorageClient)();
15
+ await cloudStorageClient.bucket(bucketName).file(key).delete();
16
+ };
17
+ exports.cloudrunDeleteFile = cloudrunDeleteFile;