@vestra-player/sdk - v1.11.3
    Preparing search index...

    Interface VideoUpscaling

    plugin.video.upscaling: the GPU's video upscaler, NVIDIA RTX Video Super Resolution on Windows. Read whether it works here and why not; turn it on or off for this plugin.

    The player checks the GPU once, when a plugin first asks, and keeps the answer: the check wakes a sleeping discrete GPU, so call VideoUpscaling.state when the plugin first needs the answer (the first time the user picks its upscaling item), not while the plugin starts, and do not poll it. set(false) never starts the check. It works only with GPU rendering, on the GPU the upscaler runs on, with the video decoded on that GPU; UpscalingReasonCode lists what can stand in the way.

    While some plugin has it on and it works, the player puts the upscaler last in the video filter chain and scales the video to the area it is shown in, following window and video size changes (a resize waits until the size holds). A video already shown at its own size or smaller is not upscaled. The upscaler stays while any plugin has it on; it goes when the last one turns it off or stops: the player revokes a stopped plugin's request.

    Windows: the user must turn on Super Resolution in the NVIDIA app (System ▸ Video ▸ RTX Video Enhancement); no program can read that switch, and the driver gives no sign that it upscales (UpscalingState.requested is as far as the player can see). It uses the NVIDIA GPU, so power use and heat go up, and on a laptop with two GPUs the whole player must run on the NVIDIA one. macOS, Linux: available is false with platform.

    A Video menu item turns upscaling on and off; once the player said it cannot work here, the item is greyed out with the player's reason. The state is read the first time the user picks the item (that runs the player's GPU check, so nothing wakes the GPU while the plugin starts) and again after each pick; set resolves with the new state, or rejects with unsupported where upscaling cannot work in this run.

    let state: UpscalingState | null = null; // unknown until first picked
    plugin.commands.add({
    id: "upscaling",
    path: ["@video", "AI Upscaling"],
    checked: () => state?.enabled ?? false,
    // Greyed only once the player said it cannot work (`decoding` can pass).
    enabled: () => state === null || state.available || state.reason?.code === "decoding",
    reason: () => state?.reason?.message ?? null, // shown while disabled
    run: async () => {
    state ??= await plugin.video.upscaling.state(); // the first pick checks the GPU
    try {
    state = await plugin.video.upscaling.set(!(state?.enabled ?? false));
    } catch (error) {
    // Cannot work in this run (no RTX GPU, software rendering…).
    if ((error as PluginError).code !== "unsupported") throw error;
    state = await plugin.video.upscaling.state();
    }
    },
    });

    0.5.16

    1.5.37

    interface VideoUpscaling {
        state(): Promise<UpscalingState>;
        set(enabled: boolean): Promise<UpscalingState>;
        onChange(listener: (state: UpscalingState) => void): Disposable;
    }
    Index
    • Read whether the upscaler works now and why not, whether this plugin turned it on and what the player asked the GPU for.

      Returns Promise<UpscalingState>

      The state, once the player's GPU check ran (the first call starts it and may take a moment).

      The plugin reads the state the first time the user picks its upscaling item and keeps it for the item. The first call makes the player check the GPU (which wakes a sleeping discrete GPU) and later calls reuse the answer; the rest (GPU rendering, the GPU it runs on, the decoding) is read at each call.

      const { available, reason } = await plugin.video.upscaling.state();
      if (!available) console.log(reason?.message);

      disabled (rejects) The plugin is stopping.

      1.5.37

    • Turn upscaling on or off for this plugin.

      Parameters

      • enabled: boolean

        true to ask for upscaling, false to withdraw the request.

      Returns Promise<UpscalingState>

      The new state.

      On stays this plugin's request until it turns it off or stops; the player upscales whenever the request can take effect (a decoding reason can pass with the next file). Off takes the upscaler out at once unless another plugin has it on. Upscaling is a request of the whole plugin, not of a Scope: disposing a scope does not turn it off.

      invalid (rejects) enabled is not a boolean.

      unsupported (rejects) true where upscaling cannot work in this run: every UpscalingReasonCode except decoding, and except rendering while GPU rendering is still starting (those two are accepted and the request is kept until they pass); message is the reason. Nothing changes. false is always accepted and answered at once without the GPU check (before any check, available is false with unchecked).

      The plugin turns upscaling on from its settings and tells the user what else to switch on. set(true) records the request and resolves with the new state; where upscaling cannot work in this run it rejects with unsupported and the player's reason instead.

      try {
      const state = await plugin.video.upscaling.set(true);
      // The driver's own switch cannot be read: remind the user once.
      if (state.enabled) await plugin.osd.show("Turn on Super Resolution in the NVIDIA app");
      } catch (error) {
      if ((error as PluginError).code !== "unsupported") throw error;
      await plugin.osd.show("AI upscaling: {}", [(error as PluginError).message]);
      }

      1.5.37

    • Call listener with the new state whenever it changes while some plugin has upscaling on: the factor, whether the upscaler is in the chain, the reason, the video's and the area's size, the decoder. A window that shows how upscaling runs listens instead of polling VideoUpscaling.state.

      Parameters

      Returns Disposable

      Stops listening; also when the scope that added it is disposed.

      The player looks about five times a second while upscaling is on for any plugin (a window resize sends at most that many), and sends a change only when something differs; after the last plugin turns it off one more change says so, then nothing until it is on again: read VideoUpscaling.state when you need the state then. Nothing is sent before the player's GPU check ran (the first state() or set(true) of any plugin). enabled is this plugin's own request, as in state(). The message of a rendering reason can be shorter than the one state() gives (it may leave out what to do).

      A listener keeps the plugin running. video.upscaling.changed is not an event the player wakes a stopped plugin for: while the plugin listens, the player does not stop it while idle (lazy activation), even with upscaling off. Listen only while a window that shows the state is open, and dispose of the listener when it closes. Players before 0.5.25 do not know the event: the listener never fires and the SDK logs that the player refused the subscription.

      The plugin's window shows the factor, the sizes and the GPU while it is open; the listener goes when the window closes, so the plugin can be stopped while idle again.

      // When the window opens:
      const watch = plugin.video.upscaling.onChange((state) => {
      const video = state.video ? `${state.video.width}×${state.video.height}` : "no video";
      const area = state.area ? `${state.area.width}×${state.area.height}` : "—";
      console.log(`${video} → ${area}, ×${state.factor ?? 1}, ${state.gpu ?? "no GPU"}`);
      });
      // When it closes: stop listening (it keeps the plugin running).
      await watch.dispose();

      0.5.25

      1.5.43