@remotion/renderer 4.0.0-offthread.21 → 4.0.0-offthread.22
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.
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { FfmpegExecutable } from 'remotion';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
export declare function streamToString(stream: Readable): Promise<string>;
|
|
5
|
+
export declare const getLastFrameOfVideo: ({ ffmpegExecutable, offset, src, }: {
|
|
6
|
+
ffmpegExecutable: FfmpegExecutable;
|
|
7
|
+
offset: number;
|
|
8
|
+
src: string;
|
|
9
|
+
}) => Promise<Readable>;
|
|
3
10
|
export declare const extractFrameFromVideo: ({ time, src, ffmpegExecutable, }: {
|
|
4
11
|
time: number;
|
|
5
12
|
src: string;
|
|
6
13
|
ffmpegExecutable: FfmpegExecutable;
|
|
7
|
-
}) =>
|
|
14
|
+
}) => Promise<Readable | null>;
|
|
@@ -3,12 +3,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.extractFrameFromVideo = void 0;
|
|
6
|
+
exports.extractFrameFromVideo = exports.getLastFrameOfVideo = exports.streamToString = void 0;
|
|
7
7
|
const execa_1 = __importDefault(require("execa"));
|
|
8
8
|
const frame_to_ffmpeg_timestamp_1 = require("./frame-to-ffmpeg-timestamp");
|
|
9
|
-
|
|
9
|
+
function streamToString(stream) {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
stream.on('data', (chunk) => chunks.push(Buffer.from(chunk)));
|
|
13
|
+
stream.on('error', (err) => reject(err));
|
|
14
|
+
stream.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
exports.streamToString = streamToString;
|
|
18
|
+
const getLastFrameOfVideo = async ({ ffmpegExecutable, offset, src, }) => {
|
|
19
|
+
if (offset > 100) {
|
|
20
|
+
throw new Error('could not get last frame of ' +
|
|
21
|
+
src +
|
|
22
|
+
'. Tried to seek 100ms before the end of the video and no frame was found. The video container has a duration that is longer than it contains video.');
|
|
23
|
+
}
|
|
24
|
+
const actualOffset = `-${offset + 10}ms`;
|
|
25
|
+
const { stdout, stderr } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
|
|
26
|
+
'-sseof',
|
|
27
|
+
actualOffset,
|
|
28
|
+
'-i',
|
|
29
|
+
src,
|
|
30
|
+
'-frames:v',
|
|
31
|
+
'1',
|
|
32
|
+
'-f',
|
|
33
|
+
'image2pipe',
|
|
34
|
+
'-',
|
|
35
|
+
]);
|
|
36
|
+
const info = await streamToString(stderr);
|
|
37
|
+
if (info.includes('Output file is empty')) {
|
|
38
|
+
return (0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: offset + 10, src });
|
|
39
|
+
}
|
|
40
|
+
return stdout;
|
|
41
|
+
};
|
|
42
|
+
exports.getLastFrameOfVideo = getLastFrameOfVideo;
|
|
43
|
+
const extractFrameFromVideo = async ({ time, src, ffmpegExecutable, }) => {
|
|
10
44
|
const ffmpegTimestamp = (0, frame_to_ffmpeg_timestamp_1.frameToFfmpegTimestamp)(time);
|
|
11
|
-
const { stdout } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
|
|
45
|
+
const { stdout, stderr } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
|
|
12
46
|
'-ss',
|
|
13
47
|
ffmpegTimestamp,
|
|
14
48
|
'-i',
|
|
@@ -19,6 +53,14 @@ const extractFrameFromVideo = ({ time, src, ffmpegExecutable, }) => {
|
|
|
19
53
|
'image2pipe',
|
|
20
54
|
'-',
|
|
21
55
|
]);
|
|
56
|
+
const info = await streamToString(stderr);
|
|
57
|
+
if (info.includes('Output file is empty')) {
|
|
58
|
+
return (0, exports.getLastFrameOfVideo)({
|
|
59
|
+
ffmpegExecutable,
|
|
60
|
+
offset: 0,
|
|
61
|
+
src,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
22
64
|
return stdout;
|
|
23
65
|
};
|
|
24
66
|
exports.extractFrameFromVideo = extractFrameFromVideo;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remotion/renderer",
|
|
3
|
-
"version": "4.0.0-offthread.
|
|
3
|
+
"version": "4.0.0-offthread.22+0c1f87dbc",
|
|
4
4
|
"description": "Renderer for Remotion",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"execa": "5.1.1",
|
|
24
24
|
"puppeteer-core": "13.5.1",
|
|
25
|
-
"remotion": "4.0.0-offthread.
|
|
25
|
+
"remotion": "4.0.0-offthread.22+0c1f87dbc",
|
|
26
26
|
"serve-handler": "6.1.3",
|
|
27
27
|
"source-map": "^0.8.0-beta.0"
|
|
28
28
|
},
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "0c1f87dbc03f756647d542172cbd3c067c19154a"
|
|
63
63
|
}
|