@remotion/renderer 4.0.0-offthread.32 → 4.0.0-offthread.34
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.js +48 -34
- package/package.json +3 -3
|
@@ -16,7 +16,7 @@ function streamToString(stream) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
exports.streamToString = streamToString;
|
|
19
|
-
const getLastFrameOfVideo = ({ ffmpegExecutable, offset, src, }) => {
|
|
19
|
+
const getLastFrameOfVideo = async ({ ffmpegExecutable, offset, src, }) => {
|
|
20
20
|
if (offset > 100) {
|
|
21
21
|
throw new Error('could not get last frame of ' +
|
|
22
22
|
src +
|
|
@@ -40,33 +40,34 @@ const getLastFrameOfVideo = ({ ffmpegExecutable, offset, src, }) => {
|
|
|
40
40
|
if (!stdout) {
|
|
41
41
|
throw new Error('unexpectedly did not get stdout');
|
|
42
42
|
}
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
stderr.on('data', (d) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.catch((err) => reject(err));
|
|
52
|
-
}
|
|
53
|
-
});
|
|
43
|
+
const stderrChunks = [];
|
|
44
|
+
const stdoutChunks = [];
|
|
45
|
+
const stdErrString = new Promise((resolve, reject) => {
|
|
46
|
+
stderr.on('data', (d) => stderrChunks.push(d));
|
|
47
|
+
stderr.on('error', (err) => reject(err));
|
|
48
|
+
stderr.on('end', () => resolve(Buffer.concat(stderrChunks).toString('utf-8')));
|
|
49
|
+
});
|
|
50
|
+
const stdoutChunk = new Promise((resolve, reject) => {
|
|
54
51
|
stdout.on('data', (d) => {
|
|
55
|
-
|
|
52
|
+
stdoutChunks.push(d);
|
|
56
53
|
});
|
|
57
54
|
stdout.on('error', (err) => {
|
|
58
55
|
reject(err);
|
|
59
56
|
});
|
|
60
57
|
stdout.on('end', () => {
|
|
61
|
-
|
|
62
|
-
resolve(Buffer.concat(chunks));
|
|
63
|
-
}
|
|
58
|
+
resolve(Buffer.concat(stdoutChunks));
|
|
64
59
|
});
|
|
65
60
|
});
|
|
61
|
+
const [stdErr, stdoutBuffer] = await Promise.all([stdErrString, stdoutChunk]);
|
|
62
|
+
const isEmpty = stdErr.includes('Output file is empty');
|
|
63
|
+
if (isEmpty) {
|
|
64
|
+
return (0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: offset + 10, src });
|
|
65
|
+
}
|
|
66
|
+
return stdoutBuffer;
|
|
66
67
|
};
|
|
67
68
|
exports.getLastFrameOfVideo = getLastFrameOfVideo;
|
|
68
69
|
const limit = (0, p_limit_1.pLimit)(5);
|
|
69
|
-
const extractFrameFromVideoFn = ({ time, src, ffmpegExecutable, }) => {
|
|
70
|
+
const extractFrameFromVideoFn = async ({ time, src, ffmpegExecutable, }) => {
|
|
70
71
|
const ffmpegTimestamp = (0, frame_to_ffmpeg_timestamp_1.frameToFfmpegTimestamp)(time);
|
|
71
72
|
const { stdout, stderr } = (0, execa_1.default)(ffmpegExecutable !== null && ffmpegExecutable !== void 0 ? ffmpegExecutable : 'ffmpeg', [
|
|
72
73
|
'-ss',
|
|
@@ -87,29 +88,42 @@ const extractFrameFromVideoFn = ({ time, src, ffmpegExecutable, }) => {
|
|
|
87
88
|
if (!stdout) {
|
|
88
89
|
throw new Error('unexpectedly did not get stdout');
|
|
89
90
|
}
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
stderr
|
|
94
|
-
|
|
95
|
-
isEmpty = true;
|
|
96
|
-
(0, exports.getLastFrameOfVideo)({ ffmpegExecutable, offset: 0, src })
|
|
97
|
-
.then((frame) => resolve(frame))
|
|
98
|
-
.catch((err) => reject(err));
|
|
99
|
-
}
|
|
91
|
+
const stdoutChunks = [];
|
|
92
|
+
const stderrChunks = [];
|
|
93
|
+
const stderrStringProm = new Promise((resolve, reject) => {
|
|
94
|
+
stderr.on('data', (d) => {
|
|
95
|
+
stderrChunks.push(d);
|
|
100
96
|
});
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
stderr.on('error', (err) => {
|
|
98
|
+
reject(err);
|
|
103
99
|
});
|
|
104
|
-
|
|
100
|
+
stderr.on('end', () => {
|
|
101
|
+
resolve(Buffer.concat(stderrChunks).toString('utf8'));
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
const stdoutBuffer = new Promise((resolve, reject) => {
|
|
105
|
+
stdout.on('data', (d) => {
|
|
106
|
+
stdoutChunks.push(d);
|
|
107
|
+
});
|
|
108
|
+
stdout.on('error', (err) => {
|
|
105
109
|
reject(err);
|
|
106
110
|
});
|
|
107
|
-
stdout
|
|
108
|
-
|
|
109
|
-
resolve(Buffer.concat(chunks));
|
|
110
|
-
}
|
|
111
|
+
stdout.on('end', () => {
|
|
112
|
+
resolve(Buffer.concat(stdoutChunks));
|
|
111
113
|
});
|
|
112
114
|
});
|
|
115
|
+
const [stderrStr, stdOut] = await Promise.all([
|
|
116
|
+
stderrStringProm,
|
|
117
|
+
stdoutBuffer,
|
|
118
|
+
]);
|
|
119
|
+
if (stderrStr.includes('Output file is empty')) {
|
|
120
|
+
return (0, exports.getLastFrameOfVideo)({
|
|
121
|
+
ffmpegExecutable,
|
|
122
|
+
offset: 0,
|
|
123
|
+
src,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
return stdOut;
|
|
113
127
|
};
|
|
114
128
|
exports.extractFrameFromVideoFn = extractFrameFromVideoFn;
|
|
115
129
|
const extractFrameFromVideo = (options) => {
|
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.34+5888bc369",
|
|
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.34+5888bc369",
|
|
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": "5888bc369ebc9edf6ecb60a7214f01ca4844b3a0"
|
|
63
63
|
}
|