@remotion/renderer 4.0.0-alpha11 → 4.0.0-alpha13

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/package.json +9 -9
  2. package/dist/assets/get-video-stream-duration.d.ts +0 -9
  3. package/dist/assets/get-video-stream-duration.js +0 -71
  4. package/dist/calculate-sar-dar-pixels.d.ts +0 -9
  5. package/dist/calculate-sar-dar-pixels.js +0 -19
  6. package/dist/determine-resize-params.d.ts +0 -1
  7. package/dist/determine-resize-params.js +0 -10
  8. package/dist/determine-vcodec-ffmpeg-flags.d.ts +0 -2
  9. package/dist/determine-vcodec-ffmpeg-flags.js +0 -13
  10. package/dist/ensure-ffmpeg.d.ts +0 -18
  11. package/dist/ensure-ffmpeg.js +0 -58
  12. package/dist/ensure-presentation-timestamp.d.ts +0 -15
  13. package/dist/ensure-presentation-timestamp.js +0 -88
  14. package/dist/extract-frame-from-video.d.ts +0 -16
  15. package/dist/extract-frame-from-video.js +0 -191
  16. package/dist/ffmpeg-executable.d.ts +0 -1
  17. package/dist/ffmpeg-executable.js +0 -2
  18. package/dist/ffmpeg-flags.d.ts +0 -31
  19. package/dist/ffmpeg-flags.js +0 -245
  20. package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -1
  21. package/dist/frame-to-ffmpeg-timestamp.js +0 -8
  22. package/dist/get-can-extract-frames-fast.d.ts +0 -14
  23. package/dist/get-can-extract-frames-fast.js +0 -71
  24. package/dist/get-frame-of-video-slow.d.ts +0 -17
  25. package/dist/get-frame-of-video-slow.js +0 -72
  26. package/dist/get-video-info.d.ts +0 -8
  27. package/dist/get-video-info.js +0 -59
  28. package/dist/is-beyond-last-frame.d.ts +0 -3
  29. package/dist/is-beyond-last-frame.js +0 -12
  30. package/dist/last-frame-from-video-cache.d.ts +0 -17
  31. package/dist/last-frame-from-video-cache.js +0 -55
  32. package/dist/legacy-webpack-config.d.ts +0 -9
  33. package/dist/legacy-webpack-config.js +0 -13
  34. package/dist/quality.d.ts +0 -1
  35. package/dist/quality.js +0 -21
  36. package/dist/try-to-extract-frame-of-video-fast.d.ts +0 -12
  37. package/dist/try-to-extract-frame-of-video-fast.js +0 -55
  38. package/dist/validate-ffmpeg.d.ts +0 -7
  39. package/dist/validate-ffmpeg.js +0 -77
  40. package/dist/warn-about-ffmpeg-version.d.ts +0 -5
  41. package/dist/warn-about-ffmpeg-version.js +0 -37
