@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
@@ -1,13 +1,13 @@
1
1
 
2
- > @remotion/cloudrun@3.3.96 build /Users/jonathanburger/remotion-v4/packages/cloudrun
2
+ > @remotion/cloudrun@3.3.101 build /Users/jonathanburger/remotion-v4/packages/cloudrun
3
3
  > tsc -d && cp src/shared/sa-permissions.json dist/shared/sa-permissions.json && pnpm run buildContainer && pnpm run tarInstaller
4
4
 
5
5
 
6
- > @remotion/cloudrun@3.3.96 buildContainer /Users/jonathanburger/remotion-v4/packages/cloudrun
6
+ > @remotion/cloudrun@3.3.101 buildContainer /Users/jonathanburger/remotion-v4/packages/cloudrun
7
7
  > ts-node src/admin/bundle-renderLogic.ts
8
8
 
9
9
  distribution bundled.
10
10
 
11
- > @remotion/cloudrun@3.3.96 tarInstaller /Users/jonathanburger/remotion-v4/packages/cloudrun
11
+ > @remotion/cloudrun@3.3.101 tarInstaller /Users/jonathanburger/remotion-v4/packages/cloudrun
12
12
  > ts-node src/admin/bundle-installer.ts
13
13
 
@@ -34,7 +34,6 @@ const checkIfServiceExists = async ({ memoryLimit, cpuLimit, timeoutSeconds, pro
34
34
  return response;
35
35
  }
36
36
  }
37
- return;
38
37
  }
39
38
  catch (e) {
40
39
  if (e.code === 7) {
@@ -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 type { 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;
@@ -32,6 +32,10 @@ export declare type RenderMediaOnCloudrunInput = {
32
32
  forceWidth?: number | null;
33
33
  forceHeight?: number | null;
34
34
  logLevel?: LogLevel;
35
+ delayRenderTimeoutInMilliseconds?: number;
36
+ concurrency?: number | string | null;
37
+ enforceAudioTrack?: boolean;
38
+ preferLossless?: boolean;
35
39
  };
36
40
  /**
37
41
  * @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
@@ -65,6 +69,10 @@ export declare type RenderMediaOnCloudrunInput = {
65
69
  * @param params.forceWidth Overrides default composition width.
66
70
  * @param params.forceHeight Overrides default composition height.
67
71
  * @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
72
+ * @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
73
+ * @param params.concurrency By default, each Cloud Run service renders with concurrency 1 (one open browser tab). You may use the option to customize this value.
74
+ * @param params.enforceAudioTrack Render a silent audio track if there wouldn't be any otherwise.
75
+ * @param params.preferLossless Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.
68
76
  * @returns {Promise<RenderMediaOnCloudrunOutput>} See documentation for detailed structure
69
77
  */
70
- export declare const renderMediaOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, }: RenderMediaOnCloudrunInput) => Promise<RenderMediaOnCloudrunOutput>;
78
+ export declare const renderMediaOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, concurrency, enforceAudioTrack, preferLossless, }: RenderMediaOnCloudrunInput) => Promise<RenderMediaOnCloudrunOutput>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderMediaOnCloudrun = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
4
5
  const validate_gcp_codec_1 = require("../shared/validate-gcp-codec");
5
6
  const validate_privacy_1 = require("../shared/validate-privacy");
6
7
  const validate_serveurl_1 = require("../shared/validate-serveurl");
@@ -39,9 +40,13 @@ const get_cloudrun_endpoint_1 = require("./helpers/get-cloudrun-endpoint");
39
40
  * @param params.forceWidth Overrides default composition width.
40
41
  * @param params.forceHeight Overrides default composition height.
41
42
  * @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
43
+ * @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
44
+ * @param params.concurrency By default, each Cloud Run service renders with concurrency 1 (one open browser tab). You may use the option to customize this value.
45
+ * @param params.enforceAudioTrack Render a silent audio track if there wouldn't be any otherwise.
46
+ * @param params.preferLossless Uses a lossless audio codec, if one is available for the codec. If you set audioCodec, it takes priority over preferLossless.
42
47
  * @returns {Promise<RenderMediaOnCloudrunOutput>} See documentation for detailed structure
43
48
  */
