@remotion/renderer 3.0.31 → 3.1.0

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 (93) hide show
  1. package/dist/browser/NetworkManager.js +1 -5
  2. package/dist/combine-videos.d.ts +2 -1
  3. package/dist/combine-videos.js +8 -2
  4. package/dist/convert-number-of-gif-loops-to-ffmpeg.d.ts +1 -0
  5. package/dist/convert-number-of-gif-loops-to-ffmpeg.js +17 -0
  6. package/dist/ensure-frames-in-order.d.ts +1 -1
  7. package/dist/ensure-frames-in-order.js +3 -2
  8. package/dist/ensure-presentation-timestamp.d.ts +1 -1
  9. package/dist/ensure-presentation-timestamp.js +9 -10
  10. package/dist/extract-frame-from-video.js +4 -2
  11. package/dist/get-codec-name.js +3 -0
  12. package/dist/get-duration-from-frame-range.d.ts +1 -2
  13. package/dist/get-duration-from-frame-range.js +13 -9
  14. package/dist/get-extension-from-codec.d.ts +1 -1
  15. package/dist/get-extension-from-codec.js +5 -0
  16. package/dist/index.d.ts +4 -3
  17. package/dist/index.js +3 -1
  18. package/dist/mime-types.d.ts +1 -1
  19. package/dist/mime-types.js +2 -2
  20. package/dist/prespawn-ffmpeg.js +2 -2
  21. package/dist/render-frames.d.ts +1 -0
  22. package/dist/render-frames.js +12 -16
  23. package/dist/render-media.d.ts +2 -0
  24. package/dist/render-media.js +11 -4
  25. package/dist/render-still.js +1 -1
  26. package/dist/stitch-frames-to-video.d.ts +1 -0
  27. package/dist/stitch-frames-to-video.js +32 -22
  28. package/dist/validate-output-filename.js +5 -0
  29. package/package.json +8 -10
  30. package/tsconfig.json +2 -1
  31. package/vitest.config.ts +8 -0
  32. package/dist/abort.d.ts +0 -7
  33. package/dist/abort.js +0 -20
  34. package/dist/assets/cleanup-assets.d.ts +0 -2
  35. package/dist/assets/cleanup-assets.js +0 -2
  36. package/dist/browser/ConnectionTransport.d.ts +0 -21
  37. package/dist/browser/ConnectionTransport.js +0 -17
  38. package/dist/browser/EmulationManager.d.ts +0 -7
  39. package/dist/browser/EmulationManager.js +0 -40
  40. package/dist/browser/Page.d.ts +0 -74
  41. package/dist/browser/Page.js +0 -283
  42. package/dist/browser/compat.d.ts +0 -2
  43. package/dist/browser/compat.js +0 -17
  44. package/dist/browser/environment.d.ts +0 -16
  45. package/dist/browser/environment.js +0 -19
  46. package/dist/browser/ws.d.ts +0 -287
  47. package/dist/browser/ws.js +0 -21
  48. package/dist/cancel.d.ts +0 -7
  49. package/dist/cancel.js +0 -25
  50. package/dist/ensure-faststart.d.ts +0 -1
  51. package/dist/ensure-faststart.js +0 -14
  52. package/dist/faststart/atom.d.ts +0 -35
  53. package/dist/faststart/atom.js +0 -138
  54. package/dist/faststart/index.d.ts +0 -0
  55. package/dist/faststart/index.js +0 -1
  56. package/dist/faststart/options.d.ts +0 -6
  57. package/dist/faststart/options.js +0 -2
  58. package/dist/faststart/qt-faststart.d.ts +0 -18
  59. package/dist/faststart/qt-faststart.js +0 -66
  60. package/dist/faststart/update-chunk-offsets.d.ts +0 -10
  61. package/dist/faststart/update-chunk-offsets.js +0 -114
  62. package/dist/faststart/util.d.ts +0 -9
  63. package/dist/faststart/util.js +0 -34
  64. package/dist/get-duration-of-asset.d.ts +0 -7
  65. package/dist/get-duration-of-asset.js +0 -36
  66. package/dist/is-vp9-video.d.ts +0 -3
  67. package/dist/is-vp9-video.js +0 -24
  68. package/dist/offthread/index.d.ts +0 -0
  69. package/dist/offthread/index.js +0 -1
  70. package/dist/render-gif.d.ts +0 -2
  71. package/dist/render-gif.js +0 -242
  72. package/dist/serve-handler/glob-slash.d.ts +0 -1
  73. package/dist/serve-handler/glob-slash.js +0 -12
  74. package/dist/should-use-vp9-decoder.d.ts +0 -0
  75. package/dist/should-use-vp9-decoder.js +0 -1
  76. package/dist/stitch-frames-to-gif.d.ts +0 -8
  77. package/dist/stitch-frames-to-gif.js +0 -128
  78. package/dist/validate-fps-for-gif.d.ts +0 -2
  79. package/dist/validate-fps-for-gif.js +0 -9
  80. package/dist/validate-offthreadvideo-image-format.d.ts +0 -1
  81. package/dist/validate-offthreadvideo-image-format.js +0 -15
  82. package/dist/ws/buffer-util.d.ts +0 -10
  83. package/dist/ws/buffer-util.js +0 -123
  84. package/dist/ws/constants.d.ts +0 -10
  85. package/dist/ws/constants.js +0 -13
  86. package/dist/ws/event-target.d.ts +0 -155
  87. package/dist/ws/event-target.js +0 -203
  88. package/dist/ws/extension.d.ts +0 -16
  89. package/dist/ws/extension.js +0 -232
  90. package/dist/ws/limiter.d.ts +0 -34
  91. package/dist/ws/limiter.js +0 -41
  92. package/dist/ws/permessage_deflate.d.ts +0 -152
  93. package/dist/ws/permessage_deflate.js +0 -409