@@ -1,245 +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.warnAboutFfmpegVersion = exports.getBinaryDownloadUrl = exports.getExecutableBinary = exports.lambdaFfmpegPaths = exports.downloadBinary = exports.getFfmpegVersion = exports.parseFfmpegVersion = exports.ffmpegHasFeature = exports.ffmpegInNodeModules = exports.getFfmpegBuildInfo = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const os_1 = __importDefault(require("os"));
10
- const path_1 = __importDefault(require("path"));
11
- const BrowserFetcher_1 = require("./browser/BrowserFetcher");
12
- const validate_ffmpeg_1 = require("./validate-ffmpeg");
13
- let buildConfig = null;
14
- const listeners = {};
15
- const isDownloading = {};
16
- const getFfmpegBuildInfo = async (options) => {
17
- if (buildConfig !== null) {
18
- return buildConfig;
19
- }
20
- const data = await (0, execa_1.default)(await (0, exports.getExecutableBinary)(options.ffmpegExecutable, options.remotionRoot, 'ffmpeg'), ['-buildconf'], {
21
- reject: false,
22
- });
23
- buildConfig = data.stderr;
24
- return buildConfig;
25
- };
26
- exports.getFfmpegBuildInfo = getFfmpegBuildInfo;
27
- const getFfmpegFolderName = (remotionRoot) => {
28
- return path_1.default.resolve(remotionRoot, 'node_modules/.ffmpeg');
29
- };
30
- const binaryPrefix = { ffmpeg: 'ffmpeg-', ffprobe: 'ffprobe-' };
31
- const randomFfmpegRuntimeId = String(Math.random()).replace('0.', '');
32
- const ffmpegInNodeModules = (remotionRoot, binary) => {
33
- const folderName = getFfmpegFolderName(remotionRoot);
34
- if (!fs_1.default.existsSync(folderName)) {
35
- fs_1.default.mkdirSync(folderName, {
36
- recursive: true,
37
- });
38
- }
39
- // Check if a version of FFMPEG is already installed.
40
- // To qualify, it must have the expected file size
41
- // to avoid finding binaries that are still being downloaded
42
- // A random ID is being assigned to the download to avoid conflicts when multiple Remotion processes are running
43
- const ffmpegInstalled = fs_1.default.readdirSync(folderName).find((filename) => {
44
- if (!filename.startsWith(binaryPrefix[binary])) {
45
- return false;
46
- }
47
- const dlUrl = (0, exports.getBinaryDownloadUrl)(binary);
48
- if (!dlUrl) {
49
- return false;
50
- }
51
- const expectedLength = dlUrl.contentLength;
52
- if (fs_1.default.statSync(path_1.default.join(folderName, filename)).size === expectedLength) {
53
- return true;
54
- }
55
- return false;
56
- });
57
- if (ffmpegInstalled) {
58
- return path_1.default.join(folderName, ffmpegInstalled);
59
- }
60
- return null;
61
- };
62
- exports.ffmpegInNodeModules = ffmpegInNodeModules;
63
- const getFfmpegAbsolutePath = (remotionRoot, binary) => {
64
- const folderName = getFfmpegFolderName(remotionRoot);
65
- if (!fs_1.default.existsSync(folderName)) {
66
- fs_1.default.mkdirSync(folderName);
67
- }
68
- if (os_1.default.platform() === 'win32') {
69
- return path_1.default.resolve(folderName, `${binaryPrefix[binary]}${randomFfmpegRuntimeId}.exe`);
70
- }
71
- return path_1.default.resolve(folderName, `${binaryPrefix[binary]}${randomFfmpegRuntimeId}`);
72
- };
73
- const ffmpegHasFeature = async ({ ffmpegExecutable, feature, remotionRoot, }) => {
74
- if (ffmpegExecutable && !(0, validate_ffmpeg_1.customExecutableExists)(ffmpegExecutable)) {
75
- return false;
76
- }
77
- if (!(0, validate_ffmpeg_1.binaryExists)('ffmpeg')) {
78
- return false;
79
- }
80
- const config = await (0, exports.getFfmpegBuildInfo)({ ffmpegExecutable, remotionRoot });
81
- return config.includes(feature);
82
- };
83
- exports.ffmpegHasFeature = ffmpegHasFeature;
84
- const parseFfmpegVersion = (buildconf) => {
85
- var _a;
86
- const match = buildconf.match(/ffmpeg version ([0-9]+).([0-9]+)(?:.([0-9]+))?/);
87
- if (!match) {
88
- return null;
89
- }
90
- return [Number(match[1]), Number(match[2]), Number((_a = match[3]) !== null && _a !== void 0 ? _a : 0)];
91
- };
92
- exports.parseFfmpegVersion = parseFfmpegVersion;
93
- const getFfmpegVersion = async (options) => {
94
- const buildInfo = await (0, exports.getFfmpegBuildInfo)({
95
- ffmpegExecutable: options.ffmpegExecutable,
96
- remotionRoot: options.remotionRoot,
97
- });
98
- return (0, exports.parseFfmpegVersion)(buildInfo);
99
- };
100
- exports.getFfmpegVersion = getFfmpegVersion;
101
- const waitForFfmpegToBeDownloaded = (url) => {
102
- return new Promise((resolve) => {
103
- if (!listeners[url]) {
104
- listeners[url] = [];
105
- }
106
- listeners[url].push((src) => resolve(src));
107
- });
108
- };
109
- const onProgress = (downloadedBytes, totalBytesToDownload, binary) => {
110
- console.log('Downloading ', binary, `${toMegabytes(downloadedBytes)}/${toMegabytes(totalBytesToDownload)}`);
111
- };
112
- const downloadBinary = async (remotionRoot, url, binary) => {
113
- const destinationPath = getFfmpegAbsolutePath(remotionRoot, binary);
114
- const onProgressCallback = (downloadedBytes, _totalBytes) => {
115
- onProgress(downloadedBytes, _totalBytes, binary);
116
- };
117
- isDownloading[url] = true;
118
- const totalBytes = await (0, BrowserFetcher_1._downloadFile)(url, destinationPath, onProgressCallback);
119
- onProgress(totalBytes, totalBytes, binary);
120
- if (os_1.default.platform() !== 'win32') {
121
- fs_1.default.chmodSync(destinationPath, '777');
122
- }
123
- isDownloading[url] = false;
124
- if (!listeners[url]) {
125
- listeners[url] = [];
126
- }
127
- listeners[url].forEach((listener) => listener(destinationPath));
128
- listeners[url] = [];
129
- return destinationPath;
130
- };
131
- exports.downloadBinary = downloadBinary;
132
- exports.lambdaFfmpegPaths = {
133
- ffmpeg: '/opt/bin/ffmpeg',
134
- ffprobe: '/opt/bin/ffprobe',
135
- };
136
- const getExecutableBinary = (ffmpegExecutable, remotionRoot, binary) => {
137
- if (fs_1.default.existsSync(exports.lambdaFfmpegPaths[binary])) {
138
- return exports.lambdaFfmpegPaths[binary];
139
- }
140
- if (ffmpegExecutable && (0, validate_ffmpeg_1.customExecutableExists)(ffmpegExecutable)) {
141
- return ffmpegExecutable;
142
- }
143
- if ((0, validate_ffmpeg_1.binaryExists)(binary)) {
144
- return binary;
145
- }
146
- const dlUrl = (0, exports.getBinaryDownloadUrl)(binary);
147
- if (dlUrl && isDownloading[dlUrl.url]) {
148
- return waitForFfmpegToBeDownloaded(dlUrl.url);
149
- }
150
- const inNodeMod = (0, exports.ffmpegInNodeModules)(remotionRoot, binary);
151
- if (inNodeMod) {
152
- return inNodeMod;
153
- }
154
- if (!dlUrl) {
155
- throw new Error(`${binary} could not be installed automatically. Your architecture and OS combination (os = ${os_1.default.platform()}, arch = ${process.arch}) is not supported. Please install ${binary} manually and add "${binary}" to your PATH.`);
156
- }
157
- return (0, exports.downloadBinary)(remotionRoot, dlUrl.url, binary);
158
- };
159
- exports.getExecutableBinary = getExecutableBinary;
160
- function toMegabytes(bytes) {
161
- const mb = bytes / 1024 / 1024;
162
- return `${Math.round(mb * 10) / 10} Mb`;
163
- }
164
- const getBinaryDownloadUrl = (binary) => {
165
- if (os_1.default.platform() === 'win32' && process.arch === 'x64') {
166
- return binary === 'ffmpeg'
167
- ? {
168
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-win-x86.exe',
169
- contentLength: 127531008,
170
- }
171
- : {
172
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-win-x86.exe',
173
- contentLength: 127425536,
174
- };
175
- }
176
- if (os_1.default.platform() === 'darwin' && process.arch === 'arm64') {
177
- return binary === 'ffmpeg'
178
- ? {
179
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-macos-arm64',
180
- contentLength: 42093320,
181
- }
182
- : {
183
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-macos-arm64-v2',
184
- contentLength: 46690008,
185
- };
186
- }
187
- if (os_1.default.platform() === 'darwin' && process.arch === 'x64') {
188
- return binary === 'ffmpeg'
189
- ? {
190
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-macos-x86',
191
- contentLength: 78380700,
192
- }
193
- : {
194
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-macos-x86',
195
- contentLength: 77364284,
196
- };
197
- }
198
- if (os_1.default.platform() === 'linux' && process.arch === 'x64') {
199
- return binary === 'ffmpeg'
200
- ? {
201
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffmpeg-linux-amd64',
202
- contentLength: 78502560,
203
- }
204
- : {
205
- url: 'https://remotion-ffmpeg-binaries.s3.eu-central-1.amazonaws.com/ffprobe-linux-amd64',
206
- contentLength: 78400704,
207
- };
208
- }
209
- return null;
210
- };
211
- exports.getBinaryDownloadUrl = getBinaryDownloadUrl;
212
- const printMessage = (ffmpegVersion) => {
213
- console.warn('⚠️Old FFMPEG version detected: ' + ffmpegVersion.join('.'));
214
- console.warn(' You need at least version 4.1.0.');
215
- console.warn(' Upgrade FFMPEG to get rid of this warning.');
216
- };
217
- const printBuildConfMessage = () => {
218
- console.error('⚠️ Unsupported FFMPEG version detected.');
219
- console.error(" Your version doesn't support the -buildconf flag");
220
- console.error(' Audio will not be supported and you may experience other issues.');
221
- console.error(' Upgrade FFMPEG to at least v4.1.0 to get rid of this warning.');
222
- };
223
- const warnAboutFfmpegVersion = ({ ffmpegVersion, buildConf, }) => {
224
- if (buildConf === null) {
225
- printBuildConfMessage();
226
- return;
227
- }
228
- if (ffmpegVersion === null) {
229
- return null;
230
- }
231
- const [major, minor] = ffmpegVersion;
232
- // 3.x and below definitely is too old
233
- if (major < 4) {
234
- printMessage(ffmpegVersion);
235
- return;
236
- }
237
- // 5.x will be all good
238
- if (major > 4) {
239
- return;
240
- }
241
- if (minor < 1) {
242
- printMessage(ffmpegVersion);
243
- }
244
- };
245
- exports.warnAboutFfmpegVersion = warnAboutFfmpegVersion;
@@ -1 +0,0 @@
1
- export declare const frameToFfmpegTimestamp: (time: number) => string;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.frameToFfmpegTimestamp = void 0;
4
- const frameToFfmpegTimestamp = (time) => {
5
- // We ceil because FFMPEG seeks to the closest frame BEFORE the position
6
- return (Math.ceil(time * 1000000) / 1000).toFixed(3) + 'ms';
7
- };
8
- exports.frameToFfmpegTimestamp = frameToFfmpegTimestamp;
@@ -1,14 +0,0 @@
1
- import type { FfmpegExecutable } from './ffmpeg-executable';
2
- export declare const ACCEPTABLE_OFFSET_THRESHOLD = 50;
3
- /**
4
- * @description Probes whether frames of a video can be efficiently extracted when using <OffthreadVideo>.
5
- * @see [Documentation](https://www.remotion.dev/docs/renderer/get-can-extract-frames-fast)
6
- */
7
- export declare const getCanExtractFramesFast: ({ src, ffmpegExecutable, ffprobeExecutable, }: {
8
- src: string;
9
- ffmpegExecutable?: FfmpegExecutable | undefined;
10
- ffprobeExecutable?: FfmpegExecutable | undefined;
11
- }) => Promise<{
12
- canExtractFramesFast: boolean;
13
- shouldReencode: boolean;
14
- }>;
@@ -1,71 +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.getCanExtractFramesFast = exports.ACCEPTABLE_OFFSET_THRESHOLD = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const get_video_stream_duration_1 = require("./assets/get-video-stream-duration");
9
- const ensure_presentation_timestamp_1 = require("./ensure-presentation-timestamp");
10
- const find_closest_package_json_1 = require("./find-closest-package-json");
11
- const get_video_info_1 = require("./get-video-info");
12
- const try_to_extract_frame_of_video_fast_1 = require("./try-to-extract-frame-of-video-fast");
13
- exports.ACCEPTABLE_OFFSET_THRESHOLD = 50;
14
- /**
15
- * @description Probes whether frames of a video can be efficiently extracted when using <OffthreadVideo>.
16
- * @see [Documentation](https://www.remotion.dev/docs/renderer/get-can-extract-frames-fast)
17
- */
18
- const getCanExtractFramesFast = async ({ src, ffmpegExecutable, ffprobeExecutable, }) => {
19
- const remotionRoot = (0, find_closest_package_json_1.findRemotionRoot)();
20
- const out = await (0, ensure_presentation_timestamp_1.ensurePresentationTimestampWithoutCache)({
21
- ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
22
- ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
23
- remotionRoot,
24
- src,
25
- });
26
- const { specialVcodecForTransparency: specialVcodec } = await (0, get_video_info_1.getVideoInfoUncached)({
27
- src: out,
28
- ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
29
- remotionRoot,
30
- });
31
- if (specialVcodec === 'vp8') {
32
- fs_1.default.unlinkSync(out);
33
- return {
34
- canExtractFramesFast: false,
35
- shouldReencode: false,
36
- };
37
- }
38
- const { duration } = await (0, get_video_stream_duration_1.getVideoStreamDurationwithoutCache)({
39
- ffprobeExecutable: ffprobeExecutable !== null && ffprobeExecutable !== void 0 ? ffprobeExecutable : null,
40
- remotionRoot,
41
- src: out,
42
- });
43
- if (duration === null) {
44
- fs_1.default.unlinkSync(out);
45
- throw new Error(`Could not determine the duration of ${src} using FFMPEG. The file is not supported.`);
46
- }
47
- const actualOffset = `${duration * 1000 - exports.ACCEPTABLE_OFFSET_THRESHOLD}ms`;
48
- const [stdErr] = await (0, try_to_extract_frame_of_video_fast_1.tryToExtractFrameOfVideoFast)({
49
- actualOffset,
50
- ffmpegExecutable: ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : null,
51
- imageFormat: 'jpeg',
52
- // Intentionally leaving needsResize as null, because we don't need to resize
53
- needsResize: null,
54
- remotionRoot,
55
- specialVCodecForTransparency: specialVcodec,
56
- src: out,
57
- });
58
- fs_1.default.unlinkSync(out);
59
- const isEmpty = stdErr.includes('Output file is empty');
60
- if (isEmpty) {
61
- return {
62
- canExtractFramesFast: false,
63
- shouldReencode: true,
64
- };
65
- }
66
- return {
67
- canExtractFramesFast: true,
68
- shouldReencode: false,
69
- };
70
- };
71
- exports.getCanExtractFramesFast = getCanExtractFramesFast;
@@ -1,17 +0,0 @@
1
- import type { OffthreadVideoImageFormat } from 'remotion';
2
- import type { SpecialVCodecForTransparency } from './assets/download-map';
3
- import type { FfmpegExecutable } from './ffmpeg-executable';
4
- export declare const getFrameOfVideoSlow: ({ src, duration, ffmpegExecutable, imageFormat, specialVCodecForTransparency, needsResize, offset, fps, remotionRoot, }: {
5
- ffmpegExecutable: FfmpegExecutable;
6
- src: string;
7
- duration: number;
8
- imageFormat: OffthreadVideoImageFormat;
9
- specialVCodecForTransparency: SpecialVCodecForTransparency;
10
- needsResize: [
11
- number,
12
- number
13
- ] | null;
14
- offset: number;
15
- fps: number | null;
16
- remotionRoot: string;
17
- }) => Promise<Buffer>;
@@ -1,72 +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.getFrameOfVideoSlow = void 0;
7
- // Uses no seeking, therefore the whole video has to be decoded. This is a last resort and should only happen
8
- // if the video is corrupted
9
- const execa_1 = __importDefault(require("execa"));
10
- const determine_resize_params_1 = require("./determine-resize-params");
11
- const determine_vcodec_ffmpeg_flags_1 = require("./determine-vcodec-ffmpeg-flags");
12
- const ffmpeg_flags_1 = require("./ffmpeg-flags");
13
- const truthy_1 = require("./truthy");
14
- const getFrameOfVideoSlow = async ({ src, duration, ffmpegExecutable, imageFormat, specialVCodecForTransparency, needsResize, offset, fps, remotionRoot, }) => {
15
- console.warn(`\nUsing a slow method to extract the frame at ${duration}ms of ${src}. See https://remotion.dev/docs/slow-method-to-extract-frame for advice`);
16
- const actualOffset = `-${duration * 1000 - offset}ms`;
17
- const command = [
18
- '-itsoffset',
19
- actualOffset,
20
- ...(0, determine_vcodec_ffmpeg_flags_1.determineVcodecFfmpegFlags)(specialVCodecForTransparency),
21
- '-i',
22
- src,
23
- '-frames:v',
24
- '1',
25
- '-c:v',
26
- imageFormat === 'jpeg' ? 'mjpeg' : 'png',
27
- '-f',
28
- 'image2pipe',
29
- ...(0, determine_resize_params_1.determineResizeParams)(needsResize),
30
- '-',
31
- ].filter(truthy_1.truthy);
32
- const { stdout, stderr } = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffmpegExecutable, remotionRoot, 'ffmpeg'), command);
33
- if (!stderr) {
34
- throw new Error('unexpectedly did not get stderr');
35
- }
36
- if (!stdout) {
37
- throw new Error('unexpectedly did not get stdout');
38
- }
39
- const stderrChunks = [];
40
- const stdoutChunks = [];
41
- const stdErrString = new Promise((resolve, reject) => {
42
- stderr.on('data', (d) => stderrChunks.push(d));
43
- stderr.on('error', (err) => reject(err));
44
- stderr.on('end', () => resolve(Buffer.concat(stderrChunks).toString('utf-8')));
45
- });
46
- const stdoutChunk = new Promise((resolve, reject) => {
47
- stdout.on('data', (d) => stdoutChunks.push(d));
48
- stdout.on('error', (err) => reject(err));
49
- stdout.on('end', () => resolve(Buffer.concat(stdoutChunks)));
50
- });
51
- const [stdErr, stdoutBuffer] = await Promise.all([stdErrString, stdoutChunk]);
52
- const isEmpty = stdErr.includes('Output file is empty');
53
- if (isEmpty) {
54
- if (offset > 70) {
55
- throw new Error(`Could not get last frame of ${src}. Tried to seek to the end using the command "ffmpeg ${command.join(' ')}" but got no frame. Most likely this video is corrupted.`);
56
- }
57
- return (0, exports.getFrameOfVideoSlow)({
58
- ffmpegExecutable,
59
- duration,
60
- // Decrement in 10ms increments, or 1 frame (e.g. fps = 25 --> 40ms)
61
- offset: offset + (fps === null ? 10 : 1000 / fps),
62
- src,
63
- imageFormat,
64
- specialVCodecForTransparency,
65
- needsResize,
66
- fps,
67
- remotionRoot,
68
- });
69
- }
70
- return stdoutBuffer;
71
- };
72
- exports.getFrameOfVideoSlow = getFrameOfVideoSlow;
@@ -1,8 +0,0 @@
1
- import type { DownloadMap, Vp9Result } from './assets/download-map';
2
- import type { FfmpegExecutable } from './ffmpeg-executable';
3
- export declare function getVideoInfoUncached({ src, ffprobeExecutable, remotionRoot, }: {
4
- src: string;
5
- ffprobeExecutable: FfmpegExecutable;
6
- remotionRoot: string;
7
- }): Promise<Vp9Result>;
8
- export declare const getVideoInfo: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<Vp9Result>;
@@ -1,59 +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.getVideoInfo = exports.getVideoInfoUncached = void 0;
7
- const execa_1 = __importDefault(require("execa"));
8
- const calculate_sar_dar_pixels_1 = require("./calculate-sar-dar-pixels");
9
- const ffmpeg_flags_1 = require("./ffmpeg-flags");
10
- const p_limit_1 = require("./p-limit");
11
- const limit = (0, p_limit_1.pLimit)(1);
12
- async function getVideoInfoUncached({ src, ffprobeExecutable, remotionRoot, }) {
13
- var _a;
14
- const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), [src]);
15
- const isVp9 = task.stderr.includes('Video: vp9');
16
- const isVp8 = task.stderr.includes('Video: vp8');
17
- const dimensions = (_a = task.stderr
18
- .split('\n')
19
- .find((n) => n.trim().startsWith('Stream #'))) === null || _a === void 0 ? void 0 : _a.match(/([0-9]{2,6})x([0-9]{2,6})/);
20
- const dar = task.stderr.match(/DAR\s([0-9]+):([0-9]+)/);
21
- let needsResize = null;
22
- if (dimensions && dar) {
23
- const width = parseInt(dimensions[1], 10);
24
- const height = parseInt(dimensions[2], 10);
25
- const darWidth = parseInt(dar[1], 10);
26
- const darHeight = parseInt(dar[2], 10);
27
- const { width: actualWidth, height: actualHeight } = (0, calculate_sar_dar_pixels_1.calculateDisplayVideoSize)({
28
- darX: darWidth,
29
- darY: darHeight,
30
- x: width,
31
- y: height,
32
- });
33
- if (actualWidth !== width || actualHeight !== height) {
34
- needsResize = [actualWidth, actualHeight];
35
- }
36
- }
37
- const result = {
38
- specialVcodecForTransparency: isVp9 ? 'vp9' : isVp8 ? 'vp8' : 'none',
39
- needsResize,
40
- };
41
- return result;
42
- }
43
- exports.getVideoInfoUncached = getVideoInfoUncached;
44
- async function getVideoInfoUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
45
- if (typeof downloadMap.isVp9VideoCache[src] !== 'undefined') {
46
- return downloadMap.isVp9VideoCache[src];
47
- }
48
- const result = await getVideoInfoUncached({
49
- ffprobeExecutable,
50
- remotionRoot,
51
- src,
52
- });
53
- downloadMap.isVp9VideoCache[src] = result;
54
- return downloadMap.isVp9VideoCache[src];
55
- }
56
- const getVideoInfo = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
57
- return limit(() => getVideoInfoUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
58
- };
59
- exports.getVideoInfo = getVideoInfo;
@@ -1,3 +0,0 @@
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 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.markAsBeyondLastFrame = exports.isBeyondLastFrame = void 0;
4
- const isBeyondLastFrame = (downloadMap, src, time) => {
5
- return (downloadMap.isBeyondLastFrameMap[src] &&
6
- time >= downloadMap.isBeyondLastFrameMap[src]);
7
- };
8
- exports.isBeyondLastFrame = isBeyondLastFrame;
9
- const markAsBeyondLastFrame = (downloadMap, src, time) => {
10
- downloadMap.isBeyondLastFrameMap[src] = time;
11
- };
12
- exports.markAsBeyondLastFrame = markAsBeyondLastFrame;
@@ -1,17 +0,0 @@
1
- import type { OffthreadVideoImageFormat } from 'remotion';
2
- import type { DownloadMap, SpecialVCodecForTransparency } from './assets/download-map';
3
- import type { FfmpegExecutable } from './ffmpeg-executable';
4
- export declare type LastFrameOptions = {
5
- ffmpegExecutable: FfmpegExecutable;
6
- ffprobeExecutable: FfmpegExecutable;
7
- offset: number;
8
- src: string;
9
- specialVCodecForTransparency: SpecialVCodecForTransparency;
10
- imageFormat: OffthreadVideoImageFormat;
11
- needsResize: [number, number] | null;
12
- downloadMap: DownloadMap;
13
- remotionRoot: string;
14
- };
15
- export declare const setLastFrameInCache: (options: LastFrameOptions, data: Buffer) => void;
16
- export declare const getLastFrameFromCache: (options: LastFrameOptions) => Buffer | null;
17
- export declare const clearLastFileCache: (downloadMap: DownloadMap) => void;
@@ -1,55 +0,0 @@
1
- "use strict";
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
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearLastFileCache = exports.getLastFrameFromCache = exports.setLastFrameInCache = void 0;
5
- const MAX_CACHE_SIZE = 50 * 1024 * 1024; // 50MB
6
- let bufferSize = 0;
7
- const makeLastFrameCacheKey = (options) => {
8
- return [
9
- options.ffmpegExecutable,
10
- options.offset,
11
- options.src,
12
- options.imageFormat,
13
- options.downloadMap.id,
14
- ].join('-');
15
- };
16
- const setLastFrameInCache = (options, data) => {
17
- const key = makeLastFrameCacheKey(options);
18
- if (options.downloadMap.lastFrameMap[key]) {
19
- bufferSize -= options.downloadMap.lastFrameMap[key].data.byteLength;
20
- }
21
- options.downloadMap.lastFrameMap[key] = { data, lastAccessed: Date.now() };
22
- bufferSize += data.byteLength;
23
- ensureMaxSize(options.downloadMap);
24
- };
25
- exports.setLastFrameInCache = setLastFrameInCache;
26
- const getLastFrameFromCache = (options) => {
27
- var _a;
28
- const key = makeLastFrameCacheKey(options);
29
- if (!options.downloadMap.lastFrameMap[key]) {
30
- return null;
31
- }
32
- options.downloadMap.lastFrameMap[key].lastAccessed = Date.now();
33
- return (_a = options.downloadMap.lastFrameMap[key].data) !== null && _a !== void 0 ? _a : null;
34
- };
35
- exports.getLastFrameFromCache = getLastFrameFromCache;
36
- const removedLastFrameFromCache = (key, downloadMap) => {
37
- if (!downloadMap.lastFrameMap[key]) {
38
- return;
39
- }
40
- bufferSize -= downloadMap.lastFrameMap[key].data.byteLength;
41
- delete downloadMap.lastFrameMap[key];
42
- };
43
- const ensureMaxSize = (downloadMap) => {
44
- // eslint-disable-next-line no-unmodified-loop-condition
45
- while (bufferSize > MAX_CACHE_SIZE) {
46
- const earliest = Object.entries(downloadMap.lastFrameMap).sort((a, b) => {
47
- return a[1].lastAccessed - b[1].lastAccessed;
48
- })[0];
49
- removedLastFrameFromCache(earliest[0], downloadMap);
50
- }
51
- };
52
- const clearLastFileCache = (downloadMap) => {
53
- downloadMap.lastFrameMap = {};
54
- };
55
- exports.clearLastFileCache = clearLastFileCache;
@@ -1,9 +0,0 @@
1
- export declare type ServeUrlOrWebpackBundle = {
2
- serveUrl: string;
3
- } | {
4
- /**
5
- * @deprecated Renamed to `serveUrl`
6
- */
7
- webpackBundle: string;
8
- };
9
- export declare const getServeUrlWithFallback: (serve: ServeUrlOrWebpackBundle) => string;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getServeUrlWithFallback = void 0;
4
- const getServeUrlWithFallback = (serve) => {
5
- if ('webpackBundle' in serve) {
6
- return serve.webpackBundle;
7
- }
8
- if ('serveUrl' in serve) {
9
- return serve.serveUrl;
10
- }
11
- throw new Error('You must pass the `serveUrl` parameter');
12
- };
13
- exports.getServeUrlWithFallback = getServeUrlWithFallback;
package/dist/quality.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const validateQuality: (q: number | undefined) => void;
package/dist/quality.js DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateQuality = void 0;
4
- const validateQuality = (q) => {
5
- if (typeof q !== 'undefined' && typeof q !== 'number') {
6
- throw new Error(`Quality option must be a number or undefined. Got ${typeof q} (${JSON.stringify(q)})`);
7
- }
8
- if (typeof q === 'undefined') {
9
- return;
10
- }
11
- if (!Number.isFinite(q)) {
12
- throw new RangeError(`Quality must be a finite number, but is ${q}`);
13
- }
14
- if (Number.isNaN(q)) {
15
- throw new RangeError(`Quality is NaN, but must be a real number`);
16
- }
17
- if (q > 100 || q < 0) {
18
- throw new RangeError('Quality option must be between 0 and 100.');
19
- }
20
- };
21
- exports.validateQuality = validateQuality;
@@ -1,12 +0,0 @@
1
- import type { OffthreadVideoImageFormat } from 'remotion';
2
- import type { NeedsResize, SpecialVCodecForTransparency } from './assets/download-map';
3
- import type { FfmpegExecutable } from './ffmpeg-executable';
4
- export declare const tryToExtractFrameOfVideoFast: ({ ffmpegExecutable, remotionRoot, specialVCodecForTransparency, imageFormat, needsResize, src, actualOffset, }: {
5
- ffmpegExecutable: FfmpegExecutable;
6
- remotionRoot: string;
7
- imageFormat: OffthreadVideoImageFormat;
8
- needsResize: NeedsResize;
9
- src: string;
10
- specialVCodecForTransparency: SpecialVCodecForTransparency;
11
- actualOffset: string;
12
- }) => Promise<readonly [string, Buffer]>;