@remotion/renderer 3.1.4 → 3.1.7

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 (121) hide show
  1. package/dist/assets/convert-assets-to-file-urls.d.ts +3 -2
  2. package/dist/assets/convert-assets-to-file-urls.js +2 -2
  3. package/dist/assets/download-and-map-assets-to-file.d.ts +6 -5
  4. package/dist/assets/download-and-map-assets-to-file.js +48 -48
  5. package/dist/assets/download-map.d.ts +57 -0
  6. package/dist/assets/download-map.js +20 -0
  7. package/dist/assets/get-audio-channels.d.ts +3 -7
  8. package/dist/assets/get-audio-channels.js +6 -7
  9. package/dist/assets/get-files-in-folder.d.ts +9 -0
  10. package/dist/assets/get-files-in-folder.js +50 -0
  11. package/dist/assets/get-video-stream-duration.d.ts +3 -0
  12. package/dist/assets/get-video-stream-duration.js +35 -0
  13. package/dist/browser/TimeoutSettings.d.ts +1 -0
  14. package/dist/browser/TimeoutSettings.js +4 -4
  15. package/dist/browser-executable.d.ts +1 -0
  16. package/dist/browser-executable.js +2 -0
  17. package/dist/browser.d.ts +2 -0
  18. package/dist/browser.js +4 -0
  19. package/dist/can-use-parallel-encoding.d.ts +1 -1
  20. package/dist/can-use-parallel-encoding.js +2 -2
  21. package/dist/codec-supports-media.d.ts +1 -1
  22. package/dist/codec.d.ts +4 -0
  23. package/dist/codec.js +16 -0
  24. package/dist/combine-videos.d.ts +1 -1
  25. package/dist/combine-videos.js +7 -6
  26. package/dist/compress-assets.d.ts +7 -0
  27. package/dist/compress-assets.js +25 -0
  28. package/dist/convert-to-pcm.d.ts +1 -1
  29. package/dist/create-ffmpeg-merge-filter.js +3 -3
  30. package/dist/create-silent-audio.d.ts +1 -1
  31. package/dist/crf.d.ts +5 -0
  32. package/dist/crf.js +64 -0
  33. package/dist/ensure-presentation-timestamp.d.ts +2 -1
  34. package/dist/ensure-presentation-timestamp.js +9 -7
  35. package/dist/extract-frame-from-video.d.ts +4 -1
  36. package/dist/extract-frame-from-video.js +22 -17
  37. package/dist/ffmpeg-executable.d.ts +1 -0
  38. package/dist/ffmpeg-executable.js +2 -0
  39. package/dist/frame-range.d.ts +2 -0
  40. package/dist/frame-range.js +49 -0
  41. package/dist/get-audio-codec-name.d.ts +1 -1
  42. package/dist/get-audio-codec-name.js +2 -2
  43. package/dist/get-browser-instance.d.ts +1 -1
  44. package/dist/get-browser-instance.js +2 -2
  45. package/dist/get-codec-name.d.ts +1 -1
  46. package/dist/get-codec-name.js +2 -2
  47. package/dist/get-compositions.d.ts +8 -1
  48. package/dist/get-compositions.js +6 -6
  49. package/dist/get-extension-from-codec.d.ts +1 -1
  50. package/dist/get-extension-of-filename.d.ts +1 -1
  51. package/dist/get-extension-of-filename.js +3 -0
  52. package/dist/get-frame-to-render.d.ts +1 -1
  53. package/dist/get-local-browser-executable.d.ts +2 -1
  54. package/dist/get-prores-profile-name.d.ts +2 -1
  55. package/dist/get-video-info.d.ts +3 -8
  56. package/dist/get-video-info.js +7 -8
  57. package/dist/image-format.d.ts +6 -1
  58. package/dist/image-format.js +25 -1
  59. package/dist/index.d.ts +45 -6
  60. package/dist/index.js +70 -1
  61. package/dist/is-audio-codec.d.ts +2 -0
  62. package/dist/is-audio-codec.js +7 -0
  63. package/dist/is-beyond-last-frame.d.ts +3 -2
  64. package/dist/is-beyond-last-frame.js +5 -5
  65. package/dist/last-frame-from-video-cache.d.ts +5 -3
  66. package/dist/last-frame-from-video-cache.js +17 -17
  67. package/dist/log-level.d.ts +4 -0
  68. package/dist/log-level.js +15 -0
  69. package/dist/merge-audio-track.d.ts +1 -1
  70. package/dist/merge-audio-track.js +2 -2
  71. package/dist/offthread-video-server.d.ts +5 -3
  72. package/dist/offthread-video-server.js +3 -2
  73. package/dist/open-browser.d.ts +1 -1
  74. package/dist/open-browser.js +4 -4
  75. package/dist/overwrite.d.ts +1 -0
  76. package/dist/overwrite.js +4 -0
  77. package/dist/perf.d.ts +5 -0
  78. package/dist/perf.js +35 -0
  79. package/dist/pixel-format.d.ts +5 -0
  80. package/dist/pixel-format.js +26 -0
  81. package/dist/prepare-server.d.ts +4 -3
  82. package/dist/prepare-server.js +3 -3
  83. package/dist/preprocess-audio-track.d.ts +3 -1
  84. package/dist/preprocess-audio-track.js +2 -2
  85. package/dist/prespawn-ffmpeg.d.ts +5 -1
  86. package/dist/prespawn-ffmpeg.js +9 -6
  87. package/dist/prores-profile.d.ts +5 -0
  88. package/dist/prores-profile.js +23 -0
  89. package/dist/provide-screenshot.d.ts +1 -1
  90. package/dist/quality.d.ts +1 -0
  91. package/dist/quality.js +21 -0
  92. package/dist/render-frames.d.ts +10 -1
  93. package/dist/render-frames.js +21 -16
  94. package/dist/render-media.d.ts +15 -2
  95. package/dist/render-media.js +16 -9
  96. package/dist/render-still.d.ts +9 -1
  97. package/dist/render-still.js +14 -10
  98. package/dist/screenshot-dom-element.d.ts +1 -1
  99. package/dist/screenshot-task.d.ts +1 -1
  100. package/dist/screenshot-task.js +7 -7
  101. package/dist/serve-static.d.ts +3 -2
  102. package/dist/serve-static.js +3 -4
  103. package/dist/set-props-and-env.js +2 -2
  104. package/dist/stitch-frames-to-video.d.ts +6 -1
  105. package/dist/stitch-frames-to-video.js +16 -11
  106. package/dist/stringify-ffmpeg-filter.js +2 -2
  107. package/dist/symbolicate-stacktrace.js +3 -3
  108. package/dist/truthy.d.ts +3 -0
  109. package/dist/truthy.js +7 -0
  110. package/dist/types.d.ts +1 -1
  111. package/dist/validate-even-dimensions-with-codec.d.ts +1 -1
  112. package/dist/validate-even-dimensions-with-codec.js +2 -2
  113. package/dist/validate-every-nth-frame.d.ts +1 -0
  114. package/dist/validate-every-nth-frame.js +21 -0
  115. package/dist/validate-ffmpeg.js +2 -3
  116. package/dist/validate-frame.d.ts +1 -0
  117. package/dist/validate-frame.js +24 -0
  118. package/dist/validate-opengl-renderer.d.ts +5 -0
  119. package/dist/validate-opengl-renderer.js +15 -0
  120. package/dist/validate-output-filename.d.ts +1 -1
  121. package/package.json +3 -3
@@ -2,6 +2,30 @@
2
2
  // Keeping the default image format PNG if you don't pass a
3
3
  // value to the renderer for backwards compatibility.
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.DEFAULT_IMAGE_FORMAT = void 0;
5
+ exports.validateNonNullImageFormat = exports.validateSelectedPixelFormatAndImageFormatCombination = exports.DEFAULT_IMAGE_FORMAT = exports.validImageFormats = void 0;
6
+ exports.validImageFormats = ['png', 'jpeg', 'none'];
6
7
  // However, the CLI will override it and use JPEG if suitable.
7
8
  exports.DEFAULT_IMAGE_FORMAT = 'png';
9
+ // By returning a value, we improve testability as we can specifically test certain branches
10
+ const validateSelectedPixelFormatAndImageFormatCombination = (pixelFormat, imageFormat) => {
11
+ if (imageFormat === 'none') {
12
+ return 'none';
13
+ }
14
+ if (!exports.validImageFormats.includes(imageFormat)) {
15
+ throw new TypeError(`Value ${imageFormat} is not valid as an image format.`);
16
+ }
17
+ if (pixelFormat !== 'yuva420p' && pixelFormat !== 'yuva444p10le') {
18
+ return 'valid';
19
+ }
20
+ if (imageFormat !== 'png') {
21
+ throw new TypeError(`Pixel format was set to '${pixelFormat}' but the image format is not PNG. To render transparent videos, you need to set PNG as the image format.`);
22
+ }
23
+ return 'valid';
24
+ };
25
+ exports.validateSelectedPixelFormatAndImageFormatCombination = validateSelectedPixelFormatAndImageFormatCombination;
26
+ const validateNonNullImageFormat = (imageFormat) => {
27
+ if (imageFormat !== 'jpeg' && imageFormat !== 'png') {
28
+ throw new TypeError('Image format should be either "png" or "jpeg"');
29
+ }
30
+ };
31
+ exports.validateNonNullImageFormat = validateNonNullImageFormat;
package/dist/index.d.ts CHANGED
@@ -2,23 +2,36 @@
2
2
  import execa from 'execa';
3
3
  import { SymbolicateableError } from './error-handling/symbolicateable-error';
4
4
  import { mimeContentType, mimeLookup } from './mime-types';
5
+ import * as perf from './perf';
5
6
  export type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
7
+ export type { DownloadMap } from './assets/download-map';
8
+ export { Browser } from './browser';
9
+ export { BrowserExecutable } from './browser-executable';
6
10
  export { BrowserLog } from './browser-log';
11
+ export { Codec, CodecOrUndefined } from './codec';
7
12
  export { combineVideos } from './combine-videos';
13
+ export { Crf } from './crf';
8
14
  export { ErrorWithStackFrame } from './error-handling/handle-javascript-exception';
15
+ export { FfmpegExecutable } from './ffmpeg-executable';
9
16
  export { FfmpegVersion } from './ffmpeg-flags';
17
+ export { FrameRange } from './frame-range';
10
18
  export { getCompositions } from './get-compositions';
19
+ export { ImageFormat, StillImageFormat, validateSelectedPixelFormatAndImageFormatCombination, validImageFormats, } from './image-format';
20
+ export type { LogLevel } from './log-level';
11
21
  export { CancelSignal, makeCancelSignal } from './make-cancel-signal';
12
22
  export { openBrowser } from './open-browser';
13
23
  export type { ChromiumOptions } from './open-browser';
24
+ export { PixelFormat } from './pixel-format';
25
+ export { ProResProfile } from './prores-profile';
14
26
  export { renderFrames } from './render-frames';
