@remotion/renderer 4.0.0-offthread.22 → 4.0.0-offthread.28
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/extract-frame-from-video.d.ts +6 -3
- package/dist/extract-frame-from-video.js +68 -16
- package/dist/frame-to-ffmpeg-timestamp.d.ts +0 -0
- package/dist/frame-to-ffmpeg-timestamp.js +0 -0
- package/dist/offthread-video-server.d.ts +0 -0
- package/dist/offthread-video-server.js +2 -8
- package/package.json +3 -3
|
@@ -6,9 +6,12 @@ export declare const getLastFrameOfVideo: ({ ffmpegExecutable, offset, src, }: {
|
|
|
6
6
|
ffmpegExecutable: FfmpegExecutable;
|
|
7
7
|
offset: number;
|
|
8
8
|
src: string;
|
|
9
|
-
}) => Promise<
|
|
10
|
-
|
|
9
|
+
}) => Promise<Buffer>;
|
|
10
|
+
declare type Options = {
|
|
11
11
|
time: number;
|
|
12
12
|
src: string;
|
|
13
13
|
ffmpegExecutable: FfmpegExecutable;
|
|
14
|
-
}
|
|
14
|
+
};
|
|
15
|
+
export declare const extractFrameFromVideoFn: ({ time, src, ffmpegExecutable, }: Options) => Promise<Buffer>;
|
|
16
|
+
export declare const extractFrameFromVideo: (options: Options) => Promise<Buffer>;
|
|
17
|
+
export {};
|
|
@@ -3,9 +3,10 @@ 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 = exports.getLastFrameOfVideo = exports.streamToString = void 0;
|
|
6
|
+
exports.extractFrameFromVideo = exports.extractFrameFromVideoFn = 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
|
+
const p_limit_1 = require("./p-limit");
|
|
9
10
|
function streamToString(stream) {
|
|
10
11
|
const chunks = [];
|
|
11
12
|
return new Promise((resolve, reject) => {
|
|
@@ -15,7 +16,7 @@ function streamToString(stream) {
|
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
18
|
exports.streamToString = streamToString;
|
|
18
|
-
const getLastFrameOfVideo =
|
|
19
|
+
const getLastFrameOfVideo = ({ ffmpegExecutable, offset, src, }) => {
|
|
19
20
|
if (offset > 100) {
|
|
20
21
|
throw new Error('could not get last frame of ' +
|
|
21
22
|
src +
|
|
@@ -33,14 +34,39 @@ const getLastFrameOfVideo = async ({ ffmpegExecutable, offset, src, }) => {
|
|
|
33
34
|
'image2pipe',
|
|
34
35
|
'-',
|
|
35
36
|
]);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return (0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: offset + 10, src });
|
|
37
|
+
if (!stderr) {
|
|
38
|
+
throw new Error('unexpectedly did not get stderr');
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (!stdout) {
|
|
41
|
+
throw new Error('unexpectedly did not get stdout');
|
|
42
|
+
}
|
|
43
|
+
const chunks = [];
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
let isEmpty = false;
|
|
46
|
+
stderr.on('data', (d) => {
|
|
47
|
+
if (d.toString().includes('Output file is empty')) {
|
|
48
|
+
isEmpty = true;
|
|
49
|
+
(0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: offset + 10, src })
|
|
50
|
+
.then((frame) => resolve(frame))
|
|
51
|
+
.catch((err) => reject(err));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
stdout.on('data', (d) => {
|
|
55
|
+
chunks.push(d);
|
|
56
|
+
});
|
|
57
|
+
stdout.on('error', (err) => {
|
|
58
|
+
reject(err);
|
|
59
|
+
});
|
|
60
|
+
stdout.on('end', () => {
|
|
61
|
+
if (!isEmpty) {
|
|
62
|
+
resolve(Buffer.concat(chunks));
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
});
|
|
41
66
|
};
|
|
42
67
|
exports.getLastFrameOfVideo = getLastFrameOfVideo;
|
|
43
|
-
const
|
|
68
|
+
const limit = (0, p_limit_1.pLimit)(5);
|
|
69
|
+
const extractFrameFromVideoFn = ({ time, src, ffmpegExecutable, }) => {
|
|
44
70
|
const ffmpegTimestamp = (0, frame_to_ffmpeg_timestamp_1.frameToFfmpegTimestamp)(time);
|
|
45
71
|
const { stdout, stderr } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
|
|
46
72
|
'-ss',
|
|
@@ -52,15 +78,41 @@ const extractFrameFromVideo = async ({ time, src, ffmpegExecutable, }) => {
|
|
|
52
78
|
'-f',
|
|
53
79
|
'image2pipe',
|
|
54
80
|
'-',
|
|
55
|
-
]
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
], {
|
|
82
|
+
buffer: false,
|
|
83
|
+
});
|
|
84
|
+
if (!stderr) {
|
|
85
|
+
throw new Error('unexpectedly did not get stderr');
|
|
86
|
+
}
|
|
87
|
+
if (!stdout) {
|
|
88
|
+
throw new Error('unexpectedly did not get stdout');
|
|
63
89
|
}
|
|
64
|
-
|
|
90
|
+
const chunks = [];
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
let isEmpty = false;
|
|
93
|
+
stderr === null || stderr === void 0 ? void 0 : stderr.on('data', (d) => {
|
|
94
|
+
if (d.toString().includes('Output file is empty')) {
|
|
95
|
+
isEmpty = true;
|
|
96
|
+
(0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: 0, src })
|
|
97
|
+
.then((frame) => resolve(frame))
|
|
98
|
+
.catch((err) => reject(err));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
stdout === null || stdout === void 0 ? void 0 : stdout.on('data', (d) => {
|
|
102
|
+
chunks.push(d);
|
|
103
|
+
});
|
|
104
|
+
stdout === null || stdout === void 0 ? void 0 : stdout.on('error', (err) => {
|
|
105
|
+
reject(err);
|
|
106
|
+
});
|
|
107
|
+
stdout === null || stdout === void 0 ? void 0 : stdout.on('end', () => {
|
|
108
|
+
if (!isEmpty) {
|
|
109
|
+
resolve(Buffer.concat(chunks));
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
exports.extractFrameFromVideoFn = extractFrameFromVideoFn;
|
|
115
|
+
const extractFrameFromVideo = (options) => {
|
|
116
|
+
return limit(exports.extractFrameFromVideoFn, options);
|
|
65
117
|
};
|
|
66
118
|
exports.extractFrameFromVideo = extractFrameFromVideo;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -50,14 +50,8 @@ const startOffthreadVideoServer = (ffmpegExecutable, downloadDir, onDownload, on
|
|
|
50
50
|
throw new Error('no readable from ffmpeg');
|
|
51
51
|
}
|
|
52
52
|
res.writeHead(200);
|
|
53
|
-
readable
|
|
54
|
-
|
|
55
|
-
.on('close', () => {
|
|
56
|
-
res.end();
|
|
57
|
-
})
|
|
58
|
-
.on('error', (err) => {
|
|
59
|
-
onError(err);
|
|
60
|
-
});
|
|
53
|
+
res.write(readable);
|
|
54
|
+
res.end();
|
|
61
55
|
})
|
|
62
56
|
.catch((err) => {
|
|
63
57
|
res.writeHead(500);
|
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.28+4c660b5d3",
|
|
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.28+4c660b5d3",
|
|
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": "4c660b5d347a5c6213abcc2021442f35d84af844"
|
|
63
63
|
}
|