Edit: The final version of the script has been published on the wiki, along with a few other scripts:
https://github.com/mpv-player/mpv/wiki/User-Scripts
-
auto-keep-gui-open
Intelligently switches mpv's "keep-open" behavior based on whether you are running in video-mode or audio-only mode.
-
cycle-video-rotate
Allows you to perform video rotation which perfectly cycles through all 360 degrees without any glitches.
-
multi-command-if
Very powerful conditional logic and multiple action engine for your keybindings, without having to write a single line of code!
-
quick-scale
Quickly scale the video player to a target size, with full control over target scale and max scale. Helps you effortlessly resize a video to fit on your desktop, or any other video dimensions you need!
Old post:
I noticed that you have an internal repository of scripts. I also noticed that you've had questions from users about how to rotate a video.
Method 1: Add/Subtract
Alt+LEFT add video-rotate -90
Alt+RIGHT add video-rotate 90
Result: 0..90..180..270..359 (this is where all hell breaks loose; the video is now unevenly rotated).
Verdict: Garbage method.
Method 2: Cycle a set of pre-determined values.
Alt+LEFT cycle-values "!reverse" video-rotate "90" "180" "270" "0"
Alt+RIGHT cycle-values video-rotate "90" "180" "270" "0"
Result: Always even rotation. But if your first action on a video is to rotate left, your next rotation will be "0" (the default rotation for a video), so you actually have to press left twice to get it to rotate left.
Verdict: Almost good... so close, but not good enough for a project the quality of mpv.
Method 3: My "Cycle_Video_Rotate" script.
~/.config/mpv/scripts/cycle_video_rotate.lua: (Edit: See updated version of this script below)
function cycle_video_rotate(direction)
-- Calculate what the next rotation value should be.
newrotate = mp.get_property_number("video-rotate")
if direction == "clockwise" then
newrotate = newrotate + 90
else
newrotate = newrotate - 90
end
-- Wrap value to correct range (0 (aka 360) to 359).
if newrotate >= 360 then
newrotate = newrotate - 360
elseif newrotate < 0 then
newrotate = newrotate + 360
end
-- Change rotation and tell the user.
mp.set_property_number("video-rotate", newrotate)
mp.osd_message("Rotate: " .. newrotate)
end
mp.register_script_message("Cycle_Video_Rotate", cycle_video_rotate)
~/.config/mpv/input.conf
# Rotate video in 90 degree increments.
Alt+LEFT script-message Cycle_Video_Rotate "counter-clockwise"
Alt+RIGHT script-message Cycle_Video_Rotate "clockwise"
Result: Works instantly in any direction without needing multiple keypresses. Always aware of and basing itself on the current rotation value, thus never "jumping" to an unexpected rotation. Always uses even 90-degree increments as long as the users themselves haven't applied any uneven rotation before calling this function (in that case, it fully preserves their offset and does the 90 degree rotation on top of that).
Verdict: Get this included into mpv! ;-) It's so much slicker.
Take care!
Edit: The final version of the script has been published on the wiki, along with a few other scripts:
https://github.com/mpv-player/mpv/wiki/User-Scripts
auto-keep-gui-open
Intelligently switches mpv's "keep-open" behavior based on whether you are running in video-mode or audio-only mode.
cycle-video-rotate
Allows you to perform video rotation which perfectly cycles through all 360 degrees without any glitches.
multi-command-if
Very powerful conditional logic and multiple action engine for your keybindings, without having to write a single line of code!
quick-scale
Quickly scale the video player to a target size, with full control over target scale and max scale. Helps you effortlessly resize a video to fit on your desktop, or any other video dimensions you need!
Old post:
I noticed that you have an internal repository of scripts. I also noticed that you've had questions from users about how to rotate a video.
Method 1: Add/Subtract
Result: 0..90..180..270..359 (this is where all hell breaks loose; the video is now unevenly rotated).
Verdict: Garbage method.
Method 2: Cycle a set of pre-determined values.
Result: Always even rotation. But if your first action on a video is to rotate left, your next rotation will be "0" (the default rotation for a video), so you actually have to press left twice to get it to rotate left.
Verdict: Almost good... so close, but not good enough for a project the quality of mpv.
Method 3: My "Cycle_Video_Rotate" script.
~/.config/mpv/scripts/cycle_video_rotate.lua: (Edit: See updated version of this script below)
~/.config/mpv/input.conf
Result: Works instantly in any direction without needing multiple keypresses. Always aware of and basing itself on the current rotation value, thus never "jumping" to an unexpected rotation. Always uses even 90-degree increments as long as the users themselves haven't applied any uneven rotation before calling this function (in that case, it fully preserves their offset and does the 90 degree rotation on top of that).
Verdict: Get this included into mpv! ;-) It's so much slicker.
Take care!