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.
Unified · Split
| @@ -56,6 +56,9 @@ detect_min_ratio: number[0.0-1.0] - The ratio of the minimum clip · 55 unmodified lines | |||
| 56 | detect_seconds: seconds - How long to gather cropdetect data. | 56 | detect_seconds: seconds - How long to gather cropdetect data. |
| 57 | Increasing this may be desirable to allow cropdetect more | 57 | Increasing this may be desirable to allow cropdetect more |
| 58 | time to collect data. | 58 | time to collect data. |
| 59 | |||
| 60 | suppress_osd: bool - Whether the OSD shouldn't be used when filters | ||
| 61 | are applied and removed. | ||
| 59 | --]] | 62 | --]] |
| 60 | 63 | ||
| 61 | require "mp.msg" | 64 | require "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 = 1 | 73 | detect_seconds = 1, |
| 74 | suppress_osd = false, | ||
| 71 | } | 75 | } |
| 72 | read_options(options) | 76 | read_options(options) |
| 73 | 77 | ||
| @@ -82,6 +86,8 @@ timers = { · 8 unmodified lines | |||
| 82 | detect_crop = nil | 86 | detect_crop = nil |
| 83 | } | 87 | } |
| 84 | 88 | ||
| 89 | local command_prefix = options.suppress_osd and 'no-osd' or '' | ||
| 90 | |||
| 85 | function is_filter_present(label) | 91 | function 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) do | 93 | for index, filter in pairs(filters) do |
| @@ -113,7 +119,7 @@ end · 25 unmodified lines | |||
| 113 | 119 | ||
| 114 | function remove_filter(label) | 120 | function remove_filter(label) |
| 115 | if is_filter_present(label) then | 121 | 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 true | 123 | return true |
| 118 | end | 124 | end |
| 119 | return false | 125 | 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, round | 167 | 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.y | 259 | command_prefix, labels.crop, meta.w, meta.h, meta.x, meta.y |
| 254 | ) | 260 | ) |
| 255 | ) | 261 | ) |
| 256 | end | 262 | end |