From 64a80d22343f012ebee9b22ff92093cd527de9a1 Mon Sep 17 00:00:00 2001 From: hoelee Date: Sun, 25 Oct 2026 04:32:18 +0800 Subject: [PATCH] fix(gate): the space-reclaim class is about the PICTURES, not the audio codec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An h264 mp4 with an mp3 track was excluded from the 0.990 second tier, but encode() already re-encodes non-AAC audio to AAC in the same pass (-c:a aac -b:a ), so that track is fixed whichever picture bar applies. Holding the PICTURE to 0.995 because of it is exactly the rule that the size ceiling makes unreachable. Renamed plays_everywhere -> space_reclaim_source to say what it actually decides (owner 2026-10-25: 「把音轨转 AAC 后也按二档跑」). --- scripts/library_run.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scripts/library_run.py b/scripts/library_run.py index 9f94ff5..05f54fb 100644 --- a/scripts/library_run.py +++ b/scripts/library_run.py @@ -1254,17 +1254,19 @@ def dst_path_for(src, container="mp4"): return TR.out_path_for(src, container) -def plays_everywhere(info, src): - """True when the file AS IT STANDS already plays on an iPad and on Android. +def space_reclaim_source(info, src): + """The conversion's ONLY remaining job is reclaiming disk: the PICTURES already play everywhere. - H.264 in an mp4-family container with AAC audio is the one combination both platforms decode - natively - which is what decides whether a conversion's only remaining job is to reclaim disk - space (`SSIM_MEAN_MIN_REDO`) or whether it is also a playability fix that must not be relaxed. + H.264 in an mp4-family container is the combination an iPad and an Android phone decode natively. + AUDIO deliberately does not enter into this: `encode()` re-encodes any non-AAC track to AAC in the + same pass (`-c:a aac -b:a `, the branch just below), so an mp3/mp2 track is fixed no + matter which picture bar applies - it must not be a reason to hold the PICTURE to 0.995, which is + the bar the size ceiling makes unreachable (owner 2026-10-25: 「把音轨转 AAC 后也按二档跑」). + A source that needs the picture re-decoded (VP9/AV1) or the container rebuilt (mkv) is NOT this + class: there the conversion is a playability fix and keeps the strict bar. """ if info["vcodec"] not in ("h264", "avc1"): return False - if info["acodec"] not in ("aac", "mp4a"): - return False return os.path.splitext(src)[1].lower() in (".mp4", ".m4v", ".mov") @@ -1478,7 +1480,7 @@ def process(src, args, dest=None, origin=None): capped = bool(vbps) and obps >= vbps * SIZE_CEIL * CAP_BOUND_SHARE second_tier = False if (systematic and mean is not None and bad_share <= MAX_BAD_SHARE - and mean >= SSIM_MEAN_MIN_FALLBACK and plays_everywhere(info, src)): + and mean >= SSIM_MEAN_MIN_FALLBACK and space_reclaim_source(info, src)): second_tier, systematic = True, False note = ("second tier %.3f: the source already plays everywhere, so this is a " "space-reclaim job (mean %.4f, %s%.0f%% of the source video)" @@ -1510,7 +1512,7 @@ def process(src, args, dest=None, origin=None): # the production record says the gear ladder cannot fix it: 194 of 202 files with # two measured rounds moved by < 0.0015, i.e. the ceiling ate the extra bits. tail = "" - if plays_everywhere(info, src) and bad_share <= MAX_BAD_SHARE: + if space_reclaim_source(info, src) and bad_share <= MAX_BAD_SHARE: tail = (" ; the second tier %.3f was not met either%s - no gear change can " "move this class (owner 2026-10-25)" % (SSIM_MEAN_MIN_FALLBACK,