Skip to content

Commit 911a724

Browse files
authored
Merge pull request #304 from mifi/dependabot/npm_and_yarn/execa-9.5.2
Bump execa from 6.1.0 to 9.5.2
2 parents 2144705 + f540128 commit 911a724

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"@types/ndarray": "^1.0.14",
2323
"canvas": "^2.11.2",
2424
"compare-versions": "^6.1.0",
25-
"execa": "^8.0.1",
25+
"execa": "^9.5.2",
2626
"fabric": "^6.5.4",
2727
"file-type": "^20.0.0",
2828
"file-url": "^4.0.0",

src/configuration.ts

-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,6 @@ export class Configuration {
250250
this.keepTmp = input.keepTmp ?? false;
251251
this.fast = input.fast ?? false;
252252

253-
this.defaults = input.defaults ?? {};
254253
this.ffmpegPath = input.ffmpegPath ?? "ffmpeg";
255254
this.ffprobePath = input.ffprobePath ?? "ffprobe";
256255

src/ffmpeg.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function configureFf(params: Partial<FfmpegConfig>) {
7474
await testFf(config.ffprobePath, "ffprobe");
7575
}
7676

77-
export function ffmpeg(args: string[], options?: Options<null>) {
77+
export function ffmpeg(args: string[], options?: Options) {
7878
if (config.enableFfmpegLog) console.log(`$ ${config.ffmpegPath} ${args.join(" ")}`);
7979
return execa(config.ffmpegPath, [...getFfmpegCommonArgs(), ...args], options);
8080
}

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import assert from "assert";
2-
import { ExecaChildProcess } from "execa";
2+
import { Options, ResultPromise } from "execa";
33
import fsExtra from "fs-extra";
44
import JSON5 from "json5";
55

@@ -247,15 +247,15 @@ async function Editly(input: ConfigurationOptions): Promise<void> {
247247
outPath,
248248
];
249249
return ffmpeg(args, {
250-
encoding: null,
250+
encoding: "buffer",
251251
buffer: false,
252252
stdin: "pipe",
253253
stdout: process.stdout,
254254
stderr: process.stderr,
255255
});
256256
}
257257

258-
let outProcess: ExecaChildProcess<Buffer<ArrayBufferLike>> | undefined = undefined;
258+
let outProcess: ResultPromise<Options> | undefined;
259259
let outProcessExitCode;
260260

261261
let frameSource1;
@@ -465,7 +465,7 @@ async function Editly(input: ConfigurationOptions): Promise<void> {
465465
await outProcess;
466466
} catch (err) {
467467
// eslint-disable-next-line @typescript-eslint/no-explicit-any
468-
if (outProcessExitCode !== 0 && !(err as any).killed) throw err;
468+
if (outProcessExitCode !== 0 && !(err as any).isTerminated) throw err;
469469
}
470470
} finally {
471471
if (!keepTmp) await fsExtra.remove(tmpDir);

src/sources/video.ts

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import assert from "assert";
2+
import { ExecaError } from "execa";
23
import * as fabric from "fabric/node";
34
import { defineFrameSource } from "../api/index.js";
45
import { ffmpeg, readFileStreams } from "../ffmpeg.js";
@@ -129,15 +130,27 @@ export default defineFrameSource<VideoLayer>("video", async (options) => {
129130
"-",
130131
];
131132

133+
const controller = new AbortController();
134+
132135
const ps = ffmpeg(args, {
133-
encoding: null,
136+
encoding: "buffer",
134137
buffer: false,
135138
stdin: "ignore",
136139
stdout: "pipe",
137140
stderr: process.stderr,
141+
// ffmpeg doesn't like to stop, force it
142+
killSignal: "SIGKILL",
143+
cancelSignal: controller.signal,
144+
});
145+
146+
// Ignore errors if the process is aborted
147+
ps.catch((err: ExecaError) => {
148+
if (!err.isCanceled) throw err;
149+
if (verbose) console.log("ffmpeg process aborted", path);
138150
});
139151

140152
const stream = ps.stdout!;
153+
stream.pause();
141154

142155
let timeout: NodeJS.Timeout;
143156
let ended = false;
@@ -272,7 +285,7 @@ export default defineFrameSource<VideoLayer>("video", async (options) => {
272285

273286
const close = () => {
274287
if (verbose) console.log("Close", path);
275-
ps.cancel();
288+
controller.abort();
276289
};
277290

278291
return {

0 commit comments

Comments
 (0)