44
- const renderMediaOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, }) => {
49
+ const renderMediaOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, codec, forceBucketName, privacy, outName, updateRenderProgress, jpegQuality, audioCodec, audioBitrate, videoBitrate, proResProfile, crf, pixelFormat, imageFormat, scale, everyNthFrame, numberOfGifLoops, frameRange, envVariables, chromiumOptions, muted, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, concurrency, enforceAudioTrack, preferLossless, }) => {
45
50
  const actualCodec = (0, validate_gcp_codec_1.validateCloudrunCodec)(codec);
46
51
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
47
52
  if (privacy)
@@ -56,22 +61,22 @@ const renderMediaOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUr
56
61
  composition,
57
62
  serveUrl,
58
63
  codec: actualCodec,
59
- inputProps,
60
- jpegQuality,
61
- audioCodec,
62
- audioBitrate,
63
- videoBitrate,
64
- crf,
65
- pixelFormat,
66
- imageFormat,
67
- scale,
68
- proResProfile,
69
- everyNthFrame,
70
- numberOfGifLoops,
71
- frameRange,
72
- envVariables,
64
+ inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
65
+ jpegQuality: jpegQuality !== null && jpegQuality !== void 0 ? jpegQuality : renderer_1.RenderInternals.DEFAULT_JPEG_QUALITY,
66
+ audioCodec: audioCodec !== null && audioCodec !== void 0 ? audioCodec : null,
67
+ audioBitrate: audioBitrate !== null && audioBitrate !== void 0 ? audioBitrate : null,
68
+ videoBitrate: videoBitrate !== null && videoBitrate !== void 0 ? videoBitrate : null,
69
+ crf: crf !== null && crf !== void 0 ? crf : null,
70
+ pixelFormat: pixelFormat !== null && pixelFormat !== void 0 ? pixelFormat : renderer_1.RenderInternals.DEFAULT_PIXEL_FORMAT,
71
+ imageFormat: imageFormat !== null && imageFormat !== void 0 ? imageFormat : renderer_1.RenderInternals.DEFAULT_VIDEO_IMAGE_FORMAT,
72
+ scale: scale !== null && scale !== void 0 ? scale : 1,
73
+ proResProfile: proResProfile !== null && proResProfile !== void 0 ? proResProfile : null,
74
+ everyNthFrame: everyNthFrame !== null && everyNthFrame !== void 0 ? everyNthFrame : 1,
75
+ numberOfGifLoops: numberOfGifLoops !== null && numberOfGifLoops !== void 0 ? numberOfGifLoops : null,
76
+ frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
77
+ envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
73
78
  chromiumOptions,
74
- muted,
79
+ muted: muted !== null && muted !== void 0 ? muted : false,
75
80
  outputBucket,
76
81
  privacy,
77
82
  outName,
@@ -79,6 +84,10 @@ const renderMediaOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUr
79
84
  forceHeight,
80
85
  type: 'media',
81
86
  logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
87
+ delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : renderer_1.RenderInternals.DEFAULT_TIMEOUT,
88
+ concurrency: concurrency !== null && concurrency !== void 0 ? concurrency : null,
89
+ enforceAudioTrack: enforceAudioTrack !== null && enforceAudioTrack !== void 0 ? enforceAudioTrack : false,
90
+ preferLossless: preferLossless !== null && preferLossless !== void 0 ? preferLossless : false,
82
91
  };
83
92
  const client = await (0, get_auth_client_for_url_1.getAuthClientForUrl)(cloudRunEndpoint);
84
93
  const postResponse = await client.request({
@@ -20,6 +20,7 @@ export declare type RenderStillOnCloudrunInput = {
20
20
  forceWidth?: number | null;
21
21
  forceHeight?: number | null;
22
22
  logLevel?: LogLevel;
23
+ delayRenderTimeoutInMilliseconds?: number;
23
24
  };
24
25
  /**
25
26
  * @description Triggers a render on a GCP Cloud Run service given a composition and a Cloud Run URL.
@@ -42,6 +43,7 @@ export declare type RenderStillOnCloudrunInput = {
42
43
  * @param params.forceWidth Overrides default composition width.
43
44
  * @param params.forceHeight Overrides default composition height.
44
45
  * @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
46
+ * @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
45
47
  * @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
46
48
  */
47
- export declare const renderStillOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, }: RenderStillOnCloudrunInput) => Promise<RenderStillOnCloudrunOutput>;
49
+ export declare const renderStillOnCloudrun: ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, }: RenderStillOnCloudrunInput) => Promise<RenderStillOnCloudrunOutput>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderStillOnCloudrun = void 0;
4
+ const renderer_1 = require("@remotion/renderer");
4
5
  const validate_privacy_1 = require("../shared/validate-privacy");
5
6
  const validate_serveurl_1 = require("../shared/validate-serveurl");