15
27
  export { renderMedia, RenderMediaOnProgress, RenderMediaOptions, StitchingState, } from './render-media';
16
28
  export { renderStill } from './render-still';
17
29
  export { StitcherOptions, stitchFramesToVideo } from './stitch-frames-to-video';
18
30
  export { SymbolicatedStackFrame } from './symbolicate-stacktrace';
19
31
  export { OnStartData, RenderFramesOutput } from './types';
32
+ export { OpenGlRenderer } from './validate-opengl-renderer';
20
33
  export declare const RenderInternals: {
21
- ensureLocalBrowser: (browser: import("remotion").Browser, preferredBrowserExecutable: import("remotion").BrowserExecutable) => Promise<void>;
34
+ ensureLocalBrowser: (browser: import("./browser").Browser, preferredBrowserExecutable: import("./browser-executable").BrowserExecutable) => Promise<void>;
22
35
  ffmpegHasFeature: ({ ffmpegExecutable, feature, isLambda, }: {
23
36
  ffmpegExecutable: string | null;
24
37
  feature: "enable-gpl" | "enable-libx265" | "enable-libvpx";
@@ -35,11 +48,11 @@ export declare const RenderInternals: {
35
48
  }) => Promise<string>;
36
49
  serveStatic: (path: string | null, options: {
37
50
  port: number | null;
38
- ffmpegExecutable: import("remotion").FfmpegExecutable;
39
- ffprobeExecutable: import("remotion").FfmpegExecutable;
40
- downloadDir: string;
51
+ ffmpegExecutable: import("./ffmpeg-executable").FfmpegExecutable;
52
+ ffprobeExecutable: import("./ffmpeg-executable").FfmpegExecutable;
41
53
  onDownload: import("./assets/download-and-map-assets-to-file").RenderMediaOnDownload;
42
54
  onError: (err: Error) => void;
55
+ downloadMap: import("./assets/download-map").DownloadMap;
43
56
  }) => Promise<{
44
57
  port: number;
45
58
  close: () => Promise<void>;
@@ -60,7 +73,7 @@ export declare const RenderInternals: {
60
73
  deleteDirectory: (directory: string) => Promise<void>;
61
74
  isServeUrl: (potentialUrl: string) => boolean;
62
75
  ensureOutputDirectory: (outputLocation: string) => void;
63
- getRealFrameRange: (durationInFrames: number, frameRange: import("remotion").FrameRange | null) => [number, number];
76
+ getRealFrameRange: (durationInFrames: number, frameRange: import("./frame-range").FrameRange | null) => [number, number];
64
77
  validatePuppeteerTimeout: (timeoutInMilliseconds: unknown) => void;
65
78
  downloadFile: ({ onProgress, url, to: toFn, }: {
66
79
  url: string;
@@ -80,7 +93,7 @@ export declare const RenderInternals: {
80
93
  symbolicateError: (symbolicateableError: SymbolicateableError) => Promise<import("./error-handling/handle-javascript-exception").ErrorWithStackFrame>;
81
94
  SymbolicateableError: typeof SymbolicateableError;
82
95
  getFramesToRender: (frameRange: [number, number], everyNthFrame: number) => number[];
83
- getExtensionOfFilename: (filename: string) => string | null;
96
+ getExtensionOfFilename: (filename: string | null) => string | null;
84
97
  getDesiredPort: (desiredPort: number | undefined, from: number, to: number) => Promise<number>;
85
98
  isPathInside: (thePath: string, potentialParent: string) => boolean;
86
99
  execa: {
@@ -107,4 +120,30 @@ export declare const RenderInternals: {
107
120
  mimeContentType: typeof mimeContentType;
108
121
  mimeLookup: typeof mimeLookup;
109
122
  validateConcurrency: (value: unknown, setting: string) => void;
123
+ validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
124
+ DEFAULT_BROWSER: import("./browser").Browser;
125
+ validateFrameRange: (frameRange: import("./frame-range").FrameRange | null) => void;
126
+ DEFAULT_OPENGL_RENDERER: "angle" | "swangle" | "egl" | "swiftshader" | null;
127
+ validateOpenGlRenderer: (option: "angle" | "swangle" | "egl" | "swiftshader" | null) => "angle" | "swangle" | "egl" | "swiftshader" | null;
128
+ getDefaultCrfForCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => number;
129
+ validateSelectedCrfAndCodecCombination: (crf: unknown, codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
130
+ validImageFormats: readonly ["png", "jpeg", "none"];
131
+ validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
132
+ DEFAULT_OVERWRITE: boolean;
133
+ DEFAULT_PIXEL_FORMAT: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le";
134
+ validateQuality: (q: number | undefined) => void;
135
+ validateFrame: (frame: number, durationInFrames: number) => void;
136
+ DEFAULT_TIMEOUT: number;
137
+ getValidCrfRanges: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => [number, number];
138
+ validateSelectedPixelFormatAndCodecCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif") => void;
139
+ validateSelectedCodecAndProResCombination: (actualCodec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif", actualProResProfile: "proxy" | "4444-xq" | "4444" | "hq" | "standard" | "light" | undefined) => void;
140
+ validateSelectedPixelFormatAndImageFormatCombination: (pixelFormat: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le", imageFormat: "jpeg" | "png" | "none") => "none" | "valid";
141
+ DEFAULT_CODEC: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif";
142
+ isAudioCodec: (codec: "h264" | "h265" | "vp8" | "vp9" | "mp3" | "aac" | "wav" | "prores" | "h264-mkv" | "gif" | undefined) => boolean;
143
+ logLevels: readonly ["verbose", "info", "warn", "error"];
144
+ isEqualOrBelowLogLevel: (currentLevel: "error" | "verbose" | "info" | "warn", level: "error" | "verbose" | "info" | "warn") => boolean;
145
+ isValidLogLevel: (level: string) => boolean;
146
+ validateEveryNthFrame: (everyNthFrame: unknown) => void;
147
+ perf: typeof perf;
148
+ makeDownloadMap: () => import("./assets/download-map").DownloadMap;
110
149
  };
package/dist/index.js CHANGED
@@ -1,17 +1,46 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RenderInternals = exports.stitchFramesToVideo = exports.renderStill = exports.renderMedia = exports.renderFrames = exports.openBrowser = exports.makeCancelSignal = exports.getCompositions = exports.ErrorWithStackFrame = exports.combineVideos = void 0;
29
+ exports.RenderInternals = exports.stitchFramesToVideo = exports.renderStill = exports.renderMedia = exports.renderFrames = exports.openBrowser = exports.makeCancelSignal = exports.validImageFormats = exports.validateSelectedPixelFormatAndImageFormatCombination = exports.getCompositions = exports.ErrorWithStackFrame = exports.combineVideos = void 0;
7
30
  const execa_1 = __importDefault(require("execa"));
8
31
  const download_file_1 = require("./assets/download-file");
32
+ const download_map_1 = require("./assets/download-map");
33
+ const browser_1 = require("./browser");
34
+ const TimeoutSettings_1 = require("./browser/TimeoutSettings");
9
35
  const can_use_parallel_encoding_1 = require("./can-use-parallel-encoding");
36
+ const codec_1 = require("./codec");
37
+ const crf_1 = require("./crf");
10
38
  const delete_directory_1 = require("./delete-directory");
11
39
  const ensure_output_directory_1 = require("./ensure-output-directory");
12
40
  const symbolicate_error_1 = require("./error-handling/symbolicate-error");
13
41
  const symbolicateable_error_1 = require("./error-handling/symbolicateable-error");
14
42
  const ffmpeg_flags_1 = require("./ffmpeg-flags");
43
+ const frame_range_1 = require("./frame-range");
15
44
  const get_concurrency_1 = require("./get-concurrency");
16
45
  const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range");
17
46
  const get_extension_from_codec_1 = require("./get-extension-from-codec");
@@ -19,18 +48,29 @@ const get_extension_of_filename_1 = require("./get-extension-of-filename");
19
48
  const get_frame_to_render_1 = require("./get-frame-to-render");
20
49
  const get_local_browser_executable_1 = require("./get-local-browser-executable");
21
50
  const get_port_1 = require("./get-port");
51
+ const image_format_1 = require("./image-format");
52
+ const is_audio_codec_1 = require("./is-audio-codec");
22
53
  const is_serve_url_1 = require("./is-serve-url");
54
+ const log_level_1 = require("./log-level");
23
55
  const mime_types_1 = require("./mime-types");
24
56
  const normalize_serve_url_1 = require("./normalize-serve-url");
25
57
  const open_browser_1 = require("./open-browser");
58
+ const overwrite_1 = require("./overwrite");
26
59
  const parse_browser_error_stack_1 = require("./parse-browser-error-stack");
60
+ const perf = __importStar(require("./perf"));
61
+ const pixel_format_1 = require("./pixel-format");
62
+ const prores_profile_1 = require("./prores-profile");
63
+ const quality_1 = require("./quality");
27
64
  const is_path_inside_1 = require("./serve-handler/is-path-inside");
28
65
  const serve_static_1 = require("./serve-static");
29
66
  const stitch_frames_to_video_1 = require("./stitch-frames-to-video");
30
67
  const tmp_dir_1 = require("./tmp-dir");
31
68
  const validate_concurrency_1 = require("./validate-concurrency");
32
69
  const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
70
+ const validate_every_nth_frame_1 = require("./validate-every-nth-frame");
33
71
  const validate_ffmpeg_1 = require("./validate-ffmpeg");
72
+ const validate_frame_1 = require("./validate-frame");
73
+ const validate_opengl_renderer_1 = require("./validate-opengl-renderer");
34
74
  const validate_puppeteer_timeout_1 = require("./validate-puppeteer-timeout");
35
75
  const validate_scale_1 = require("./validate-scale");
36
76
  const wait_for_symbolication_error_to_be_done_1 = require("./wait-for-symbolication-error-to-be-done");
@@ -40,6 +80,9 @@ var handle_javascript_exception_1 = require("./error-handling/handle-javascript-
40
80
  Object.defineProperty(exports, "ErrorWithStackFrame", { enumerable: true, get: function () { return handle_javascript_exception_1.ErrorWithStackFrame; } });
41
81
  var get_compositions_1 = require("./get-compositions");
42
82
  Object.defineProperty(exports, "getCompositions", { enumerable: true, get: function () { return get_compositions_1.getCompositions; } });
83
+ var image_format_2 = require("./image-format");
84
+ Object.defineProperty(exports, "validateSelectedPixelFormatAndImageFormatCombination", { enumerable: true, get: function () { return image_format_2.validateSelectedPixelFormatAndImageFormatCombination; } });
85
+ Object.defineProperty(exports, "validImageFormats", { enumerable: true, get: function () { return image_format_2.validImageFormats; } });
43
86
  var make_cancel_signal_1 = require("./make-cancel-signal");
44
87
  Object.defineProperty(exports, "makeCancelSignal", { enumerable: true, get: function () { return make_cancel_signal_1.makeCancelSignal; } });
45
88
  var open_browser_2 = require("./open-browser");
@@ -88,4 +131,30 @@ exports.RenderInternals = {
88
131
  mimeContentType: mime_types_1.mimeContentType,
89
132
  mimeLookup: mime_types_1.mimeLookup,
90
133
  validateConcurrency: validate_concurrency_1.validateConcurrency,
134
+ validPixelFormats: pixel_format_1.validPixelFormats,
135
+ DEFAULT_BROWSER: browser_1.DEFAULT_BROWSER,
136
+ validateFrameRange: frame_range_1.validateFrameRange,
137
+ DEFAULT_OPENGL_RENDERER: validate_opengl_renderer_1.DEFAULT_OPENGL_RENDERER,
138
+ validateOpenGlRenderer: validate_opengl_renderer_1.validateOpenGlRenderer,
139
+ getDefaultCrfForCodec: crf_1.getDefaultCrfForCodec,
140
+ validateSelectedCrfAndCodecCombination: crf_1.validateSelectedCrfAndCodecCombination,
141
+ validImageFormats: image_format_1.validImageFormats,
142
+ validCodecs: codec_1.validCodecs,
143
+ DEFAULT_OVERWRITE: overwrite_1.DEFAULT_OVERWRITE,
144
+ DEFAULT_PIXEL_FORMAT: pixel_format_1.DEFAULT_PIXEL_FORMAT,
145
+ validateQuality: quality_1.validateQuality,
146
+ validateFrame: validate_frame_1.validateFrame,
147
+ DEFAULT_TIMEOUT: TimeoutSettings_1.DEFAULT_TIMEOUT,
148
+ getValidCrfRanges: crf_1.getValidCrfRanges,
149
+ validateSelectedPixelFormatAndCodecCombination: pixel_format_1.validateSelectedPixelFormatAndCodecCombination,
150
+ validateSelectedCodecAndProResCombination: prores_profile_1.validateSelectedCodecAndProResCombination,
151
+ validateSelectedPixelFormatAndImageFormatCombination: image_format_1.validateSelectedPixelFormatAndImageFormatCombination,
152
+ DEFAULT_CODEC: codec_1.DEFAULT_CODEC,
153
+ isAudioCodec: is_audio_codec_1.isAudioCodec,
154
+ logLevels: log_level_1.logLevels,
155
+ isEqualOrBelowLogLevel: log_level_1.isEqualOrBelowLogLevel,
156
+ isValidLogLevel: log_level_1.isValidLogLevel,
157
+ validateEveryNthFrame: validate_every_nth_frame_1.validateEveryNthFrame,
158
+ perf,
159
+ makeDownloadMap: download_map_1.makeDownloadMap,
91
160
  };
@@ -0,0 +1,2 @@
1
+ import type { Codec } from './codec';
2
+ export declare const isAudioCodec: (codec: Codec | undefined) => boolean;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAudioCodec = void 0;
4
+ const isAudioCodec = (codec) => {
5
+ return codec === 'mp3' || codec === 'aac' || codec === 'wav';
6
+ };
7
+ exports.isAudioCodec = isAudioCodec;
@@ -1,2 +1,3 @@
1
- export declare const isBeyondLastFrame: (src: string, time: number) => boolean | 0;
2
- export declare const markAsBeyondLastFrame: (src: string, time: number) => void;
1
+ import type { DownloadMap } from './assets/download-map';
2
+ export declare const isBeyondLastFrame: (downloadMap: DownloadMap, src: string, time: number) => boolean | 0;
3
+ export declare const markAsBeyondLastFrame: (downloadMap: DownloadMap, src: string, time: number) => void;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.markAsBeyondLastFrame = exports.isBeyondLastFrame = void 0;
4
- const map = {};
5
- const isBeyondLastFrame = (src, time) => {
6
- return map[src] && time >= map[src];
4
+ const isBeyondLastFrame = (downloadMap, src, time) => {
5
+ return (downloadMap.isBeyondLastFrameMap[src] &&
6
+ time >= downloadMap.isBeyondLastFrameMap[src]);
7
7
  };
8
8
  exports.isBeyondLastFrame = isBeyondLastFrame;
9
- const markAsBeyondLastFrame = (src, time) => {
10
- map[src] = time;
9
+ const markAsBeyondLastFrame = (downloadMap, src, time) => {
10
+ downloadMap.isBeyondLastFrameMap[src] = time;
11
11
  };
12
12
  exports.markAsBeyondLastFrame = markAsBeyondLastFrame;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
- import type { FfmpegExecutable, OffthreadVideoImageFormat } from 'remotion';
3
- import type { SpecialVCodecForTransparency } from './get-video-info';
2
+ import type { OffthreadVideoImageFormat } from 'remotion';
3
+ import type { DownloadMap, SpecialVCodecForTransparency } from './assets/download-map';
4
+ import type { FfmpegExecutable } from './ffmpeg-executable';
4
5
  export declare type LastFrameOptions = {
5
6
  ffmpegExecutable: FfmpegExecutable;
6
7
  ffprobeExecutable: FfmpegExecutable;
@@ -9,7 +10,8 @@ export declare type LastFrameOptions = {
9
10
  specialVCodecForTransparency: SpecialVCodecForTransparency;
10
11
  imageFormat: OffthreadVideoImageFormat;
11
12
  needsResize: [number, number] | null;
13
+ downloadMap: DownloadMap;
12
14
  };
13
15
  export declare const setLastFrameInCache: (options: LastFrameOptions, data: Buffer) => void;
14
16
  export declare const getLastFrameFromCache: (options: LastFrameOptions) => Buffer | null;
15
- export declare const clearLastFileCache: () => void;
17
+ export declare const clearLastFileCache: (downloadMap: DownloadMap) => void;
@@ -2,7 +2,6 @@
2
2
  // OffthreadVideo requires sometimes that the last frame of a video gets extracted, however, this can be slow. We allocate a cache for it but that can be garbage collected
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearLastFileCache = exports.getLastFrameFromCache = exports.setLastFrameInCache = void 0;
5
- let map = {};
6
5
  const MAX_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
7
6
  let bufferSize = 0;
8
7
  const makeLastFrameCacheKey = (options) => {
@@ -11,45 +10,46 @@ const makeLastFrameCacheKey = (options) => {
11
10
  options.offset,
12
11
  options.src,
13
12
  options.imageFormat,
13
+ options.downloadMap.id,
14
14
  ].join('-');
15
15
  };
16
16
  const setLastFrameInCache = (options, data) => {
17
17
  const key = makeLastFrameCacheKey(options);
18
- if (map[key]) {
19
- bufferSize -= map[key].data.byteLength;
18
+ if (options.downloadMap.lastFrameMap[key]) {
19
+ bufferSize -= options.downloadMap.lastFrameMap[key].data.byteLength;
20
20
  }
21
- map[key] = { data, lastAccessed: Date.now() };
21
+ options.downloadMap.lastFrameMap[key] = { data, lastAccessed: Date.now() };
22
22
  bufferSize += data.byteLength;
23
- ensureMaxSize();
23
+ ensureMaxSize(options.downloadMap);
24
24
  };
25
25
  exports.setLastFrameInCache = setLastFrameInCache;
26
26
  const getLastFrameFromCache = (options) => {
27
27
  var _a;
28
28
  const key = makeLastFrameCacheKey(options);
29
- if (!map[key]) {
29
+ if (!options.downloadMap.lastFrameMap[key]) {
30
30
  return null;
31
31
  }
32
- map[key].lastAccessed = Date.now();
33
- return (_a = map[key].data) !== null && _a !== void 0 ? _a : null;
32
+ options.downloadMap.lastFrameMap[key].lastAccessed = Date.now();
33
+ return (_a = options.downloadMap.lastFrameMap[key].data) !== null && _a !== void 0 ? _a : null;
34
34
  };
35
35
  exports.getLastFrameFromCache = getLastFrameFromCache;
36
- const removedLastFrameFromCache = (key) => {
37
- if (!map[key]) {
36
+ const removedLastFrameFromCache = (key, downloadMap) => {
37
+ if (!downloadMap.lastFrameMap[key]) {
38
38
  return;
39
39
  }
40
- bufferSize -= map[key].data.byteLength;
41
- delete map[key];
40
+ bufferSize -= downloadMap.lastFrameMap[key].data.byteLength;
41
+ delete downloadMap.lastFrameMap[key];
42
42
  };
43
- const ensureMaxSize = () => {
43
+ const ensureMaxSize = (downloadMap) => {
44
44
  // eslint-disable-next-line no-unmodified-loop-condition
45
45
  while (bufferSize > MAX_CACHE_SIZE) {
46
- const earliest = Object.entries(map).sort((a, b) => {
46
+ const earliest = Object.entries(downloadMap.lastFrameMap).sort((a, b) => {
47
47
  return a[1].lastAccessed - b[1].lastAccessed;
48
48
  })[0];
49
- removedLastFrameFromCache(earliest[0]);
49
+ removedLastFrameFromCache(earliest[0], downloadMap);
50
50
  }
51
51
  };
52
- const clearLastFileCache = () => {
53
- map = {};
52
+ const clearLastFileCache = (downloadMap) => {
53
+ downloadMap.lastFrameMap = {};
54
54
  };
55
55
  exports.clearLastFileCache = clearLastFileCache;
@@ -0,0 +1,4 @@
1
+ export declare const logLevels: readonly ["verbose", "info", "warn", "error"];
2
+ export declare type LogLevel = typeof logLevels[number];
3
+ export declare const isValidLogLevel: (level: string) => boolean;
4
+ export declare const isEqualOrBelowLogLevel: (currentLevel: LogLevel, level: LogLevel) => boolean;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEqualOrBelowLogLevel = exports.isValidLogLevel = exports.logLevels = void 0;
4
+ exports.logLevels = ['verbose', 'info', 'warn', 'error'];
5
+ const getNumberForLogLevel = (level) => {
6
+ return exports.logLevels.indexOf(level);
7
+ };
8
+ const isValidLogLevel = (level) => {
9
+ return getNumberForLogLevel(level) > -1;
10
+ };
11
+ exports.isValidLogLevel = isValidLogLevel;
12
+ const isEqualOrBelowLogLevel = (currentLevel, level) => {
13
+ return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
14
+ };
15
+ exports.isEqualOrBelowLogLevel = isEqualOrBelowLogLevel;
@@ -1,4 +1,4 @@
1
- import type { FfmpegExecutable } from 'remotion';
1
+ import type { FfmpegExecutable } from './ffmpeg-executable';
2
2
  declare type Options = {
3
3
  ffmpegExecutable: FfmpegExecutable;
4
4
  files: string[];
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.mergeAudioTrack = void 0;
7
7
  const execa_1 = __importDefault(require("execa"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const remotion_1 = require("remotion");
10
9
  const chunk_1 = require("./chunk");
11
10
  const convert_to_pcm_1 = require("./convert-to-pcm");
12
11
  const create_ffmpeg_complex_filter_1 = require("./create-ffmpeg-complex-filter");
@@ -14,6 +13,7 @@ const create_silent_audio_1 = require("./create-silent-audio");
14
13
  const delete_directory_1 = require("./delete-directory");
15
14
  const p_limit_1 = require("./p-limit");
16
15
  const tmp_dir_1 = require("./tmp-dir");
16
+ const truthy_1 = require("./truthy");
17
17
  const mergeAudioTrackUnlimited = async ({ ffmpegExecutable, outName, files, numberOfSeconds, }) => {
18
18
  if (files.length === 0) {
19
19
  await (0, create_silent_audio_1.createSilentAudio)({
@@ -62,7 +62,7 @@ const mergeAudioTrackUnlimited = async ({ ffmpegExecutable, outName, files, numb
62
62
  ['-map', '[a]'],
63
63
  ['-y', outName],
64
64
  ]
65
- .filter(remotion_1.Internals.truthy)
65
+ .filter(truthy_1.truthy)
66
66
  .flat(2);
67
67
  const task = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', args);
68
68
  await task;
@@ -1,15 +1,17 @@
1
1
  import type { RequestListener } from 'http';
2
- import type { FfmpegExecutable, OffthreadVideoImageFormat } from 'remotion';
2
+ import type { OffthreadVideoImageFormat } from 'remotion';
3
3
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
4
+ import type { DownloadMap } from './assets/download-map';
5
+ import type { FfmpegExecutable } from './ffmpeg-executable';
4
6
  export declare const extractUrlAndSourceFromUrl: (url: string) => {
5
7
  src: string;
6
8
  time: number;
7
9
  imageFormat: OffthreadVideoImageFormat;
8
10
  };
9
- export declare const startOffthreadVideoServer: ({ ffmpegExecutable, ffprobeExecutable, downloadDir, onDownload, onError, }: {
11
+ export declare const startOffthreadVideoServer: ({ ffmpegExecutable, ffprobeExecutable, onDownload, onError, downloadMap, }: {
10
12
  ffmpegExecutable: FfmpegExecutable;
11
13
  ffprobeExecutable: FfmpegExecutable;
12
- downloadDir: string;
13
14
  onDownload: RenderMediaOnDownload;
14
15
  onError: (err: Error) => void;
16
+ downloadMap: DownloadMap;
15
17
  }) => RequestListener;
@@ -32,7 +32,7 @@ const extractUrlAndSourceFromUrl = (url) => {
32
32
  };
33
33
  };
34
34
  exports.extractUrlAndSourceFromUrl = extractUrlAndSourceFromUrl;
35
- const startOffthreadVideoServer = ({ ffmpegExecutable, ffprobeExecutable, downloadDir, onDownload, onError, }) => {
35
+ const startOffthreadVideoServer = ({ ffmpegExecutable, ffprobeExecutable, onDownload, onError, downloadMap, }) => {
36
36
  return (req, res) => {
37
37
  if (!req.url) {
38
38
  throw new Error('Request came in without URL');
@@ -45,7 +45,7 @@ const startOffthreadVideoServer = ({ ffmpegExecutable, ffprobeExecutable, downlo
45
45
  const { src, time, imageFormat } = (0, exports.extractUrlAndSourceFromUrl)(req.url);
46
46
  res.setHeader('access-control-allow-origin', '*');
47
47
  res.setHeader('content-type', `image/${imageFormat === 'jpeg' ? 'jpg' : 'png'}`);
48
- (0, download_and_map_assets_to_file_1.downloadAsset)({ src, downloadDir, onDownload })
48
+ (0, download_and_map_assets_to_file_1.downloadAsset)({ src, onDownload, downloadMap })
49
49
  .then((to) => {
50
50
  return (0, extract_frame_from_video_1.extractFrameFromVideo)({
51
51
  time,
@@ -53,6 +53,7 @@ const startOffthreadVideoServer = ({ ffmpegExecutable, ffprobeExecutable, downlo
53
53
  ffmpegExecutable,
54
54
  ffprobeExecutable,
55
55
  imageFormat,
56
+ downloadMap,
56
57
  });
57
58
  })
58
59
  .then((readable) => {
@@ -1,4 +1,4 @@
1
- import type { Browser } from 'remotion';
1
+ import type { Browser } from './browser';
2
2
  import type { Browser as PuppeteerBrowser } from './browser/Browser';
3
3
  import type { Viewport } from './browser/PuppeteerViewport';
4
4
  declare const validRenderers: readonly ["swangle", "angle", "egl", "swiftshader"];
@@ -7,13 +7,13 @@ exports.openBrowser = exports.killAllBrowsers = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const remotion_1 = require("remotion");
11
10
  const node_1 = require("./browser/node");
12
11
  const get_local_browser_executable_1 = require("./get-local-browser-executable");
12
+ const validate_opengl_renderer_1 = require("./validate-opengl-renderer");
13
13
  const validRenderers = ['swangle', 'angle', 'egl', 'swiftshader'];
14
14
  const getOpenGlRenderer = (option) => {
15
- const renderer = option !== null && option !== void 0 ? option : remotion_1.Internals.DEFAULT_OPENGL_RENDERER;
16
- remotion_1.Internals.validateOpenGlRenderer(renderer);
15
+ const renderer = option !== null && option !== void 0 ? option : validate_opengl_renderer_1.DEFAULT_OPENGL_RENDERER;
16
+ (0, validate_opengl_renderer_1.validateOpenGlRenderer)(renderer);
17
17
  if (renderer === 'swangle') {
18
18
  return [`--use-gl=angle`, `--use-angle=swiftshader`];
19
19
  }
@@ -34,7 +34,7 @@ const killAllBrowsers = async () => {
34
34
  exports.killAllBrowsers = killAllBrowsers;
35
35
  const openBrowser = async (browser, options) => {
36
36
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
37
- if (browser === 'firefox' && !remotion_1.Internals.FEATURE_FLAG_FIREFOX_SUPPORT) {
37
+ if (browser === 'firefox') {
38
38
  throw new TypeError('Firefox supported is not yet turned on. Stay tuned for the future.');
39
39
  }
40
40
  await (0, get_local_browser_executable_1.ensureLocalBrowser)(browser, (_a = options === null || options === void 0 ? void 0 : options.browserExecutable) !== null && _a !== void 0 ? _a : null);
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_OVERWRITE = true;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_OVERWRITE = void 0;
4
+ exports.DEFAULT_OVERWRITE = true;
package/dist/perf.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ declare type PerfId = 'activate-target' | 'capture' | 'save' | 'extract-frame' | 'piping';
2
+ export declare const startPerfMeasure: (marker: PerfId) => number;
3
+ export declare const stopPerfMeasure: (id: number) => void;
4
+ export declare const logPerf: () => void;
5
+ export {};
package/dist/perf.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logPerf = exports.stopPerfMeasure = exports.startPerfMeasure = void 0;
4
+ const perf = {
5
+ 'activate-target': [],
6
+ capture: [],
7
+ save: [],
8
+ 'extract-frame': [],
9
+ piping: [],
10
+ };
11
+ const map = {};
12
+ const startPerfMeasure = (marker) => {
13
+ const id = Math.random();
14
+ map[id] = {
15
+ id,
16
+ marker,
17
+ start: Date.now(),
18
+ };
19
+ return id;
20
+ };
21
+ exports.startPerfMeasure = startPerfMeasure;
22
+ const stopPerfMeasure = (id) => {
23
+ const now = Date.now();
24
+ const diff = now - map[id].start;
25
+ perf[map[id].marker].push(diff);
26
+ delete map[id];
27
+ };
28
+ exports.stopPerfMeasure = stopPerfMeasure;
29
+ const logPerf = () => {
30
+ console.log('Render performance:');
31
+ Object.keys(perf).forEach((p) => {
32
+ console.log(` ${p} => ${perf[p].reduce((a, b) => a + b, 0) / perf[p].length} (n = ${perf[p].length})`);
33
+ });
34
+ };
35
+ exports.logPerf = logPerf;
@@ -0,0 +1,5 @@
1
+ import type { Codec } from './codec';
2
+ export declare const validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
3
+ export declare type PixelFormat = typeof validPixelFormats[number];
4
+ export declare const DEFAULT_PIXEL_FORMAT: PixelFormat;
5
+ export declare const validateSelectedPixelFormatAndCodecCombination: (pixelFormat: PixelFormat, codec: Codec) => void;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateSelectedPixelFormatAndCodecCombination = exports.DEFAULT_PIXEL_FORMAT = exports.validPixelFormats = void 0;
4
+ exports.validPixelFormats = [
5
+ 'yuv420p',
6
+ 'yuva420p',
7
+ 'yuv422p',
8
+ 'yuv444p',
9
+ 'yuv420p10le',
10
+ 'yuv422p10le',
11
+ 'yuv444p10le',
12
+ 'yuva444p10le',
13
+ ];
14
+ exports.DEFAULT_PIXEL_FORMAT = 'yuv420p';
15
+ const validateSelectedPixelFormatAndCodecCombination = (pixelFormat, codec) => {
16
+ if (!exports.validPixelFormats.includes(pixelFormat)) {
17
+ throw new TypeError(`Value ${pixelFormat} is not valid as a pixel format.`);
18
+ }
19
+ if (pixelFormat !== 'yuva420p') {
20
+ return;
21
+ }
22
+ if (codec !== 'vp8' && codec !== 'vp9') {
23
+ throw new TypeError("Pixel format was set to 'yuva420p' but codec is not 'vp8' or 'vp9'. To render videos with alpha channel, you must choose a codec that supports it.");
24
+ }
25
+ };
26
+ exports.validateSelectedPixelFormatAndCodecCombination = validateSelectedPixelFormatAndCodecCombination;
@@ -1,13 +1,14 @@
1
- import type { FfmpegExecutable } from 'remotion';
2
1
  import type { RenderMediaOnDownload } from './assets/download-and-map-assets-to-file';
3
- export declare const prepareServer: ({ downloadDir, ffmpegExecutable, ffprobeExecutable, onDownload, onError, webpackConfigOrServeUrl, port, }: {
2
+ import type { DownloadMap } from './assets/download-map';
3
+ import type { FfmpegExecutable } from './ffmpeg-executable';
4
+ export declare const prepareServer: ({ ffmpegExecutable, ffprobeExecutable, onDownload, onError, webpackConfigOrServeUrl, port, downloadMap, }: {
4
5
  webpackConfigOrServeUrl: string;
5
- downloadDir: string;
6
6
  onDownload: RenderMediaOnDownload;
7
7
  onError: (err: Error) => void;
8
8
  ffmpegExecutable: FfmpegExecutable;
9
9
  ffprobeExecutable: FfmpegExecutable;
10
10
  port: number | null;
11
+ downloadMap: DownloadMap;
11
12
  }) => Promise<{
12
13
  serveUrl: string;
13
14
  closeServer: () => Promise<unknown>;