History

TOOLS/autocrop.lua: allow hiding OSD messages

Because having these on every video is annoying, and when you resume from watch later files, the filters are applied immediately so they hide your osd-playing-msg or equivalent show-text commands.

Guido Cella committed 5 years ago

Commit 6fe4fc41 parent e2c24ad1 file · +12 −6Browse files

Unified · Split

TOOLS/lua/autocrop.lua+12−6
@@ -56,6 +56,9 @@ detect_min_ratio: number[0.0-1.0] - The ratio of the minimum clip · 55 unmodified lines
5656 detect_seconds: seconds - How long to gather cropdetect data.
5757 Increasing this may be desirable to allow cropdetect more
5858 time to collect data.
59+
60+suppress_osd: bool - Whether the OSD shouldn't be used when filters
61+ are applied and removed.
5962 --]]
6063
6164 require "mp.msg"
@@ -67,7 +70,8 @@ local options = { · 5 unmodified lines
6770 detect_limit = "24/255",
6871 detect_round = 2,
6972 detect_min_ratio = 0.5,
70− detect_seconds = 1
73+ detect_seconds = 1,
74+ suppress_osd = false,
7175 }
7276 read_options(options)
7377
@@ -82,6 +86,8 @@ timers = { · 8 unmodified lines
8286 detect_crop = nil
8387 }
8488
89+local command_prefix = options.suppress_osd and 'no-osd' or ''
90+
8591 function is_filter_present(label)
8692 local filters = mp.get_property_native("vf")
8793 for index, filter in pairs(filters) do
@@ -113,7 +119,7 @@ end · 25 unmodified lines
113119
114120 function remove_filter(label)
115121 if is_filter_present(label) then
116− mp.command(string.format('vf remove @%s', label))
122+ mp.command(string.format('%s vf remove @%s', command_prefix, label))
117123 return true
118124 end
119125 return false
@@ -157,8 +163,8 @@ function detect_crop() · 37 unmodified lines
157163
158164 mp.command(
159165 string.format(
160− 'vf pre @%s:cropdetect=limit=%s:round=%d:reset=0',
161− labels.cropdetect, limit, round
166+ '%s vf pre @%s:cropdetect=limit=%s:round=%d:reset=0',
167+ command_prefix, labels.cropdetect, limit, round
162168 )
163169 )
164170
@@ -249,8 +255,8 @@ function apply_crop(meta) · 84 unmodified lines
249255
250256 -- Apply crop.
251257 mp.command(
252− string.format("vf pre @%s:lavfi-crop=w=%s:h=%s:x=%s:y=%s",
253− labels.crop, meta.w, meta.h, meta.x, meta.y
258+ string.format("%s vf pre @%s:lavfi-crop=w=%s:h=%s:x=%s:y=%s",
259+ command_prefix, labels.crop, meta.w, meta.h, meta.x, meta.y
254260 )
255261 )
256262 end

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t