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
56detect_seconds: seconds - How long to gather cropdetect data.56detect_seconds: seconds - How long to gather cropdetect data.
57 Increasing this may be desirable to allow cropdetect more57 Increasing this may be desirable to allow cropdetect more
58 time to collect data.58 time to collect data.
59
60suppress_osd: bool - Whether the OSD shouldn't be used when filters
61 are applied and removed.
59--]]62--]]
60 63
61require "mp.msg"64require "mp.msg"
@@ -67,7 +70,8 @@ local options = { · 5 unmodified lines
67 detect_limit = "24/255",70 detect_limit = "24/255",
68 detect_round = 2,71 detect_round = 2,
69 detect_min_ratio = 0.5,72 detect_min_ratio = 0.5,
70 detect_seconds = 173 detect_seconds = 1,
74 suppress_osd = false,
71}75}
72read_options(options)76read_options(options)
73 77
@@ -82,6 +86,8 @@ timers = { · 8 unmodified lines
82 detect_crop = nil86 detect_crop = nil
83}87}
84 88
89local command_prefix = options.suppress_osd and 'no-osd' or ''
90
85function is_filter_present(label)91function is_filter_present(label)
86 local filters = mp.get_property_native("vf")92 local filters = mp.get_property_native("vf")
87 for index, filter in pairs(filters) do93 for index, filter in pairs(filters) do
@@ -113,7 +119,7 @@ end · 25 unmodified lines
113 119
114function remove_filter(label)120function remove_filter(label)
115 if is_filter_present(label) then121 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))
117 return true123 return true
118 end124 end
119 return false125 return false
@@ -157,8 +163,8 @@ function detect_crop() · 37 unmodified lines
157 163
158 mp.command(164 mp.command(
159 string.format(165 string.format(
160 'vf pre @%s:cropdetect=limit=%s:round=%d:reset=0',166 '%s vf pre @%s:cropdetect=limit=%s:round=%d:reset=0',
161 labels.cropdetect, limit, round167 command_prefix, labels.cropdetect, limit, round
162 )168 )
163 )169 )
164 170
@@ -249,8 +255,8 @@ function apply_crop(meta) · 84 unmodified lines
249 255
250 -- Apply crop.256 -- Apply crop.
251 mp.command(257 mp.command(
252 string.format("vf pre @%s:lavfi-crop=w=%s:h=%s:x=%s:y=%s",258 string.format("%s vf pre @%s:lavfi-crop=w=%s:h=%s:x=%s:y=%s",
253 labels.crop, meta.w, meta.h, meta.x, meta.y259 command_prefix, labels.crop, meta.w, meta.h, meta.x, meta.y
254 )260 )
255 )261 )
256end262end

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