@@ -1,242 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.renderGif = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const os_1 = __importDefault(require("os"));
9
- const path_1 = __importDefault(require("path"));
10
- const remotion_1 = require("remotion");
11
- const can_use_parallel_encoding_1 = require("./can-use-parallel-encoding");
12
- const ensure_frames_in_order_1 = require("./ensure-frames-in-order");
13
- const ensure_output_directory_1 = require("./ensure-output-directory");
14
- const get_duration_from_frame_range_1 = require("./get-duration-from-frame-range");
15
- const get_extension_from_codec_1 = require("./get-extension-from-codec");
16
- const get_extension_of_filename_1 = require("./get-extension-of-filename");
17
- const get_frame_to_render_1 = require("./get-frame-to-render");
18
- const legacy_webpack_config_1 = require("./legacy-webpack-config");
19
- const make_cancel_signal_1 = require("./make-cancel-signal");
20
- const prespawn_ffmpeg_1 = require("./prespawn-ffmpeg");
21
- const render_frames_1 = require("./render-frames");
22
- const stitch_frames_to_gif_1 = require("./stitch-frames-to-gif");
23
- const tmp_dir_1 = require("./tmp-dir");
24
- const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
25
- const validate_output_filename_1 = require("./validate-output-filename");
26
- const validate_scale_1 = require("./validate-scale");
27
- const renderGif = ({ parallelism, proResProfile, crf, composition, imageFormat, ffmpegExecutable, inputProps, pixelFormat, codec, envVariables, quality, frameRange, puppeteerInstance, outputLocation, onProgress, overwrite, onDownload, loop, skipNFrames, dumpBrowserLogs, onBrowserLog, onStart, timeoutInMilliseconds, chromiumOptions, scale, browserExecutable, port, cancelSignal, ...options }) => {
28
- remotion_1.Internals.validateQuality(quality);
29
- if (typeof crf !== 'undefined' && crf !== null) {
30
- remotion_1.Internals.validateSelectedCrfAndCodecCombination(crf, codec);
31
- }
32
- (0, validate_output_filename_1.validateOutputFilename)(codec, (0, get_extension_of_filename_1.getExtensionOfFilename)(outputLocation));
33
- (0, validate_scale_1.validateScale)(scale);
34
- const serveUrl = (0, legacy_webpack_config_1.getServeUrlWithFallback)(options);
35
- let stitchStage = 'encoding';
36
- let stitcherFfmpeg;
37
- let preStitcher = null;
38
- let encodedFrames = 0;
39
- let renderedFrames = 0;
40
- let renderedDoneIn = null;
41
- let encodedDoneIn = null;
42
- let cancelled = false;
43
- const renderStart = Date.now();
44
- const tmpdir = (0, tmp_dir_1.tmpDir)('pre-encode');
45
- const parallelEncoding = (0, can_use_parallel_encoding_1.canUseParallelEncoding)(codec);
46
- const actualImageFormat = imageFormat !== null && imageFormat !== void 0 ? imageFormat : 'jpeg';
47
- const preEncodedFileLocation = parallelEncoding
48
- ? path_1.default.join(tmpdir, 'pre-encode.' + (0, get_extension_from_codec_1.getFileExtensionFromCodec)(codec, 'chunk'))
49
- : null;
50
- const outputDir = parallelEncoding
51
- ? null
52
- : fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), 'react-motion-render'));
53
- (0, validate_even_dimensions_with_codec_1.validateEvenDimensionsWithCodec)({
54
- codec,
55
- height: composition.height,
56
- scale: scale !== null && scale !== void 0 ? scale : 1,
57
- width: composition.width,
58
- });
59
- const callUpdate = () => {
60
- onProgress === null || onProgress === void 0 ? void 0 : onProgress({
61
- encodedDoneIn,
62
- encodedFrames,
63
- renderedDoneIn,
64
- renderedFrames,
65
- stitchStage,
66
- });
67
- };
68
- const realFrameRange = (0, get_frame_to_render_1.getRealFrameRange)(composition.durationInFrames, frameRange !== null && frameRange !== void 0 ? frameRange : null);
69
- const cancelRenderFrames = (0, make_cancel_signal_1.makeCancelSignal)();
70
- const cancelPrestitcher = (0, make_cancel_signal_1.makeCancelSignal)();
71
- const cancelStitcher = (0, make_cancel_signal_1.makeCancelSignal)();
72
- cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
73
- cancelRenderFrames.cancel();
74
- });
75
- const { waitForRightTimeOfFrameToBeInserted, setFrameToStitch, waitForFinish } = (0, ensure_frames_in_order_1.ensureFramesInOrder)(realFrameRange);
76
- const actualGifFps = Math.floor(composition.fps / (skipNFrames + 1));
77
- const createPrestitcherIfNecessary = async () => {
78
- if (preEncodedFileLocation) {
79
- preStitcher = await (0, prespawn_ffmpeg_1.prespawnFfmpeg)({
80
- width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
81
- height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
82
- fps: actualGifFps,
83
- outputLocation: preEncodedFileLocation,
84
- pixelFormat,
85
- codec,
86
- proResProfile,
87
- crf,
88
- onProgress: (frame) => {
89
- encodedFrames = frame;
90
- callUpdate();
91
- },
92
- verbose: remotion_1.Internals.Logging.isEqualOrBelowLogLevel(remotion_1.Internals.Logging.getLogLevel(), 'verbose'),
93
- ffmpegExecutable,
94
- imageFormat: actualImageFormat,
95
- signal: cancelPrestitcher.cancelSignal,
96
- });
97
- stitcherFfmpeg = preStitcher.task;
98
- }
99
- };
100
- const waitForPrestitcherIfNecessary = async () => {
101
- var _a;
102
- if (stitcherFfmpeg) {
103
- await waitForFinish();
104
- (_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.end();
105
- try {
106
- await stitcherFfmpeg;
107
- }
108
- catch (err) {
109
- throw new Error(preStitcher === null || preStitcher === void 0 ? void 0 : preStitcher.getLogs());
110
- }
111
- }
112
- };
113
- const happyPath = createPrestitcherIfNecessary()
114
- .then(() => {
115
- const renderFramesProc = (0, render_frames_1.renderFrames)({
116
- config: composition,
117
- onFrameUpdate: (frame) => {
118
- stitchStage = 'gif';
119
- renderedFrames = frame;
120
- callUpdate();
121
- },
122
- parallelism,
123
- outputDir,
124
- skipNFrames,
125
- onStart: (data) => {
126
- renderedFrames = 0;
127
- callUpdate();
128
- onStart === null || onStart === void 0 ? void 0 : onStart(data);
129
- },
130
- inputProps,
131
- envVariables,
132
- imageFormat: actualImageFormat,
133
- quality,
134
- frameRange: frameRange !== null && frameRange !== void 0 ? frameRange : null,
135
- puppeteerInstance,
136
- onFrameBuffer: parallelEncoding
137
- ? async (buffer, frame) => {
138
- var _a;
139
- await waitForRightTimeOfFrameToBeInserted(frame);
140
- if (cancelled) {
141
- return;
142
- }
143
- (_a = stitcherFfmpeg === null || stitcherFfmpeg === void 0 ? void 0 : stitcherFfmpeg.stdin) === null || _a === void 0 ? void 0 : _a.write(buffer);
144
- setFrameToStitch(frame + 1);
145
- }
146
- : undefined,
147
- serveUrl,
148
- dumpBrowserLogs,
149
- onBrowserLog,
150
- onDownload,
151
- timeoutInMilliseconds,
152
- chromiumOptions,
153
- scale,
154
- ffmpegExecutable,
155
- browserExecutable,
156
- port,
157
- cancelSignal: cancelRenderFrames.cancelSignal,
158
- });
159
- return renderFramesProc;
160
- })
161
- .then((renderFramesReturn) => {
162
- return Promise.all([renderFramesReturn, waitForPrestitcherIfNecessary()]);
163
- })
164
- .then(([{ assetsInfo }]) => {
165
- renderedDoneIn = Date.now() - renderStart;
166
- callUpdate();
167
- (0, ensure_output_directory_1.ensureOutputDirectory)(outputLocation);
168
- const stitchStart = Date.now();
169
- return Promise.all([
170
- (0, stitch_frames_to_gif_1.stitchFramesToGif)({
171
- width: composition.width * (scale !== null && scale !== void 0 ? scale : 1),
172
- height: composition.height * (scale !== null && scale !== void 0 ? scale : 1),
173
- fps: actualGifFps,
174
- outputLocation,
175
- internalOptions: {
176
- preEncodedFileLocation,
177
- imageFormat: actualImageFormat,
178
- },
179
- force: overwrite !== null && overwrite !== void 0 ? overwrite : remotion_1.Internals.DEFAULT_OVERWRITE,
180
- pixelFormat,
181
- codec,
182
- proResProfile,
183
- crf,
184
- loop,
185
- assetsInfo,
186
- ffmpegExecutable,
187
- onProgress: (frame) => {
188
- stitchStage = 'gif';
189
- encodedFrames = frame;
190
- callUpdate();
191
- },
192
- verbose: remotion_1.Internals.Logging.isEqualOrBelowLogLevel(remotion_1.Internals.Logging.getLogLevel(), 'verbose'),
193
- dir: outputDir !== null && outputDir !== void 0 ? outputDir : undefined,
194
- cancelSignal: cancelStitcher.cancelSignal,
195
- }),
196
- stitchStart,
197
- ]);
198
- })
199
- .then(([, stitchStart]) => {
200
- encodedFrames = (0, get_duration_from_frame_range_1.getDurationFromFrameRange)(frameRange !== null && frameRange !== void 0 ? frameRange : null, composition.durationInFrames, skipNFrames);
201
- encodedDoneIn = Date.now() - stitchStart;
202
- callUpdate();
203
- })
204
- .catch((err) => {
205
- /**
206
- * When an error is thrown in renderFrames(...) (e.g., when delayRender() is used incorrectly), fs.unlinkSync(...) throws an error that the file is locked because ffmpeg is still running, and renderMedia returns it.
207
- * Therefore we first kill the FFMPEG process before deleting the file
208
- */
209
- cancelled = true;
210
- cancelRenderFrames.cancel();
211
- cancelStitcher.cancel();
212
- cancelPrestitcher.cancel();
213
- if (stitcherFfmpeg !== undefined && stitcherFfmpeg.exitCode === null) {
214
- const promise = new Promise((resolve) => {
215
- setTimeout(() => {
216
- resolve();
217
- }, 2000);
218
- stitcherFfmpeg.on('close', resolve);
219
- });
220
- stitcherFfmpeg.kill();
221
- return promise.then(() => {
222
- throw err;
223
- });
224
- }
225
- throw err;
226
- })
227
- .finally(() => {
228
- if (preEncodedFileLocation !== null &&
229
- fs_1.default.existsSync(preEncodedFileLocation)) {
230
- fs_1.default.unlinkSync(preEncodedFileLocation);
231
- }
232
- });
233
- return Promise.race([
234
- happyPath,
235
- new Promise((_resolve, reject) => {
236
- cancelSignal === null || cancelSignal === void 0 ? void 0 : cancelSignal(() => {
237
- reject(new Error('renderMedia() got cancelled'));
238
- });
239
- }),
240
- ]);
241
- };
242
- exports.renderGif = renderGif;
@@ -1 +0,0 @@
1
- export declare const slasher: (value: string) => string;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- /* ! The MIT License (MIT) Copyright (c) 2014 Scott Corgan */
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.slasher = void 0;
8
- // This is adopted from https://github.com/scottcorgan/glob-slash/
9
- const path_1 = __importDefault(require("path"));
10
- const normalize = (value) => path_1.default.posix.normalize(path_1.default.posix.join('/', value));
11
- const slasher = (value) => value.charAt(0) === '!' ? `!${normalize(value.substr(1))}` : normalize(value);
12
- exports.slasher = slasher;
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,8 +0,0 @@
1
- import { StitcherOptions } from './stitch-frames-to-video';
2
- declare type ReturnType = {
3
- task: Promise<unknown>;
4
- getLogs: () => string;
5
- };
6
- export declare const spawnFfmpeg: (options: StitcherOptions) => Promise<ReturnType>;
7
- export declare const stitchFramesToGif: (options: StitcherOptions) => Promise<void>;
8
- export {};
@@ -1,128 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.stitchFramesToGif = exports.spawnFfmpeg = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
- const remotion_1 = require("remotion");
11
- const get_codec_name_1 = require("./get-codec-name");
12
- const get_prores_profile_name_1 = require("./get-prores-profile-name");
13
- const parse_ffmpeg_progress_1 = require("./parse-ffmpeg-progress");
14
- const validate_even_dimensions_with_codec_1 = require("./validate-even-dimensions-with-codec");
15
- const validate_ffmpeg_1 = require("./validate-ffmpeg");
16
- const packageJsonPath = path_1.default.join(__dirname, '..', 'package.json');
17
- const packageJson = fs_1.default.existsSync(packageJsonPath)
18
- ? JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf-8'))
19
- : null;
20
- const spawnFfmpeg = async (options) => {
21
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
22
- remotion_1.Internals.validateDimension(options.height, 'height', 'passed to `stitchFramesToVideo()`');
23
- remotion_1.Internals.validateDimension(options.width, 'width', 'passed to `stitchFramesToVideo()`');
24
- remotion_1.Internals.validateFps(options.fps, 'passed to `stitchFramesToVideo()`');
25
- const codec = (_a = options.codec) !== null && _a !== void 0 ? _a : remotion_1.Internals.DEFAULT_CODEC;
26
- (0, validate_even_dimensions_with_codec_1.validateEvenDimensionsWithCodec)({
27
- width: options.width,
28
- height: options.height,
29
- codec,
30
- scale: 1,
31
- });
32
- const crf = (_b = options.crf) !== null && _b !== void 0 ? _b : remotion_1.Internals.getDefaultCrfForCodec(codec);
33
- const pixelFormat = (_c = options.pixelFormat) !== null && _c !== void 0 ? _c : remotion_1.Internals.DEFAULT_PIXEL_FORMAT;
34
- await (0, validate_ffmpeg_1.validateFfmpeg)((_d = options.ffmpegExecutable) !== null && _d !== void 0 ? _d : null);
35
- const encoderName = (0, get_codec_name_1.getCodecName)(codec);
36
- const proResProfileName = (0, get_prores_profile_name_1.getProResProfileName)(codec, options.proResProfile);
37
- const supportsCrf = encoderName && codec !== 'prores';
38
- if (options.verbose) {
39
- console.log('[verbose] ffmpeg', (_e = options.ffmpegExecutable) !== null && _e !== void 0 ? _e : 'ffmpeg in PATH');
40
- console.log('[verbose] encoder', encoderName);
41
- console.log('[verbose] pixelFormat', pixelFormat);
42
- if (supportsCrf) {
43
- console.log('[verbose] crf', crf);
44
- }
45
- console.log('[verbose] codec', codec);
46
- console.log('[verbose] proResProfileName', proResProfileName);
47
- }
48
- remotion_1.Internals.validateSelectedCrfAndCodecCombination(crf, codec);
49
- remotion_1.Internals.validateSelectedPixelFormatAndCodecCombination(pixelFormat, codec);
50
- const expectedFrames = options.assetsInfo.assets.length;
51
- const updateProgress = (preStitchProgress, muxProgress) => {
52
- var _a;
53
- const totalFrameProgress = 0.5 * preStitchProgress * expectedFrames + muxProgress * 0.5;
54
- (_a = options.onProgress) === null || _a === void 0 ? void 0 : _a.call(options, Math.round(totalFrameProgress));
55
- };
56
- const ffmpegArgs = [
57
- ['-r', String(options.fps)],
58
- ...(((_f = options.internalOptions) === null || _f === void 0 ? void 0 : _f.preEncodedFileLocation)
59
- ? [['-i', (_g = options.internalOptions) === null || _g === void 0 ? void 0 : _g.preEncodedFileLocation]]
60
- : [
61
- ['-f', 'image2'],
62
- ['-s', `${options.width}x${options.height}`],
63
- ['-start_number', String(options.assetsInfo.firstFrameIndex)],
64
- ['-i', options.assetsInfo.imageSequenceName],
65
- ]),
66
- // -c:v is the same as -vcodec as -codec:video
67
- // and specified the video codec.
68
- options.loop === null
69
- ? null
70
- : ['-loop', typeof options.loop === 'number' ? options.loop : '-1'],
71
- // Ignore metadata that may come from remote media
72
- ['-map_metadata', '-1'],
73
- [
74
- '-metadata',
75
- `comment=` +
76
- [`Made with Remotion`, packageJson ? packageJson.version : null].join(' '),
77
- ],
78
- options.force ? '-y' : null,
79
- options.outputLocation,
80
- ];
81
- if (options.verbose) {
82
- console.log('Generated FFMPEG command:');
83
- console.log(ffmpegArgs);
84
- }
85
- const ffmpegString = ffmpegArgs.flat(2).filter(Boolean);
86
- const task = (0, execa_1.default)((_h = options.ffmpegExecutable) !== null && _h !== void 0 ? _h : 'ffmpeg', ffmpegString, {
87
- cwd: options.dir,
88
- });
89
- (_j = options.cancelSignal) === null || _j === void 0 ? void 0 : _j.call(options, () => {
90
- task.kill();
91
- });
92
- let ffmpegOutput = '';
93
- let isFinished = false;
94
- (_k = task.stderr) === null || _k === void 0 ? void 0 : _k.on('data', (data) => {
95
- var _a;
96
- const str = data.toString();
97
- ffmpegOutput += str;
98
- if (options.onProgress) {
99
- const parsed = (0, parse_ffmpeg_progress_1.parseFfmpegProgress)(str);
100
- // FFMPEG bug: In some cases, FFMPEG does hang after it is finished with it's job
101
- // Example repo: https://github.com/JonnyBurger/ffmpeg-repro (access can be given upon request)
102
- if (parsed !== undefined) {
103
- // If two times in a row the finishing frame is logged, we quit the render
104
- if (parsed === expectedFrames) {
105
- if (isFinished) {
106
- (_a = task.stdin) === null || _a === void 0 ? void 0 : _a.write('q');
107
- }
108
- else {
109
- isFinished = true;
110
- }
111
- }
112
- updateProgress(1, parsed);
113
- }
114
- }
115
- });
116
- return { task, getLogs: () => ffmpegOutput };
117
- };
118
- exports.spawnFfmpeg = spawnFfmpeg;
119
- const stitchFramesToGif = async (options) => {
120
- const { task, getLogs } = await (0, exports.spawnFfmpeg)(options);
121
- try {
122
- await task;
123
- }
124
- catch (err) {
125
- throw new Error(getLogs());
126
- }
127
- };
128
- exports.stitchFramesToGif = stitchFramesToGif;
@@ -1,2 +0,0 @@
1
- import { Codec } from 'remotion';
2
- export declare const validateFpsForGif: (codec: Codec, fps: number) => void;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateFpsForGif = void 0;
4
- const validateFpsForGif = (codec, fps) => {
5
- if (codec === 'gif' && (fps > 50 || fps < 1)) {
6
- throw new Error(`To render a GIF, the FPS must be less than or equal to 50 and greater than 0 but got ${fps} instead`);
7
- }
8
- };
9
- exports.validateFpsForGif = validateFpsForGif;
@@ -1 +0,0 @@
1
- export declare const validateOffthreadVideoImageFormat: (input: unknown) => void;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateOffthreadVideoImageFormat = void 0;
4
- const validateOffthreadVideoImageFormat = (input) => {
5
- if (typeof input === 'undefined') {
6
- return;
7
- }
8
- if (typeof input !== 'string') {
9
- throw new TypeError(`<OffthreadVideo imageFormat=""> must be a string, but got ${JSON.stringify(input)} instead.`);
10
- }
11
- if (input !== 'png' && input !== 'jpeg') {
12
- throw new TypeError(`<OffthreadVideo imageFormat=""> must be either "png" or "jpeg", but got ${input}`);
13
- }
14
- };
15
- exports.validateOffthreadVideoImageFormat = validateOffthreadVideoImageFormat;
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * Merges an array of buffers into a new buffer.
4
- *
5
- * @param {Buffer[]} list The array of buffers to concat
6
- * @param {Number} totalLength The total length of buffers in the list
7
- * @return {Buffer} The resulting buffer
8
- * @public
9
- */
10
- export declare function concat(list: Buffer[], totalLength: number): Buffer;
@@ -1,123 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.concat = void 0;
4
- const constants_1 = require("./constants");
5
- /**
6
- * Merges an array of buffers into a new buffer.
7
- *
8
- * @param {Buffer[]} list The array of buffers to concat
9
- * @param {Number} totalLength The total length of buffers in the list
10
- * @return {Buffer} The resulting buffer
11
- * @public
12
- */
13
- function concat(list, totalLength) {
14
- if (list.length === 0)
15
- return constants_1.constants.EMPTY_BUFFER;
16
- if (list.length === 1)
17
- return list[0];
18
- const target = Buffer.allocUnsafe(totalLength);
19
- let offset = 0;
20
- for (let i = 0; i < list.length; i++) {
21
- const buf = list[i];
22
- target.set(buf, offset);
23
- offset += buf.length;
24
- }
25
- if (offset < totalLength)
26
- return target.slice(0, offset);
27
- return target;
28
- }
29
- exports.concat = concat;
30
- /**
31
- * Masks a buffer using the given mask.
32
- *
33
- * @param {Buffer} source The buffer to mask
34
- * @param {Buffer} mask The mask to use
35
- * @param {Buffer} output The buffer where to store the result
36
- * @param {Number} offset The offset at which to start writing
37
- * @param {Number} length The number of bytes to mask.
38
- * @public
39
- */
40
- function _mask(source, mask, output, offset, length) {
41
- for (let i = 0; i < length; i++) {
42
- // eslint-disable-next-line no-bitwise
43
- output[offset + i] = source[i] ^ mask[i & 3];
44
- }
45
- }
46
- /**
47
- * Unmasks a buffer using the given mask.
48
- *
49
- * @param {Buffer} buffer The buffer to unmask
50
- * @param {Buffer} mask The mask to use
51
- * @public
52
- */
53
- function _unmask(buffer, mask) {
54
- for (let i = 0; i < buffer.length; i++) {
55
- // eslint-disable-next-line no-bitwise
56
- buffer[i] ^= mask[i & 3];
57
- }
58
- }
59
- /**
60
- * Converts a buffer to an `ArrayBuffer`.
61
- *
62
- * @param {Buffer} buf The buffer to convert
63
- * @return {ArrayBuffer} Converted buffer
64
- * @public
65
- */
66
- function toArrayBuffer(buf) {
67
- if (buf.byteLength === buf.buffer.byteLength) {
68
- return buf.buffer;
69
- }
70
- return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
71
- }
72
- /**
73
- * Converts `data` to a `Buffer`.
74
- *
75
- * @param {*} data The data to convert
76
- * @return {Buffer} The buffer
77
- * @throws {TypeError}
78
- * @public
79
- */
80
- function toBuffer(data) {
81
- toBuffer.readOnly = true;
82
- if (Buffer.isBuffer(data))
83
- return data;
84
- let buf;
85
- if (data instanceof ArrayBuffer) {
86
- buf = Buffer.from(data);
87
- }
88
- else if (ArrayBuffer.isView(data)) {
89
- buf = Buffer.from(data.buffer, data.byteOffset, data.byteLength);
90
- }
91
- else {
92
- buf = Buffer.from(data);
93
- toBuffer.readOnly = false;
94
- }
95
- return buf;
96
- }
97
- module.exports = {
98
- mask: _mask,
99
- toArrayBuffer,
100
- toBuffer,
101
- unmask: _unmask,
102
- };
103
- /* istanbul ignore else */
104
- if (!process.env.WS_NO_BUFFER_UTIL) {
105
- try {
106
- const bufferUtil = require('bufferutil');
107
- module.exports.mask = function (source, mask, output, offset, length) {
108
- if (length < 48)
109
- _mask(source, mask, output, offset, length);
110
- else
111
- bufferUtil.mask(source, mask, output, offset, length);
112
- };
113
- module.exports.unmask = function (buffer, mask) {
114
- if (buffer.length < 32)
115
- _unmask(buffer, mask);
116
- else
117
- bufferUtil.unmask(buffer, mask);
118
- };
119
- }
120
- catch (e) {
121
- // Continue regardless of the error.
122
- }
123
- }
@@ -1,10 +0,0 @@
1
- export declare const constants: {
2
- BINARY_TYPES: string[];
3
- EMPTY_BUFFER: Buffer;
4
- GUID: string;
5
- kForOnEventAttribute: symbol;
6
- kListener: symbol;
7
- kStatusCode: symbol;
8
- kWebSocket: symbol;
9
- NOOP: () => undefined;
10
- };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.constants = void 0;
4
- exports.constants = {
5
- BINARY_TYPES: ['nodebuffer', 'arraybuffer', 'fragments'],
6
- EMPTY_BUFFER: Buffer.alloc(0),
7
- GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
8
- kForOnEventAttribute: Symbol('kIsForOnEventAttribute'),
9
- kListener: Symbol('kListener'),
10
- kStatusCode: Symbol('status-code'),
11
- kWebSocket: Symbol('websocket'),
12
- NOOP: () => undefined,
13
- };