From 33aac74207c9ea3419715707c679baad75563f65 Mon Sep 17 00:00:00 2001 From: TheAMM Date: Tue, 14 Nov 2017 01:49:57 +0200 Subject: [PATCH] Ensure crop is not 0x0 --- src/main.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.lua b/src/main.lua index 785c8d5..d9edf87 100644 --- a/src/main.lua +++ b/src/main.lua @@ -46,6 +46,7 @@ function get_output_path(size) return output_path, output_path_full end + function script_crop_toggle() if asscropper.active then asscropper:stop_crop(true) @@ -66,15 +67,23 @@ function script_crop_toggle() end end + function on_tick_listener() if asscropper.active and display_state:recalculate_bounds() then mp.set_osd_ass(display_state.screen.width, display_state.screen.height, asscropper:get_render_ass()) end end + function screenshot(crop) local size = round_dec(crop.w) .. "x" .. round_dec(crop.h) + -- Bail on bad crop sizes + if not (crop.w > 0 and crop.h > 0) then + mp.osd_message("Bad crop (" .. size .. ")!") + return + end + local output_path, fullsize_output_path = get_output_path(size) local out = mp.commandv("no-osd", "screenshot-to-file", fullsize_output_path)