Skip to content

Instantly share code, notes, and snippets.

@azumukupoe
Last active February 25, 2026 14:39
Show Gist options
  • Select an option

  • Save azumukupoe/a56a78d71cf26a8f682dc06407e615db to your computer and use it in GitHub Desktop.

Select an option

Save azumukupoe/a56a78d71cf26a8f682dc06407e615db to your computer and use it in GitHub Desktop.
AutoVSR for MPV

AutoVSR for MPV

This Lua script automatically enables NVIDIA Video Super Resolution (VSR) in MPV

Features:

  • Dynamically adjusts scaling based on display and video resolution
  • Toggle with Ctrl+Shift+U (default: off)

Usage:

  1. Place autovsr.lua in your MPV scripts folder
  2. Restart MPV
  3. Press Ctrl+Shift+U to toggle VSR

🔗 Original discussion comment: mpv-player/mpv#14804

local mp = require 'mp'
local autovsr_enabled = false
local function autovsr()
local display_width = mp.get_property_native("display-width")
local video_width = mp.get_property_native("width")
local display_height = mp.get_property_native("display-height")
local video_height = mp.get_property_native("height")
if video_width and display_width and video_height and display_height then
local scale = math.max(display_width, display_height) / math.max(video_width, video_height)
scale = scale - scale % 0.1 --
local vf = mp.get_property("vf") or ""
if string.match(vf, "@vsr") then
mp.command("vf remove @vsr")
end
if scale > 1 then
mp.command("vf append @vsr:d3d11vpp:scaling-mode=nvidia:scale=" .. scale)
end
end
end
local function activate()
autovsr_enabled = not autovsr_enabled
if autovsr_enabled then
autovsr()
mp.observe_property("video-params/pixelformat", "native", autovsr)
mp.observe_property("vf", "native", autovsr)
mp.osd_message("RTX ON")
else
mp.command("vf remove @vsr")
mp.unobserve_property(autovsr)
mp.osd_message("RTX OFF")
end
end
mp.add_key_binding("ctrl+shift+u", "autovsr", activate)
@jianhuan309
Copy link
Copy Markdown

How to change this script to on by default so that VSR is automatically turned on every time MPV is started, thanks

@christantoan
Copy link
Copy Markdown

christantoan commented Sep 25, 2025

How to change this script to on by default so that VSR is automatically turned on every time MPV is started, thanks

@jianhuan309 Use this: mpv-player/mpv#14804 (comment)

@jianhuan309
Copy link
Copy Markdown

How to change this script to on by default so that VSR is automatically turned on every time MPV is started, thanks

@jianhuan309 Use this: mpv-player/mpv#14804 (comment)

thank you

@Starship4605
Copy link
Copy Markdown

Does this work with Vulkan?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment