diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua index d7e3e0b858..780e9e2d48 100644 --- a/TOOLS/lua/autocrop.lua +++ b/TOOLS/lua/autocrop.lua @@ -85,6 +85,8 @@ timers = { detect_crop = nil } +local hwdec_backup + local command_prefix = options.suppress_osd and 'no-osd' or '' function is_filter_present(label) @@ -128,6 +130,13 @@ function remove_filter(label) return false end +function restore_hwdec() + if hwdec_backup then + mp.set_property("hwdec", hwdec_backup) + hwdec_backup = nil + end +end + function cleanup() -- Remove existing filter. @@ -140,6 +149,8 @@ function cleanup() timers[index] = nil end end + + restore_hwdec() end function detect_crop() @@ -149,6 +160,13 @@ function detect_crop() return end + local hwdec_current = mp.get_property("hwdec-current") + if hwdec_current:find("-copy$") == nil and hwdec_current ~= "no" and + hwdec_current ~= "crystalhd" and hwdec_current ~= "rkmpp" then + hwdec_backup = mp.get_property("hwdec") + mp.set_property("hwdec", "auto-copy-safe") + end + -- Insert the cropdetect filter. local limit = options.detect_limit local round = options.detect_round @@ -181,6 +199,8 @@ function detect_end() timers.detect_crop = nil end + restore_hwdec() + local meta = {} -- Verify the existence of metadata.