diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2023-08-25 19:22:53 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-08-31 17:37:42 +0000 |
commit | 817845645f9440978866f77f306292a6d865d64f (patch) | |
tree | 403c73d765fe2dbf5a54cb6a50be765efb5bb02c /TOOLS/lua/autocrop.lua | |
parent | f3f1a79fe3ad9bdae344559ec5802c184af41112 (diff) | |
download | mpv-817845645f9440978866f77f306292a6d865d64f.tar.bz2 mpv-817845645f9440978866f77f306292a6d865d64f.tar.xz |
autocrop.lua: use new --video-crop
Gated behind option for backward compatibility.
Note that this will not magically start working with hwdec, as we do not
have crop detection for hwdec.
Diffstat (limited to 'TOOLS/lua/autocrop.lua')
-rw-r--r-- | TOOLS/lua/autocrop.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua index 19ba87653b..5e7a566900 100644 --- a/TOOLS/lua/autocrop.lua +++ b/TOOLS/lua/autocrop.lua @@ -72,6 +72,7 @@ local options = { detect_min_ratio = 0.5, detect_seconds = 1, suppress_osd = false, + use_vo_crop = false, } read_options(options) @@ -122,6 +123,12 @@ function is_cropable(time_needed) end function remove_filter(label) + if options.use_vo_crop and label == labels.crop then + local ro = mp.get_property_native("video-out-params") + mp.command(string.format("%s set video-crop 0", command_prefix)) + return ro and ro["crop-w"] and ro["crop-w"] > 0 + end + if is_filter_present(label) then mp.command(string.format('%s vf remove @%s', command_prefix, label)) return true @@ -245,6 +252,13 @@ function apply_crop(meta) return end + if options.use_vo_crop then + -- Apply crop. + mp.command(string.format("%s set video-crop %sx%s+%s+%s", + command_prefix, meta.w, meta.h, meta.x, meta.y)) + return + end + -- Remove existing crop. remove_filter(labels.crop) |