Commit Graph

30 Commits

Author SHA1 Message Date
Guido Cella 142b75a95f TOOLS/autocrop.lua: fix lint warnings 2024-06-02 22:26:00 +02:00
Kacper Michajłow f220f0fb89 autocrop.lua: fix some lint warnings 2024-05-12 20:06:39 +02:00
llyyr f4a09fada9 TOOLS/autocrop.lua: drop Libav mention 2024-01-20 16:10:20 +00:00
Kacper Michajłow d305dc8d25 TOOLS/autocrop.lua: disable hwdec when needed instead using -copy one
This is more stable in practice. Avoids switching between possibly
different hwdecs and avoids unnecessary init. Software decoding should be
more stable and possibly faster overall for decoding this small portion
of video needed for cropdetect.
2023-10-18 15:21:34 +00:00
Kacper Michajłow 78719c14ca TOOLS/autocrop.lua: add support for detect_min_ratio
This was lost in 6b963857c0
2023-10-07 22:47:43 +00:00
Guido Cella a08b75da2b TOOLS/autocrop.lua: simplify code
Refactor code that is no longer necessary after replacing vf=crop with
video-crop. There is no change in behavior.
2023-10-07 22:45:38 +00:00
Guido Cella eecba5131a TOOLS/autocrop.lua: update comment 2023-10-06 15:08:19 +00:00
Guido Cella f4de509f01 TOOLS/autocrop.lua: switch to auto-copy hwdec during cropdetect
I didn't set file-local-options/hwdec because you have to store the
hwdec value to restore it after cropdetect anyway, and if the user
manually changes hwdec after cropdetect, the new value isn't reset when
changing file.
2023-09-21 13:50:21 +00:00
Guido Cella 252347731a TOOLS/autocrop.lua: cleanup timers correctly
If you change file while cropdetect is active and you try to crop the
next video, it fails with "Already cropdetecting!". This is because
timers.detect_crop wasn't cleared correctly, only the timer variable
local to the loop was being set to nil.
2023-09-21 13:50:21 +00:00
Kacper Michajłow 6b963857c0 TOOLS/autocrop.lua: use VO crop always
There is no reason not to and this significantly reduces script
complexity.
2023-09-20 19:08:19 +00:00
Kacper Michajłow 20e584f60b options: make video-crop validation more strict 2023-09-20 19:08:19 +00:00
Kacper Michajłow 10708c13fb autocrop.lua: enable vo_crop mode by default
It is just better way of cropping things. Can be disabled with
script-opts if needed.
2023-09-08 02:27:08 +00:00
Kacper Michajłow f4dd90aa90 autocrop.lua: don't remove crop on startup/exit
No need to remove/clean crop unlike with filters. Allows using autocrop
with auto=false and custom --video-crop.
2023-09-08 02:27:08 +00:00
Kacper Michajłow e234fc0ee5 autocrop.lua: detect if crop is enabled based on prop
Now we can have full frame crop, so to avoid checking that, just check
property.
2023-09-08 02:27:08 +00:00
Kacper Michajłow 817845645f autocrop.lua: use new --video-crop
Gated behind option for backward compatibility.

Note that this will not magically start working with hwdec, as we do not
have crop detection for hwdec.
2023-08-31 17:37:42 +00:00
Guido Cella 0772d0263c TOOLS/autocrop.lua: log a more accurate warning
This reorders some code and checks the image track-list sub-property
instead of the albumart one, so that when playing audio without enough
playtime-remaining and images, the "autocrop only works for videos."
warning is logged instead of the "Not enough time to detect crop." one.
It also avoids repeating this warning twice in the code.

As of e16d0dd15d current-tracks returns a video track even when
lavfi-complex is used, so the track-list loop in is_cropable can be
replaced with just checking current-tracks/video while still cropping
videos with lavfi-complex.
2023-02-27 17:03:38 +00:00
Guido Cella 6fe4fc4593 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.
2021-07-27 20:32:05 +03:00
Guido Cella 075154175d TOOLS/autocrop.lua: improve enable/disable condition
The previous code tried to disable autocrop for cover-art by testing
that track-list/$vid/albumart is false, however, $vid is completely
unrelated to the track-list index.

It only sometimes succeeded to disable for albumart, by accident,
e.g. with one audio track and one video track where $vid==1 and
track-list/1 happens to be the video (cover art) track.

The new code detects the currently-used video track by finding a track
with type=="video" and selected==true. Unlike the previous code, it
also works in scenarios with many audio/video/sub tracks.

Additionally, autocrop is now enabled also with lavfi-complex, which
should be considered an improvement. The previous code implicitly
disabled it with lavfi-complex because $vid is nil on such case.
2021-07-14 11:58:29 +03:00
ヒカリ 376aea36eb TOOLS/autocrop.lua: automatically crop at startup 2020-06-01 23:07:26 -07:00
Ricardo Constantino 1171f92beb
TOOLS/autocrop.lua: fix cropdetect black limit for 10-bit videos
Also update to use newer lavfi-bridges for the relevant filters to
shut up warnings about deprecated crop filter.
2017-08-17 20:43:25 +01:00
Avi Halachmi (:avih) 39e04e9294 options: deprecate 'lua' based options/dirs for 'script'
- --lua and --lua-opts change to --script and --script-opts
- 'lua' default script dirs change to 'scripts'
- DOCS updated

- 'lua-settings' dir was _not_ modified

The old lua-based names/dirs still work, but display a warning.

Signed-off-by: wm4 <wm4@nowhere>
2014-12-15 04:39:56 +01:00
Kevin Mitchell 3617399a46 TOOLS/lua: remove tabs from some lua scripts 2014-10-21 00:55:15 +02:00
Kevin Mitchell 6e62779e98 TOOLS/lua: conform to whitespace coding-style 2014-05-06 09:59:59 -07:00
Kevin Mitchell 20b5fecdf1 TOOLS/lua: use double quotes unless there's a good reason 2014-05-04 12:59:21 -07:00
Kevin Mitchell c91373a202 TOOLS/lua/autocrop: handle case of user hitting hotkey while cropdetection already running 2014-05-04 12:54:03 -07:00
Kevin Mitchell 74984aaff1 TOOLS/lua: no longer gsub out "lua/" prefix, now that its no longer there 2014-05-04 12:29:32 -07:00
Kevin Mitchell 8e8758dbe1 TOOLS: better documentation of lua scripts 2014-04-29 08:31:44 -07:00
Kevin Mitchell 4b0a760d86 TOOLS: improve autocrop.lua
It now inserts no filters and does nothing until the hot-key is pressed.
This makes it more suitable to be put in ~/.mpv/lua.

When the hot-key is pressed, it now inserts the cropdetect filter and
waits 1 second (or a --lua-opts specified duration) before gathering
the cropdetect metadata and inserting the appropriate crop filter. A
second press of the hotkey removes the crop.
2014-04-29 08:31:44 -07:00
Kevin Mitchell 4e973c059a TOOLS: indent lua scripts by 4 spaces instead of 3 2014-04-27 15:34:53 +02:00
Kevin Mitchell ae56b8d237 TOOLS: move autocrop.lua to TOOLS/lua
in anticipation of more lua scripts
2014-04-27 15:34:52 +02:00