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
});
Replace this handle's shader list (last write wins); [] withdraws
it.
Absolute paths of shader files in this plugin's package or data directory, in the order they run.
Never throws: a refused list shows in status (invalid, missing,
limit, unsupported, and previous-crash: see
the interface's remarks) and goes to Scope.onError, and what the
player held stays.
The plugin offers a light and a strong preset; picking one replaces the handle's list in one request. The files were written to the plugin's data directory when the user imported them.
const presets: Record<string, string[]> = {
light: [join(plugin.dataDirectory, "denoise.glsl")],
strong: [join(plugin.dataDirectory, "denoise.glsl"), join(plugin.dataDirectory, "sharpen.glsl")],
};
plugin.video.shaders("presets").set(presets.strong!);
Withdraw this handle's shaders (the same as set([])).
A Video menu item turns the plugin's shader on and off. Clearing keeps the handle, so the next pick sets the list again.
const shaders = plugin.video.shaders();
let on = false;
plugin.commands.add({
id: "toggle-shader",
path: ["@video", "Sharpen (Shader)"],
checked: () => on,
run: () => {
on = !on;
// Clearing keeps the handle; the next pick sets the list again.
if (on) shaders.set([file]);
else shaders.clear();
},
});
The status changed, including later pushes (a compile failure, a switch to software rendering).
The OSD shows mpv's message when the plugin's shader fails to compile.
The player pushes that failure after the list was accepted, so it
arrives through onStatus, not as a refused set.
const shaders = plugin.video.shaders();
shaders.onStatus((status) => {
if (status.state === "failed") void plugin.osd.show("Shader: {}", [status.error.message]);
});
This plugin's own GPU shaders, from
plugin.video.shaders(id): mpv user shaders (.glsl,//!HOOK…) that the GPU renderer runs on every frame.Remarks
Any number of plugins hold shader handles at the same time (unlike RenderOptions, which has one owner). The player joins every handle's list in a stable order, after the render options' own
shaders: built-in plugins first, then installed plugins in the order they were first installed, then development loads (--plugin); ties by plugin id, and a plugin's handles byid. At most 16 shaders across all handles (limitbeyond, nothing changes); the render options keep their own 16.Files must be this plugin's own: absolute paths inside its package directory or Plugin.dataDirectory after following links, each at most 16 MiB. Elsewhere:
invalid; a file that does not exist:missing. The player reads the files when the list is set.GPU rendering only (macOS; Windows with the Picture panel's GPU Rendering turned on): under software rendering a non-empty list is
failedwithunsupported, and a switch to software during the run pushesunsupportedto every handle with shaders and removes every list (they no longer count against the 16); set them again once the player draws on the GPU (after a restart). Shaders act when a frame is drawn, so processed snapshots and exports never contain them (use a VideoNode for that). When mpv cannot compile a shader the handle turnsfailedwithfailed(pushed later); mpv does not say which file failed, so while several plugins' shaders are on, each of them hears it and the message says the player cannot tell whose.setsends the whole list (last write wins);clearanddisposewithdraw it; the player removes a stopped plugin's shaders itself.After an abnormal end: when the previous run of the player ended while plugin shaders were drawing (a crash, the process being ended, a lost GPU device), the player refuses every non-empty list of every plugin with
previous-crash, its message naming the plugins whose shaders were on: one such end keeps them off for the next start only; two within a day keep them off until the GPU, its driver or the player changes, or for 7 days. Clearing ([],clear,dispose) still works. The player shows one OSD line about it itself; the handle isfailedwithprevious-crashand the SDK does not retry it. Do not set the list again in a loop while it is refused, and do not show an OSD line of your own for it; a later start of the player applies lists again once the guard lets it.Example: Add a sharpening shader the plugin ships
The video looks sharper on the GPU renderer; under software rendering the OSD says why it is not. The shader file lives in the plugin's package, and the player puts it after other plugins' shaders that come earlier in its order.
Player
0.5.20
See
Process video with a shader or a filter
Since
1.5.39