You are not logged in.
Many people take videos with mobile phones these days, and many mobile phones have a vertical orientation, which means many videos are sideways. I know I can fix this at the command line with "mpv --vf=rotate=1 filename.mp4" but...
Is there a keybinding for mpv to rotate a video during playback? Is it possible to create one in my "~/.mpv/input.conf" file?
Last edited by drcouzelis (2014-02-20 00:45:21)
Offline
$ cat ~/.mpv/input.conf
F1 vf toggle rotate=1
Offline
Thanks, worked perfectly! I decided to make "~/.mpv/input.conf" like this:
# Rotate by 90 degrees clockwise
Alt+RIGHT no-osd vf add rotate=1
# Rotate by 90 degrees counterclockwise
Alt+LEFT no-osd vf add rotate=2
Last edited by drcouzelis (2014-02-20 00:48:03)
Offline
key bindings to mirror video and reverse it back.
m vf add mirror
ctrl+m vf del mirror
Offline
First of all thank you for the comments on this thread; they helped me a lot.
# Rotate by 90 degrees clockwise Alt+RIGHT no-osd vf add rotate=1 # Rotate by 90 degrees counterclockwise Alt+LEFT no-osd vf add rotate=2
This unfortunately didn't work for me (mpv 0.14.0-git-e1993d5), with this error:
Invalid value for option angle: 1
Valid values are:
0
90
180
270
auto
Error parsing option angle (option could not be parsed)
Option vf-add: Error while parsing rotate parameter angle (1)
---
And for me either of the following did work:
Alt+RIGHT no-osd cycle video-rotate 90
Alt+LEFT no-osd cycle video-rotate -90
or
Alt+RIGHT no-osd vf add rotate=90
Alt+LEFT no-osd vf add rotate=270
The problem with the first method is that it cycles through the following values: 90, 180, 270, 360, no, 0; where '360', 'no', and '0' are effectively the same, hence require you two useless hits of the key to cycle through the rotation.
The itch I get with the second method is the very fact that it just adds up the filters. For example if I rotate a video clockwise, and then counterclockwise to get it back to the upright position, I end up adding two filters for nothing:
Opening video filter: [rotate angle=90]
Opening video filter: [rotate angle=270]
I wonder if this could have any performance implication since the filter stack just keeps getting larger.
For now I'd prefer the second.
Last edited by rinopo (2015-12-29 04:43:09)
Offline
Apparently the issue of the first working method is a glitch/bug of mpv.
Offline
@tom.ty89 Thanks for the reply.
I think I've figured out.
Amendment of "the first working method":
Alt+RIGHT no-osd cycle-values video-rotate "90" "180" "270" "0"
Alt+LEFT no-osd cycle-values video-rotate "270" "180" "90" "0"
This was what I was looking for.
Offline
I've tried cycle-values before I reply but I think it works worse? For example if you ALT+LEFT and then ALT+RIGHT, it will switch to 270 and then 90, instead of switch to 270 and switch back to 0.
Anyway I've filed a bug report, let's see if anyone is gonna fix it: https://github.com/mpv-player/mpv/issues/2647
Last edited by tom.ty89 (2015-12-29 07:06:14)
Offline
@tom.ty89
Thanks again for the reply and filing the issue!
Yes, you are right. (I switched back to the "second method.")
Offline
Hey I am using a BugMeNot account (windozupdate) to tell you guys about a solution I coded.
https://github.com/mpv-player/mpv/issues/3869
~/.config/mpv/scripts/cycle_video_rotate.lua:
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.add_key_binding(nil, "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).
Offline