Sixem

cycle-video-rotate.lua (mpv)

Aug 13th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. -- -----------------------------------------------------------
  2. --
  3. -- CYCLE-VIDEO-ROTATE.LUA
  4. -- Version: 1.0
  5. -- Author: SteveJobzniak
  6. -- URL: https://github.com/SteveJobzniak/mpv-tools
  7. --
  8. -- Description:
  9. --
  10. -- Allows you to perform video rotation which perfectly
  11. -- cycles through all 360 degrees without any glitches.
  12. --
  13. -- -----------------------------------------------------------
  14.  
  15. function cycle_video_rotate(amt)
  16. -- Ensure that amount is a base 10 integer.
  17. amt = tonumber(amt, 10)
  18. if amt == nil then
  19. mp.osd_message("Rotate: Invalid rotation amount")
  20. return nil -- abort
  21. end
  22.  
  23. -- Calculate what the next rotation value should be,
  24. -- and wrap value to correct range (0 (aka 360) to 359).
  25. local newrotate = mp.get_property_number("video-rotate")
  26. newrotate = ( newrotate + amt ) % 360
  27.  
  28. -- Change rotation and tell the user.
  29. mp.set_property_number("video-rotate", newrotate)
  30. mp.osd_message("Rotate: " .. newrotate)
  31. end
  32.  
  33. -- Bind this via input.conf. Example:
  34. -- Alt+LEFT script-message Cycle_Video_Rotate -90
  35. -- Alt+RIGHT script-message Cycle_Video_Rotate 90
  36. mp.register_script_message("Cycle_Video_Rotate", cycle_video_rotate)
Add Comment
Please, Sign In to add comment