-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathcycle-video-rotate.lua
More file actions
46 lines (40 loc) · 1.52 KB
/
cycle-video-rotate.lua
File metadata and controls
46 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
-- -----------------------------------------------------------
--
-- CYCLE-VIDEO-ROTATE.LUA
-- Version: 1.0
-- Author: VideoPlayerCode
-- URL: https://github.com/VideoPlayerCode/mpv-tools
--
-- Description:
--
-- Allows you to perform video rotation which perfectly
-- cycles through all 360 degrees without any glitches.
--
-- -----------------------------------------------------------
function cycle_video_rotate_reset()
-- Reset rotation and tell the user.
mp.set_property_number("video-rotate", 0)
mp.osd_message("Rotate: Reset")
end
function cycle_video_rotate(amt)
-- Ensure that amount is a base 10 integer.
amt = tonumber(amt, 10)
if amt == nil then
mp.osd_message("Rotate: Invalid rotation amount")
return nil -- abort
end
-- Calculate what the next rotation value should be,
-- and wrap value to correct range (0 (aka 360) to 359).
local newrotate = mp.get_property_number("video-rotate")
newrotate = ( newrotate + amt ) % 360
-- Change rotation and tell the user.
mp.set_property_number("video-rotate", newrotate)
mp.osd_message("Rotate: " .. newrotate)
end
-- Bind this via input.conf. Example:
-- Alt+SHIFT+LEFT script-message Cycle_Video_Rotate -90
-- Alt+SHIFT+RIGHT script-message Cycle_Video_Rotate 90
mp.register_script_message("Cycle_Video_Rotate", cycle_video_rotate)
-- Bind this via input.conf. Example:
-- Alt+SHIFT+DOWN script-message Cycle_Video_Rotate_Reset
mp.register_script_message("Cycle_Video_Rotate_Reset", cycle_video_rotate_reset)