mpv-scripts
mpv-scripts copied to clipboard
crop doesn't work for rotated movies
from ffprobe:
Duration: 00:30:00.07, start: 0.000000, bitrate: 20261 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 19998 kb/s, SAR 1:1 DAR 16:9, 29.98 fps, 30 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 90
creation_time : 2018-07-15T13:57:28.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
notice the displaymatrix: rotation of -90.00 degrees
.
MPV will automatically rotates the video -90 degrees. Unfortunately the video-rotate
property returns back 0, which is expected based on the docs:
--video-rotate=<0-360|no>
Rotate the video clockwise, in degrees. Currently supports 90° steps only. If no
is given, the video is never rotated, even if the file has rotation metadata. (The
rotation value is added to the rotation metadata, which means the value 0 would
rotate the video according to the rotation metadata.)
Then, the cropping is all funny.
Mh I wonder in which part of the pipeline this "displaymatrix rotation" is handled. Could you upload a short sample that has such side data?
Here, I think: https://github.com/mpv-player/mpv/blob/d5cad856255cb0e74461f9d6613f561c6f347a0f/demux/demux_lavf.c#L643
The OpenCamera app adds the metadata based on the phone orientation. I'll add a sample shortly.
Ok, I think it might just be a matter of summing the video-rotate
property with video-out-params/rotate
. Rotations due to libav's filters should handled automatically.