Run ffmpeg or ffprobe (VESTRA_FFMPEG / VESTRA_FFPROBE when set, else
found on PATH) without a shell. Rejects unavailable (not found), timeout,
failed (non-zero exit; message is the last stderr line), invalid
(output over maxOutput, default 16 MiB), aborted (signal). Timeout,
signal and disposing the scope end the process.
Arguments are passed as-is (no quoting needed). On Windows PATHEXT is
honoured. Ending sends SIGTERM, then SIGKILL after 300 ms (immediate on
Windows).
The plugin writes the first ten seconds of the file to a new file. run
starts ffmpeg without a shell (arguments pass as they are, no quoting)
and resolves with its output once it exits with 0; a failure rejects
with the last line ffmpeg printed.
await plugin.tools.run(
"ffmpeg",
["-y", "-i", input, "-t", "10", "-c", "copy", output],
{ timeoutMs: 60_000 }, // give up after a minute
);
Whether the tool can be found.
The Export item is disabled with a reason when ffmpeg is not installed.
available looks the tool up (a found path is kept, a miss is looked
up again on the next call, so installing it later is noticed).
const hasFfmpeg = await plugin.tools.available("ffmpeg");
plugin.commands.add({
id: "export",
path: ["@video", "Export…"],
enabled: hasFfmpeg,
// Shown with the greyed-out item.
reason: hasFfmpeg ? null : "Install ffmpeg to export",
run() {},
});
plugin.tools: ffmpeg and ffprobe, run in this plugin's process.Example: Read a file's format with ffprobe
The plugin gets a media file's container details as JSON.
availablesays whether ffprobe can be found (VESTRA_FFPROBE, thenPATH);runstarts it from the plugin's own process without a shell and resolves with its output as bytes once it exits, or rejects when it fails (failed, with the last stderr line) or takes longer thantimeoutMs.Remarks
ffmpeg and ffprobe run as child processes of the plugin. When
VESTRA_FFMPEG/VESTRA_FFPROBEis set, only that path is used (an invalid one means the tool is not found); otherwise the tool is searched onPATH. A found path is kept for the plugin's run, a miss is looked up again next time. Disposing the scope ends a running process.Since
1.0.0