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.
This commit is contained in:
Kacper Michajłow 2023-08-25 19:22:53 +02:00 committed by Dudemanguy
parent f3f1a79fe3
commit 817845645f
1 changed files with 14 additions and 0 deletions

View File

@ -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)