ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
13.63k stars 787 forks source link

exec, abort signal #572

Closed abernier closed 10 months ago

abernier commented 10 months ago

I know there is global ffmpeg.terminate, but is there a way (maybe using send?) to "abort" a single ffmpeg.exec(cmd) ?

It can for ex be an AbortController signal like in fetch:

const controller = new AbortController();
ffmpeg.exec(cmd, -1, {
  signal: controller.signal
})

// later...
controller.abort();
abernier commented 10 months ago

Maybe we could pass the signal to the centralised FFmpeg.prototype.#send method with a 3rd parameter?

https://github.com/ffmpegwasm/ffmpeg.wasm/blob/9110bb0a510291cff8b481a8b6f6327e98df2018/packages/ffmpeg/src/classes.ts#L86-L100

abernier commented 10 months ago

Here is my try https://github.com/ffmpegwasm/ffmpeg.wasm/pull/573

divyenduz commented 4 months ago

Question: is this expected to also terminate a running exec? Or is the user expected to call ffmpeg.terminate manually? Currently, termination is manual