6
7
  const get_or_create_bucket_1 = require("./get-or-create-bucket");
@@ -27,9 +28,10 @@ const get_cloudrun_endpoint_1 = require("./helpers/get-cloudrun-endpoint");
27
28
  * @param params.forceWidth Overrides default composition width.
28
29
  * @param params.forceHeight Overrides default composition height.
29
30
  * @param params.logLevel Level of logging that Cloud Run service should perform. Default "info".
31
+ * @param params.delayRenderTimeoutInMilliseconds A number describing how long the render may take to resolve all delayRender() calls before it times out.
30
32
  * @returns {Promise<RenderStillOnCloudrunOutput>} See documentation for detailed structure
31
33
  */
32
- const renderStillOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, }) => {
34
+ const renderStillOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUrl, composition, inputProps, forceBucketName, privacy, outName, imageFormat, envVariables, frame, jpegQuality, chromiumOptions, scale, forceWidth, forceHeight, logLevel, delayRenderTimeoutInMilliseconds, }) => {
33
35
  (0, validate_serveurl_1.validateServeUrl)(serveUrl);
34
36
  if (privacy)
35
37
  (0, validate_privacy_1.validatePrivacy)(privacy);
@@ -42,20 +44,21 @@ const renderStillOnCloudrun = async ({ cloudRunUrl, serviceName, region, serveUr
42
44
  const data = {
43
45
  composition,
44
46
  serveUrl,
45
- inputProps,
47
+ inputProps: inputProps !== null && inputProps !== void 0 ? inputProps : {},
46
48
  outputBucket,
47
49
  outName,
48
- privacy,
50
+ privacy: privacy !== null && privacy !== void 0 ? privacy : 'public',
49
51
  imageFormat,
50
- envVariables,
52
+ envVariables: envVariables !== null && envVariables !== void 0 ? envVariables : {},
51
53
  jpegQuality,
52
54
  chromiumOptions,
53
- scale,
55
+ scale: scale !== null && scale !== void 0 ? scale : 1,
54
56
  forceWidth,
55
57
  forceHeight,
56
58
  frame: frame !== null && frame !== void 0 ? frame : 0,
57
59
  type: 'still',
58
60
  logLevel: logLevel !== null && logLevel !== void 0 ? logLevel : 'info',
61
+ delayRenderTimeoutInMilliseconds: delayRenderTimeoutInMilliseconds !== null && delayRenderTimeoutInMilliseconds !== void 0 ? delayRenderTimeoutInMilliseconds : renderer_1.RenderInternals.DEFAULT_TIMEOUT,
59
62
  };
60
63
  const client = await (0, get_auth_client_for_url_1.getAuthClientForUrl)(cloudRunEndpoint);
61
64
  const renderResponse = await client.request({
@@ -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: remotion_1.VERSION.replace(/\./g, '-'),
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,161 @@
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, _b;
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, enforceAudioTrack, } = 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
+ logLevel,
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
+ logLevel,
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
+ // Special case: Should not use default local concurrency, or from
131
+ // config file, just when explicitly set
132
+ concurrency: (_b = cli_1.CliInternals.parsedCli.concurrency) !== null && _b !== void 0 ? _b : null,
133
+ delayRenderTimeoutInMilliseconds: puppeteerTimeout,
134
+ enforceAudioTrack,
135
+ preferLossless: false,
136
+ });
137
+ renderProgress.doneIn = Date.now() - renderStart;
138
+ updateProgress();
139
+ log_1.Log.info(`
140
+
141
+ `);
142
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`
143
+ ${res.publicUrl ? `Public URL = ${decodeURIComponent(res.publicUrl)}` : ``}
144
+ Cloud Storage Uri = ${res.cloudStorageUri}
145
+ Size (KB) = ${Math.round(Number(res.size) / 1000)}
146
+ Bucket Name = ${res.bucketName}
147
+ Privacy = ${res.privacy}
148
+ Render ID = ${res.renderId}
149
+ Codec = ${codec} (${codecReason})
150
+ `.trim()));
151
+ if (downloadName) {
152
+ log_1.Log.info('');
153
+ log_1.Log.info('downloading file...');
154
+ const destination = await (0, download_file_1.downloadFile)({
155
+ bucketName: res.bucketName,
156
+ gsutilURI: res.cloudStorageUri,
157
+ downloadName,
158
+ });
159
+ log_1.Log.info(cli_1.CliInternals.chalk.blueBright(`Downloaded file to ${destination}!`));
33
160
  }
34
- printCloudRunHelp();
35
161
  };
36
162
  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>;