summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido Cella <guido@guidocella.xyz>2021-07-14 09:23:01 +0200
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2021-07-14 11:58:29 +0300
commit075154175d5a4c1516df2e4bde34ffc90c31cc0a (patch)
tree3fa57584fc831bcd23fc707121b1c1c737c4184f
parent8ace8e879050fbfc7e11c68541dbadd6ce8b56a9 (diff)
downloadmpv-075154175d5a4c1516df2e4bde34ffc90c31cc0a.tar.bz2
mpv-075154175d5a4c1516df2e4bde34ffc90c31cc0a.tar.xz
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.
-rw-r--r--TOOLS/lua/autocrop.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua
index af6021b75a..a06db7f702 100644
--- a/TOOLS/lua/autocrop.lua
+++ b/TOOLS/lua/autocrop.lua
@@ -102,12 +102,13 @@ function is_enough_time(seconds)
end
function is_cropable()
- local vid = mp.get_property_native("vid")
- local is_album = vid and mp.get_property_native(
- string.format("track-list/%d/albumart", vid)
- ) or false
+ for _, track in pairs(mp.get_property_native('track-list')) do
+ if track.type == 'video' and track.selected then
+ return not track.albumart
+ end
+ end
- return vid and not is_album
+ return false
end
function remove_filter(label)