@remotion/renderer 4.0.18 → 4.0.20
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.
- package/dist/get-compositions.js +13 -1
- package/dist/index.d.ts +5 -5
- package/dist/set-props-and-env.js +1 -1
- package/package.json +9 -9
- package/dist/assets/get-video-stream-duration.d.ts +0 -9
- package/dist/assets/get-video-stream-duration.js +0 -71
- package/dist/calculate-sar-dar-pixels.d.ts +0 -9
- package/dist/calculate-sar-dar-pixels.js +0 -19
- package/dist/determine-resize-params.d.ts +0 -4
- package/dist/determine-resize-params.js +0 -10
- package/dist/determine-vcodec-ffmpeg-flags.d.ts +0 -2
- package/dist/determine-vcodec-ffmpeg-flags.js +0 -13
- package/dist/ensure-ffmpeg.d.ts +0 -18
- package/dist/ensure-ffmpeg.js +0 -58
- package/dist/ensure-presentation-timestamp.d.ts +0 -15
- package/dist/ensure-presentation-timestamp.js +0 -88
- package/dist/extract-frame-from-video.d.ts +0 -16
- package/dist/extract-frame-from-video.js +0 -191
- package/dist/ffmpeg-executable.d.ts +0 -1
- package/dist/ffmpeg-executable.js +0 -2
- package/dist/ffmpeg-flags.d.ts +0 -31
- package/dist/ffmpeg-flags.js +0 -245
- package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -1
- package/dist/frame-to-ffmpeg-timestamp.js +0 -8
- package/dist/get-can-extract-frames-fast.d.ts +0 -14
- package/dist/get-can-extract-frames-fast.js +0 -71
- package/dist/get-frame-of-video-slow.d.ts +0 -17
- package/dist/get-frame-of-video-slow.js +0 -72
- package/dist/get-video-info.d.ts +0 -8
- package/dist/get-video-info.js +0 -59
- package/dist/is-beyond-last-frame.d.ts +0 -3
- package/dist/is-beyond-last-frame.js +0 -12
- package/dist/last-frame-from-video-cache.d.ts +0 -17
- package/dist/last-frame-from-video-cache.js +0 -55
- package/dist/legacy-webpack-config.d.ts +0 -9
- package/dist/legacy-webpack-config.js +0 -13
- package/dist/quality.d.ts +0 -1
- package/dist/quality.js +0 -21
- package/dist/try-to-extract-frame-of-video-fast.d.ts +0 -12
- package/dist/try-to-extract-frame-of-video-fast.js +0 -55
- package/dist/validate-ffmpeg.d.ts +0 -7
- package/dist/validate-ffmpeg.js +0 -77
- package/dist/warn-about-ffmpeg-version.d.ts +0 -5
- package/dist/warn-about-ffmpeg-version.js +0 -37
package/dist/get-compositions.js
CHANGED
|
@@ -56,7 +56,19 @@ const innerGetCompositions = async ({ envVariables, serializedInputPropsWithCust
|
|
|
56
56
|
page,
|
|
57
57
|
args: [],
|
|
58
58
|
});
|
|
59
|
-
|
|
59
|
+
const res = result;
|
|
60
|
+
return res.map((r) => {
|
|
61
|
+
const { width, durationInFrames, fps, height, id } = r;
|
|
62
|
+
return {
|
|
63
|
+
id,
|
|
64
|
+
width,
|
|
65
|
+
height,
|
|
66
|
+
fps,
|
|
67
|
+
durationInFrames,
|
|
68
|
+
props: remotion_1.Internals.deserializeJSONWithCustomFields(r.serializedResolvedPropsWithCustomSchema),
|
|
69
|
+
defaultProps: remotion_1.Internals.deserializeJSONWithCustomFields(r.serializedDefaultPropsWithCustomSchema),
|
|
70
|
+
};
|
|
71
|
+
});
|
|
60
72
|
};
|
|
61
73
|
const internalGetCompositions = async ({ browserExecutable, chromiumOptions, envVariables, indent, serializedInputPropsWithCustomSchema, onBrowserLog, port, puppeteerInstance, serveUrlOrWebpackUrl, server, timeoutInMilliseconds, logLevel, }) => {
|
|
62
74
|
const { page, cleanup: cleanupPage } = await (0, get_browser_instance_1.getPageAndCleanupFn)({
|
package/dist/index.d.ts
CHANGED
|
@@ -115,8 +115,8 @@ export declare const RenderInternals: {
|
|
|
115
115
|
validPixelFormats: readonly ["yuv420p", "yuva420p", "yuv422p", "yuv444p", "yuv420p10le", "yuv422p10le", "yuv444p10le", "yuva444p10le"];
|
|
116
116
|
DEFAULT_BROWSER: "chrome";
|
|
117
117
|
validateFrameRange: (frameRange: import("./frame-range").FrameRange | null) => void;
|
|
118
|
-
DEFAULT_OPENGL_RENDERER: "
|
|
119
|
-
validateOpenGlRenderer: (option: "
|
|
118
|
+
DEFAULT_OPENGL_RENDERER: "swangle" | "angle" | "egl" | "swiftshader" | null;
|
|
119
|
+
validateOpenGlRenderer: (option: "swangle" | "angle" | "egl" | "swiftshader" | null) => "swangle" | "angle" | "egl" | "swiftshader" | null;
|
|
120
120
|
validCodecs: readonly ["h264", "h265", "vp8", "vp9", "mp3", "aac", "wav", "prores", "h264-mkv", "gif"];
|
|
121
121
|
DEFAULT_PIXEL_FORMAT: "yuv420p" | "yuva420p" | "yuv422p" | "yuv444p" | "yuv420p10le" | "yuv422p10le" | "yuv444p10le" | "yuva444p10le";
|
|
122
122
|
validateJpegQuality: (q: number | undefined) => void;
|
|
@@ -304,8 +304,8 @@ export declare const RenderInternals: {
|
|
|
304
304
|
};
|
|
305
305
|
validStillImageFormats: readonly ["png", "jpeg", "pdf", "webp"];
|
|
306
306
|
validVideoImageFormats: readonly ["png", "jpeg", "none"];
|
|
307
|
-
DEFAULT_STILL_IMAGE_FORMAT: "
|
|
308
|
-
DEFAULT_VIDEO_IMAGE_FORMAT: "
|
|
307
|
+
DEFAULT_STILL_IMAGE_FORMAT: "png" | "jpeg" | "pdf" | "webp";
|
|
308
|
+
DEFAULT_VIDEO_IMAGE_FORMAT: "none" | "png" | "jpeg";
|
|
309
309
|
DEFAULT_JPEG_QUALITY: number;
|
|
310
310
|
chalk: {
|
|
311
311
|
enabled: () => boolean;
|
|
@@ -416,7 +416,7 @@ export declare const RenderInternals: {
|
|
|
416
416
|
frame: number;
|
|
417
417
|
serializedInputPropsWithCustomSchema: string;
|
|
418
418
|
serializedResolvedPropsWithCustomSchema: string;
|
|
419
|
-
imageFormat: "
|
|
419
|
+
imageFormat: "png" | "jpeg" | "pdf" | "webp";
|
|
420
420
|
jpegQuality: number;
|
|
421
421
|
puppeteerInstance: HeadlessBrowser | null;
|
|
422
422
|
envVariables: Record<string, string>;
|
|
@@ -110,7 +110,7 @@ const innerSetPropsAndEnv = async ({ serializedInputPropsWithCustomSchema, envVa
|
|
|
110
110
|
frame: null,
|
|
111
111
|
page,
|
|
112
112
|
});
|
|
113
|
-
const requiredVersion = '
|
|
113
|
+
const requiredVersion = '10';
|
|
114
114
|
if (siteVersion !== requiredVersion) {
|
|
115
115
|
throw new Error([
|
|
116
116
|
`Incompatible site: When visiting ${urlToVisit}, a bundle was found, but one that is not compatible with this version of Remotion. Found version: ${siteVersion} - Required version: ${requiredVersion}. To resolve this error:`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/renderer",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.20",
|
|
4
4
|
"description": "Renderer for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"extract-zip": "2.0.1",
|
|
19
19
|
"source-map": "^0.8.0-beta.0",
|
|
20
20
|
"ws": "8.7.0",
|
|
21
|
-
"remotion": "4.0.
|
|
21
|
+
"remotion": "4.0.20"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"react": ">=16.8.0",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"zod": "^3.21.4"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"@remotion/compositor-darwin-arm64": "4.0.
|
|
45
|
-
"@remotion/compositor-linux-
|
|
46
|
-
"@remotion/compositor-
|
|
47
|
-
"@remotion/compositor-
|
|
48
|
-
"@remotion/compositor-linux-
|
|
49
|
-
"@remotion/compositor-
|
|
50
|
-
"@remotion/compositor-
|
|
44
|
+
"@remotion/compositor-darwin-arm64": "4.0.20",
|
|
45
|
+
"@remotion/compositor-linux-x64-gnu": "4.0.20",
|
|
46
|
+
"@remotion/compositor-linux-x64-musl": "4.0.20",
|
|
47
|
+
"@remotion/compositor-win32-x64-msvc": "4.0.20",
|
|
48
|
+
"@remotion/compositor-linux-arm64-musl": "4.0.20",
|
|
49
|
+
"@remotion/compositor-darwin-x64": "4.0.20",
|
|
50
|
+
"@remotion/compositor-linux-arm64-gnu": "4.0.20"
|
|
51
51
|
},
|
|
52
52
|
"keywords": [
|
|
53
53
|
"remotion",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FfmpegExecutable } from '../ffmpeg-executable';
|
|
2
|
-
import type { DownloadMap, VideoDurationResult } from './download-map';
|
|
3
|
-
export declare const parseVideoStreamDuration: (stdout: string) => VideoDurationResult;
|
|
4
|
-
export declare function getVideoStreamDurationwithoutCache({ src, ffprobeExecutable, remotionRoot, }: {
|
|
5
|
-
src: string;
|
|
6
|
-
ffprobeExecutable: FfmpegExecutable;
|
|
7
|
-
remotionRoot: string;
|
|
8
|
-
}): Promise<VideoDurationResult>;
|
|
9
|
-
export declare const getVideoStreamDuration: (downloadMap: DownloadMap, src: string, ffprobeExecutable: FfmpegExecutable, remotionRoot: string) => Promise<VideoDurationResult>;
|
|
@@ -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.getVideoStreamDuration = exports.getVideoStreamDurationwithoutCache = exports.parseVideoStreamDuration = void 0;
|
|
7
|
-
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
const ffmpeg_flags_1 = require("../ffmpeg-flags");
|
|
9
|
-
const p_limit_1 = require("../p-limit");
|
|
10
|
-
const limit = (0, p_limit_1.pLimit)(1);
|
|
11
|
-
const parseAlternativeDuration = (stdout) => {
|
|
12
|
-
const webmDuration = stdout.match(/TAG:DURATION=([0-9.]+):([0-9.]+):([0-9.]+)/);
|
|
13
|
-
if (!webmDuration) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
const [, hours, minutes, seconds] = webmDuration;
|
|
17
|
-
const hoursAsNumber = Number(hours);
|
|
18
|
-
if (Number.isNaN(hoursAsNumber)) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
const minutesAsNumber = Number(minutes);
|
|
22
|
-
if (Number.isNaN(minutesAsNumber)) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const secondsAsNumber = Number(seconds);
|
|
26
|
-
if (Number.isNaN(secondsAsNumber)) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return secondsAsNumber + minutesAsNumber * 60 + hoursAsNumber * 3600;
|
|
30
|
-
};
|
|
31
|
-
const parseVideoStreamDuration = (stdout) => {
|
|
32
|
-
const duration = stdout.match(/duration=([0-9.]+)/);
|
|
33
|
-
const alternativeDuration = parseAlternativeDuration(stdout);
|
|
34
|
-
const fps = stdout.match(/r_frame_rate=([0-9.]+)\/([0-9.]+)/);
|
|
35
|
-
const result = {
|
|
36
|
-
duration: duration ? parseFloat(duration[1]) : alternativeDuration,
|
|
37
|
-
fps: fps ? parseInt(fps[1], 10) / parseInt(fps[2], 10) : null,
|
|
38
|
-
};
|
|
39
|
-
return result;
|
|
40
|
-
};
|
|
41
|
-
exports.parseVideoStreamDuration = parseVideoStreamDuration;
|
|
42
|
-
async function getVideoStreamDurationwithoutCache({ src, ffprobeExecutable, remotionRoot, }) {
|
|
43
|
-
const args = [
|
|
44
|
-
['-v', 'error'],
|
|
45
|
-
['-select_streams', 'v:0'],
|
|
46
|
-
['-show_entries', 'stream'],
|
|
47
|
-
[src],
|
|
48
|
-
]
|
|
49
|
-
.reduce((acc, val) => acc.concat(val), [])
|
|
50
|
-
.filter(Boolean);
|
|
51
|
-
const task = await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffprobeExecutable, remotionRoot, 'ffprobe'), args);
|
|
52
|
-
const result = (0, exports.parseVideoStreamDuration)(task.stdout);
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
exports.getVideoStreamDurationwithoutCache = getVideoStreamDurationwithoutCache;
|
|
56
|
-
async function getVideoStreamDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot) {
|
|
57
|
-
if (downloadMap.videoDurationResultCache[src]) {
|
|
58
|
-
return downloadMap.videoDurationResultCache[src];
|
|
59
|
-
}
|
|
60
|
-
const result = await getVideoStreamDurationwithoutCache({
|
|
61
|
-
src,
|
|
62
|
-
ffprobeExecutable,
|
|
63
|
-
remotionRoot,
|
|
64
|
-
});
|
|
65
|
-
downloadMap.videoDurationResultCache[src] = result;
|
|
66
|
-
return result;
|
|
67
|
-
}
|
|
68
|
-
const getVideoStreamDuration = (downloadMap, src, ffprobeExecutable, remotionRoot) => {
|
|
69
|
-
return limit(() => getVideoStreamDurationUnlimited(downloadMap, src, ffprobeExecutable, remotionRoot));
|
|
70
|
-
};
|
|
71
|
-
exports.getVideoStreamDuration = getVideoStreamDuration;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// https://superuser.com/questions/907933/correct-aspect-ratio-without-re-encoding-video-file
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.calculateDisplayVideoSize = void 0;
|
|
5
|
-
const calculateDisplayVideoSize = ({ darX, darY, x, y, }) => {
|
|
6
|
-
// We know two equations:
|
|
7
|
-
// newWidth / newHeight = darX / darY
|
|
8
|
-
// and:
|
|
9
|
-
// x * y = (newWidth * newHeight)
|
|
10
|
-
// I solved it then on pen and paper and simplified the formula:
|
|
11
|
-
const dimensions = x * y;
|
|
12
|
-
const newWidth = Math.sqrt(dimensions * (darX / darY));
|
|
13
|
-
const newHeight = dimensions / newWidth;
|
|
14
|
-
return {
|
|
15
|
-
height: Math.round(newHeight),
|
|
16
|
-
width: Math.round(newWidth),
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
exports.calculateDisplayVideoSize = calculateDisplayVideoSize;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determineResizeParams = void 0;
|
|
4
|
-
const determineResizeParams = (needsResize) => {
|
|
5
|
-
if (needsResize === null) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
return ['-s', `${needsResize[0]}x${needsResize[1]}`];
|
|
9
|
-
};
|
|
10
|
-
exports.determineResizeParams = determineResizeParams;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.determineVcodecFfmpegFlags = void 0;
|
|
4
|
-
const truthy_1 = require("./truthy");
|
|
5
|
-
const determineVcodecFfmpegFlags = (vcodecFlag) => {
|
|
6
|
-
return [
|
|
7
|
-
vcodecFlag === 'vp9' ? '-vcodec' : null,
|
|
8
|
-
vcodecFlag === 'vp9' ? 'libvpx-vp9' : null,
|
|
9
|
-
vcodecFlag === 'vp8' ? '-vcodec' : null,
|
|
10
|
-
vcodecFlag === 'vp8' ? 'libvpx' : null,
|
|
11
|
-
].filter(truthy_1.truthy);
|
|
12
|
-
};
|
|
13
|
-
exports.determineVcodecFfmpegFlags = determineVcodecFfmpegFlags;
|
package/dist/ensure-ffmpeg.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type EnsureFfmpegOptions = {
|
|
2
|
-
remotionRoot?: string;
|
|
3
|
-
};
|
|
4
|
-
type Result = {
|
|
5
|
-
result: 'found-in-path' | 'found-in-node-modules' | 'installed';
|
|
6
|
-
wasAlreadyInstalled: boolean;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* @description Checks if the ffmpeg binary is installed and if it is not, downloads it and puts it into your node_modules folder.
|
|
10
|
-
* @see [Documentation](https://www.remotion.dev/docs/renderer/ensure-ffmpeg)
|
|
11
|
-
*/
|
|
12
|
-
export declare const ensureFfmpeg: (options?: EnsureFfmpegOptions) => Promise<Result>;
|
|
13
|
-
/**
|
|
14
|
-
* @description Checks if the ffprobe binary is installed and if it is not, downloads it and puts it into your node_modules folder.
|
|
15
|
-
* @see [Documentation](https://www.remotion.dev/docs/renderer/ensure-ffprobe)
|
|
16
|
-
*/
|
|
17
|
-
export declare const ensureFfprobe: (options?: EnsureFfmpegOptions) => Promise<Result>;
|
|
18
|
-
export {};
|
package/dist/ensure-ffmpeg.js
DELETED
|
@@ -1,58 +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.ensureFfprobe = exports.ensureFfmpeg = void 0;
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const os_1 = __importDefault(require("os"));
|
|
9
|
-
const ffmpeg_flags_1 = require("./ffmpeg-flags");
|
|
10
|
-
const validate_ffmpeg_1 = require("./validate-ffmpeg");
|
|
11
|
-
const ensureFfmpegOrFfprobe = async (binary, options) => {
|
|
12
|
-
var _a;
|
|
13
|
-
const exists = (0, validate_ffmpeg_1.binaryExists)(binary);
|
|
14
|
-
const remotionRoot = (_a = options === null || options === void 0 ? void 0 : options.remotionRoot) !== null && _a !== void 0 ? _a : process.cwd();
|
|
15
|
-
if (exists) {
|
|
16
|
-
return {
|
|
17
|
-
wasAlreadyInstalled: true,
|
|
18
|
-
result: 'found-in-path',
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
if (process.platform === 'linux' && (0, fs_1.existsSync)(ffmpeg_flags_1.lambdaFfmpegPaths[binary])) {
|
|
22
|
-
return {
|
|
23
|
-
wasAlreadyInstalled: true,
|
|
24
|
-
result: 'found-in-path',
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
if ((0, ffmpeg_flags_1.ffmpegInNodeModules)(remotionRoot, binary)) {
|
|
28
|
-
return {
|
|
29
|
-
result: 'found-in-node-modules',
|
|
30
|
-
wasAlreadyInstalled: true,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const binaryUrl = (0, ffmpeg_flags_1.getBinaryDownloadUrl)(binary);
|
|
34
|
-
if (binaryUrl) {
|
|
35
|
-
await (0, ffmpeg_flags_1.downloadBinary)(remotionRoot, binaryUrl.url, binary);
|
|
36
|
-
return {
|
|
37
|
-
result: 'installed',
|
|
38
|
-
wasAlreadyInstalled: false,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
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.`);
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* @description Checks if the ffmpeg binary is installed and if it is not, downloads it and puts it into your node_modules folder.
|
|
45
|
-
* @see [Documentation](https://www.remotion.dev/docs/renderer/ensure-ffmpeg)
|
|
46
|
-
*/
|
|
47
|
-
const ensureFfmpeg = (options) => {
|
|
48
|
-
return ensureFfmpegOrFfprobe('ffmpeg', options);
|
|
49
|
-
};
|
|
50
|
-
exports.ensureFfmpeg = ensureFfmpeg;
|
|
51
|
-
/**
|
|
52
|
-
* @description Checks if the ffprobe binary is installed and if it is not, downloads it and puts it into your node_modules folder.
|
|
53
|
-
* @see [Documentation](https://www.remotion.dev/docs/renderer/ensure-ffprobe)
|
|
54
|
-
*/
|
|
55
|
-
const ensureFfprobe = (options) => {
|
|
56
|
-
return ensureFfmpegOrFfprobe('ffprobe', options);
|
|
57
|
-
};
|
|
58
|
-
exports.ensureFfprobe = ensureFfprobe;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { DownloadMap } from './assets/download-map';
|
|
2
|
-
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
3
|
-
export declare const ensurePresentationTimestampWithoutCache: ({ src, remotionRoot, ffmpegExecutable, ffprobeExecutable, }: {
|
|
4
|
-
src: string;
|
|
5
|
-
remotionRoot: string;
|
|
6
|
-
ffmpegExecutable: FfmpegExecutable;
|
|
7
|
-
ffprobeExecutable: FfmpegExecutable;
|
|
8
|
-
}) => Promise<string>;
|
|
9
|
-
export declare const ensurePresentationTimestamps: ({ downloadMap, src, remotionRoot, ffmpegExecutable, ffprobeExecutable, }: {
|
|
10
|
-
downloadMap: DownloadMap;
|
|
11
|
-
src: string;
|
|
12
|
-
remotionRoot: string;
|
|
13
|
-
ffmpegExecutable: FfmpegExecutable;
|
|
14
|
-
ffprobeExecutable: FfmpegExecutable;
|
|
15
|
-
}) => Promise<string>;
|
|
@@ -1,88 +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.ensurePresentationTimestamps = exports.ensurePresentationTimestampWithoutCache = void 0;
|
|
7
|
-
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const ffmpeg_flags_1 = require("./ffmpeg-flags");
|
|
10
|
-
const guess_extension_for_media_1 = require("./guess-extension-for-media");
|
|
11
|
-
const truthy_1 = require("./truthy");
|
|
12
|
-
let callbacks = [];
|
|
13
|
-
const getTemporaryOutputName = async ({ src, remotionRoot, ffprobeBinary, }) => {
|
|
14
|
-
const parts = src.split(path_1.default.sep);
|
|
15
|
-
// If there is no file extension for the video, then we need to temporarily add an extension
|
|
16
|
-
const lastPart = parts[parts.length - 1];
|
|
17
|
-
const extraExtension = lastPart.includes('.')
|
|
18
|
-
? null
|
|
19
|
-
: await (0, guess_extension_for_media_1.guessExtensionForVideo)({
|
|
20
|
-
src,
|
|
21
|
-
remotionRoot,
|
|
22
|
-
ffprobeBinary,
|
|
23
|
-
});
|
|
24
|
-
return parts
|
|
25
|
-
.map((p, i) => {
|
|
26
|
-
if (i === parts.length - 1) {
|
|
27
|
-
return [`pts-${p}`, extraExtension].filter(truthy_1.truthy).join('.');
|
|
28
|
-
}
|
|
29
|
-
return p;
|
|
30
|
-
})
|
|
31
|
-
.join(path_1.default.sep);
|
|
32
|
-
};
|
|
33
|
-
const ensurePresentationTimestampWithoutCache = async ({ src, remotionRoot, ffmpegExecutable, ffprobeExecutable, }) => {
|
|
34
|
-
// If there is no file extension for the video, then we need to tempoa
|
|
35
|
-
const output = await getTemporaryOutputName({
|
|
36
|
-
src,
|
|
37
|
-
remotionRoot,
|
|
38
|
-
ffprobeBinary: ffprobeExecutable,
|
|
39
|
-
});
|
|
40
|
-
await (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffmpegExecutable, remotionRoot, 'ffmpeg'), [
|
|
41
|
-
'-i',
|
|
42
|
-
src,
|
|
43
|
-
'-fflags',
|
|
44
|
-
'+genpts+igndts',
|
|
45
|
-
'-vcodec',
|
|
46
|
-
'copy',
|
|
47
|
-
'-acodec',
|
|
48
|
-
'copy',
|
|
49
|
-
output,
|
|
50
|
-
'-y',
|
|
51
|
-
]);
|
|
52
|
-
return output;
|
|
53
|
-
};
|
|
54
|
-
exports.ensurePresentationTimestampWithoutCache = ensurePresentationTimestampWithoutCache;
|
|
55
|
-
const ensurePresentationTimestamps = async ({ downloadMap, src, remotionRoot, ffmpegExecutable, ffprobeExecutable, }) => {
|
|
56
|
-
const elem = downloadMap.ensureFileHasPresentationTimestamp[src];
|
|
57
|
-
if ((elem === null || elem === void 0 ? void 0 : elem.type) === 'encoding') {
|
|
58
|
-
return new Promise((resolve) => {
|
|
59
|
-
callbacks.push({
|
|
60
|
-
src,
|
|
61
|
-
fn: (newSrc) => resolve(newSrc),
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
if ((elem === null || elem === void 0 ? void 0 : elem.type) === 'done') {
|
|
66
|
-
return elem.src;
|
|
67
|
-
}
|
|
68
|
-
downloadMap.ensureFileHasPresentationTimestamp[src] = { type: 'encoding' };
|
|
69
|
-
const output = await (0, exports.ensurePresentationTimestampWithoutCache)({
|
|
70
|
-
ffmpegExecutable,
|
|
71
|
-
ffprobeExecutable,
|
|
72
|
-
remotionRoot,
|
|
73
|
-
src,
|
|
74
|
-
});
|
|
75
|
-
callbacks = callbacks.filter((c) => {
|
|
76
|
-
if (c.src === src) {
|
|
77
|
-
c.fn(output);
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
});
|
|
82
|
-
downloadMap.ensureFileHasPresentationTimestamp[src] = {
|
|
83
|
-
type: 'done',
|
|
84
|
-
src: output,
|
|
85
|
-
};
|
|
86
|
-
return output;
|
|
87
|
-
};
|
|
88
|
-
exports.ensurePresentationTimestamps = ensurePresentationTimestamps;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { OffthreadVideoImageFormat } from 'remotion';
|
|
2
|
-
import type { DownloadMap } from './assets/download-map';
|
|
3
|
-
import type { FfmpegExecutable } from './ffmpeg-executable';
|
|
4
|
-
import type { LastFrameOptions } from './last-frame-from-video-cache';
|
|
5
|
-
export declare const getLastFrameOfVideo: (options: LastFrameOptions) => Promise<Buffer>;
|
|
6
|
-
type Options = {
|
|
7
|
-
time: number;
|
|
8
|
-
src: string;
|
|
9
|
-
ffmpegExecutable: FfmpegExecutable;
|
|
10
|
-
ffprobeExecutable: FfmpegExecutable;
|
|
11
|
-
imageFormat: OffthreadVideoImageFormat;
|
|
12
|
-
downloadMap: DownloadMap;
|
|
13
|
-
remotionRoot: string;
|
|
14
|
-
};
|
|
15
|
-
export declare const extractFrameFromVideo: (options: Options) => Promise<Buffer>;
|
|
16
|
-
export {};
|
|
@@ -1,191 +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.extractFrameFromVideo = exports.getLastFrameOfVideo = void 0;
|
|
7
|
-
const execa_1 = __importDefault(require("execa"));
|
|
8
|
-
const get_video_stream_duration_1 = require("./assets/get-video-stream-duration");
|
|
9
|
-
const determine_resize_params_1 = require("./determine-resize-params");
|
|
10
|
-
const determine_vcodec_ffmpeg_flags_1 = require("./determine-vcodec-ffmpeg-flags");
|
|
11
|
-
const ensure_presentation_timestamp_1 = require("./ensure-presentation-timestamp");
|
|
12
|
-
const ffmpeg_flags_1 = require("./ffmpeg-flags");
|
|
13
|
-
const frame_to_ffmpeg_timestamp_1 = require("./frame-to-ffmpeg-timestamp");
|
|
14
|
-
const get_can_extract_frames_fast_1 = require("./get-can-extract-frames-fast");
|
|
15
|
-
const get_frame_of_video_slow_1 = require("./get-frame-of-video-slow");
|
|
16
|
-
const get_video_info_1 = require("./get-video-info");
|
|
17
|
-
const is_beyond_last_frame_1 = require("./is-beyond-last-frame");
|
|
18
|
-
const last_frame_from_video_cache_1 = require("./last-frame-from-video-cache");
|
|
19
|
-
const p_limit_1 = require("./p-limit");
|
|
20
|
-
const perf_1 = require("./perf");
|
|
21
|
-
const truthy_1 = require("./truthy");
|
|
22
|
-
const try_to_extract_frame_of_video_fast_1 = require("./try-to-extract-frame-of-video-fast");
|
|
23
|
-
const lastFrameLimit = (0, p_limit_1.pLimit)(1);
|
|
24
|
-
const mainLimit = (0, p_limit_1.pLimit)(5);
|
|
25
|
-
const getLastFrameOfVideoFastUnlimited = async (options) => {
|
|
26
|
-
const { ffmpegExecutable, ffprobeExecutable, offset, src, downloadMap } = options;
|
|
27
|
-
const fromCache = (0, last_frame_from_video_cache_1.getLastFrameFromCache)({ ...options, offset: 0 });
|
|
28
|
-
if (fromCache) {
|
|
29
|
-
return fromCache;
|
|
30
|
-
}
|
|
31
|
-
const { duration, fps } = await (0, get_video_stream_duration_1.getVideoStreamDuration)(downloadMap, src, ffprobeExecutable, options.remotionRoot);
|
|
32
|
-
if (duration === null) {
|
|
33
|
-
throw new Error(`Could not determine the duration of ${src} using FFMPEG. The file is not supported.`);
|
|
34
|
-
}
|
|
35
|
-
if (options.specialVCodecForTransparency === 'vp8' ||
|
|
36
|
-
offset > get_can_extract_frames_fast_1.ACCEPTABLE_OFFSET_THRESHOLD) {
|
|
37
|
-
const last = await (0, get_frame_of_video_slow_1.getFrameOfVideoSlow)({
|
|
38
|
-
duration,
|
|
39
|
-
ffmpegExecutable,
|
|
40
|
-
src,
|
|
41
|
-
imageFormat: options.imageFormat,
|
|
42
|
-
specialVCodecForTransparency: options.specialVCodecForTransparency,
|
|
43
|
-
needsResize: options.needsResize,
|
|
44
|
-
offset: offset - 1000 / (fps === null ? 10 : fps),
|
|
45
|
-
fps,
|
|
46
|
-
remotionRoot: options.remotionRoot,
|
|
47
|
-
});
|
|
48
|
-
return last;
|
|
49
|
-
}
|
|
50
|
-
const actualOffset = `${duration * 1000 - offset}ms`;
|
|
51
|
-
const [stdErr, stdoutBuffer] = await (0, try_to_extract_frame_of_video_fast_1.tryToExtractFrameOfVideoFast)({
|
|
52
|
-
actualOffset,
|
|
53
|
-
ffmpegExecutable,
|
|
54
|
-
imageFormat: options.imageFormat,
|
|
55
|
-
needsResize: options.needsResize,
|
|
56
|
-
remotionRoot: options.remotionRoot,
|
|
57
|
-
specialVCodecForTransparency: options.specialVCodecForTransparency,
|
|
58
|
-
src,
|
|
59
|
-
});
|
|
60
|
-
const isEmpty = stdErr.includes('Output file is empty');
|
|
61
|
-
if (isEmpty) {
|
|
62
|
-
const unlimited = await getLastFrameOfVideoFastUnlimited({
|
|
63
|
-
ffmpegExecutable,
|
|
64
|
-
// Decrement in 10ms increments, or 1 frame (e.g. fps = 25 --> 40ms)
|
|
65
|
-
offset: offset + (fps === null ? 10 : 1000 / fps),
|
|
66
|
-
src,
|
|
67
|
-
ffprobeExecutable,
|
|
68
|
-
imageFormat: options.imageFormat,
|
|
69
|
-
specialVCodecForTransparency: options.specialVCodecForTransparency,
|
|
70
|
-
needsResize: options.needsResize,
|
|
71
|
-
downloadMap: options.downloadMap,
|
|
72
|
-
remotionRoot: options.remotionRoot,
|
|
73
|
-
});
|
|
74
|
-
return unlimited;
|
|
75
|
-
}
|
|
76
|
-
return stdoutBuffer;
|
|
77
|
-
};
|
|
78
|
-
const getLastFrameOfVideo = async (options) => {
|
|
79
|
-
const result = await lastFrameLimit(getLastFrameOfVideoFastUnlimited, options);
|
|
80
|
-
(0, last_frame_from_video_cache_1.setLastFrameInCache)(options, result);
|
|
81
|
-
return result;
|
|
82
|
-
};
|
|
83
|
-
exports.getLastFrameOfVideo = getLastFrameOfVideo;
|
|
84
|
-
const extractFrameFromVideoFn = async ({ time, ffmpegExecutable, ffprobeExecutable, imageFormat, downloadMap, remotionRoot, ...options }) => {
|
|
85
|
-
// We make a new copy of the video only for video because the conversion may affect
|
|
86
|
-
// audio rendering, so we work with 2 different files
|
|
87
|
-
const src = await (0, ensure_presentation_timestamp_1.ensurePresentationTimestamps)({
|
|
88
|
-
downloadMap,
|
|
89
|
-
src: options.src,
|
|
90
|
-
remotionRoot,
|
|
91
|
-
ffmpegExecutable,
|
|
92
|
-
ffprobeExecutable,
|
|
93
|
-
});
|
|
94
|
-
const { specialVcodecForTransparency: specialVcodec, needsResize } = await (0, get_video_info_1.getVideoInfo)(downloadMap, src, ffprobeExecutable, remotionRoot);
|
|
95
|
-
if (specialVcodec === 'vp8') {
|
|
96
|
-
const { fps } = await (0, get_video_stream_duration_1.getVideoStreamDuration)(downloadMap, src, ffprobeExecutable, remotionRoot);
|
|
97
|
-
return (0, get_frame_of_video_slow_1.getFrameOfVideoSlow)({
|
|
98
|
-
ffmpegExecutable,
|
|
99
|
-
imageFormat,
|
|
100
|
-
specialVCodecForTransparency: specialVcodec,
|
|
101
|
-
src,
|
|
102
|
-
duration: time,
|
|
103
|
-
needsResize,
|
|
104
|
-
offset: 0,
|
|
105
|
-
fps,
|
|
106
|
-
remotionRoot,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
if ((0, is_beyond_last_frame_1.isBeyondLastFrame)(downloadMap, src, time)) {
|
|
110
|
-
const lastFrame = await (0, exports.getLastFrameOfVideo)({
|
|
111
|
-
ffmpegExecutable,
|
|
112
|
-
ffprobeExecutable,
|
|
113
|
-
offset: 0,
|
|
114
|
-
src,
|
|
115
|
-
imageFormat,
|
|
116
|
-
specialVCodecForTransparency: specialVcodec,
|
|
117
|
-
needsResize,
|
|
118
|
-
downloadMap,
|
|
119
|
-
remotionRoot,
|
|
120
|
-
});
|
|
121
|
-
return lastFrame;
|
|
122
|
-
}
|
|
123
|
-
const ffmpegTimestamp = (0, frame_to_ffmpeg_timestamp_1.frameToFfmpegTimestamp)(time);
|
|
124
|
-
const { stdout, stderr } = (0, execa_1.default)(await (0, ffmpeg_flags_1.getExecutableBinary)(ffmpegExecutable, remotionRoot, 'ffmpeg'), [
|
|
125
|
-
'-ss',
|
|
126
|
-
ffmpegTimestamp,
|
|
127
|
-
...(0, determine_vcodec_ffmpeg_flags_1.determineVcodecFfmpegFlags)(specialVcodec),
|
|
128
|
-
'-i',
|
|
129
|
-
src,
|
|
130
|
-
'-frames:v',
|
|
131
|
-
'1',
|
|
132
|
-
'-f',
|
|
133
|
-
'image2pipe',
|
|
134
|
-
'-vcodec',
|
|
135
|
-
imageFormat === 'jpeg' ? 'mjpeg' : 'png',
|
|
136
|
-
...(0, determine_resize_params_1.determineResizeParams)(needsResize),
|
|
137
|
-
'-',
|
|
138
|
-
].filter(truthy_1.truthy), {
|
|
139
|
-
buffer: false,
|
|
140
|
-
});
|
|
141
|
-
if (!stderr) {
|
|
142
|
-
throw new Error('unexpectedly did not get stderr');
|
|
143
|
-
}
|
|
144
|
-
if (!stdout) {
|
|
145
|
-
throw new Error('unexpectedly did not get stdout');
|
|
146
|
-
}
|
|
147
|
-
const stdoutChunks = [];
|
|
148
|
-
const stderrChunks = [];
|
|
149
|
-
const stderrStringProm = new Promise((resolve, reject) => {
|
|
150
|
-
stderr.on('data', (d) => stderrChunks.push(d));
|
|
151
|
-
stderr.on('error', (err) => reject(err));
|
|
152
|
-
stderr.on('end', () => resolve(Buffer.concat(stderrChunks).toString('utf8')));
|
|
153
|
-
});
|
|
154
|
-
const stdoutBuffer = new Promise((resolve, reject) => {
|
|
155
|
-
stdout.on('data', (d) => stdoutChunks.push(d));
|
|
156
|
-
stdout.on('error', (err) => reject(err));
|
|
157
|
-
stdout.on('end', () => resolve(Buffer.concat(stdoutChunks)));
|
|
158
|
-
});
|
|
159
|
-
const [stderrStr, stdOut] = await Promise.all([
|
|
160
|
-
stderrStringProm,
|
|
161
|
-
stdoutBuffer,
|
|
162
|
-
]);
|
|
163
|
-
if (stderrStr.includes('Output file is empty')) {
|
|
164
|
-
(0, is_beyond_last_frame_1.markAsBeyondLastFrame)(downloadMap, src, time);
|
|
165
|
-
const last = await (0, exports.getLastFrameOfVideo)({
|
|
166
|
-
ffmpegExecutable,
|
|
167
|
-
ffprobeExecutable,
|
|
168
|
-
offset: 0,
|
|
169
|
-
src,
|
|
170
|
-
imageFormat,
|
|
171
|
-
specialVCodecForTransparency: specialVcodec,
|
|
172
|
-
needsResize,
|
|
173
|
-
downloadMap,
|
|
174
|
-
remotionRoot,
|
|
175
|
-
});
|
|
176
|
-
return last;
|
|
177
|
-
}
|
|
178
|
-
if (stdOut.length === 0) {
|
|
179
|
-
console.log('FFMPEG Logs:');
|
|
180
|
-
console.log(stderrStr);
|
|
181
|
-
throw new Error("Couldn't extract frame from video - FFMPEG did not return any data. Check logs to see more information");
|
|
182
|
-
}
|
|
183
|
-
return stdOut;
|
|
184
|
-
};
|
|
185
|
-
const extractFrameFromVideo = async (options) => {
|
|
186
|
-
const perf = (0, perf_1.startPerfMeasure)('extract-frame');
|
|
187
|
-
const res = await mainLimit(extractFrameFromVideoFn, options);
|
|
188
|
-
(0, perf_1.stopPerfMeasure)(perf);
|
|
189
|
-
return res;
|
|
190
|
-
};
|
|
191
|
-
exports.extractFrameFromVideo = extractFrameFromVideo;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type FfmpegExecutable = string | null;
|