Release the resource. Resolves once the player confirmed the release (or immediately for purely local resources). Never rejects.
A "Turn feature off" item removes the feature's own menu item at once,
before the plugin stops. dispose takes the command out of the menu and
the binding table and resolves once the player confirmed it; the id can
be added again later.
const extra = plugin.commands.add({ id: "extra", path: ["Tools", "Extra"], run() {} });
plugin.commands.add({
id: "extra-off",
path: ["Tools", "Turn extra off"],
run: () => extra.dispose(), // never rejects
});
Start exporting; the job runs in the host's offline worker. One snapshot can be exported several times.
A stream copy (format: "copy") writes the video stream and the
snapshot's audio track as they are in the file, without decoding: lossless
and about as fast as the disk, but a copy can only begin on a keyframe. It
starts at the video's last keyframe at or before the snapshot time (its
first keyframe when the video itself starts later; keyframes an MP4 edit
list discards do not count) and is cut at end, where it may run a few
frames past end. An open GOP can write a frame or two that present before
the keyframe; start includes them. The finished job's outcome gives the
start and end actually written; a plugin that previews the cut (with
plugin.tools.run and ffprobe's packet flags, say) shows those once the
job is done. Copies need a raw snapshot (effects and burned-in subtitles
need a re-encode) and leave subtitle tracks and chapters out. auto writes
MP4 for H.264, HEVC, AV1 or MPEG-4 video with AAC, MP3, AC-3, E-AC-3 or
ALAC audio (or none), and MKV for anything else. A copy the player cannot
make (no video stream, a cover image, an external audio track, codecs mp4
cannot hold) ends failed with the code unsupported.
invalid (rejects) Bad options (quality outside 1–100, a
relative destination, a clip end not after the snapshot time or
past the duration, an ExportEncoding value outside its set,
copy from a processed snapshot).
A clip from the snapshot time to 30 seconds later is written as MP4.
export resolves once the job is accepted; the job then runs in the
player's offline worker, and done resolves with its terminal state,
whose outcome has the destination or the error.
const job = await snapshot.export({ format: "mp4", destination: "/tmp/clip.mp4", end: snapshot.time + 30 });
const end = await job.done;
if (end.status !== "completed") await plugin.osd.show("Export {}", [end.status]);
The clip is copied as it is in the file. A copy starts on a keyframe,
so the OSD says where it actually starts; a file the player cannot
copy ends with unsupported, and the plugin offers a re-encode instead.
const job = await snapshot.export({ format: "copy", destination: "/tmp/clip.mp4", end: snapshot.time + 20 });
const state = await job.done;
const outcome = state.outcome;
// The copy starts on a keyframe: outcome.start says where.
if (outcome && "destination" in outcome)
await plugin.osd.show("Saved {} from {} s", [outcome.destination, (outcome.start ?? snapshot.time).toFixed(1)]);
// Codecs the container cannot hold, a cover image, …
else if (outcome && "error" in outcome && outcome.error.code === "unsupported")
await plugin.osd.show("Fast cut is not possible for this file");
ReadonlykindWithout or with effects.
ReadonlytimeSource time in seconds.
ReadonlysourceThe source path or URL.
ReadonlydurationMedia duration in seconds (the backend's estimate).
ReadonlyaudioThe frozen audio track id, null for none.
ReadonlypresentationProcessed snapshots: output size and the frozen processing revision.
Output width in pixels.
Output height in pixels.
ReadonlyprocessingThe frozen processing revision (processed snapshots).
A frozen, immutable input for exports. Dispose to release it.
Remarks
A frozen input, from MediaCapture.capture: the source, the time and (processed) the effects and subtitle as they were. Exports read it in the player's offline worker, so one snapshot can be exported several times and playback is unaffected. Disposing it releases the player's copy; an export using it after that fails with
released.Example: Export one frame as PNG and as JPEG
The same frozen frame is written twice, lossless and compressed. Each
exportstarts a job of its own; the snapshot is released after both are done.Since
1.0.0