diff --git a/STATE.md b/STATE.md index c11e86a..cb80c3a 100644 --- a/STATE.md +++ b/STATE.md @@ -320,8 +320,16 @@ live = HEVC hvc1 **且**音轨是 AAC(真能播)**且**本次是从快照原 - [ ] **等业主定 D-07(队列仓 PLAN §7)**:`0705机械宇宙` 按指示跑过 `--crf 24`,仍是 mean **0.9120**、坏帧 **8.93%**、 `vmaf480` **59.41** —— 与 crf29 逐位相同 ⇒ **源档缺陷**(引擎自己标了 non-uniform cadence),别再降参数; 要么接受原档,要么单独走"源档缺陷"口径。同类还有 3 项 `engine-skip`(park 满 2 轮)。 -- [ ] **cpu(x265)档门槛问题**:crf29 在 bpp 0.0147–0.0293 带成立(0.9958/0.9968),但 **bpp ≳0.05 那一带 4/4 落到 - 0.9926–0.9946**(720p、源 ~1.17 Mbps)→ 每项白烧 2 次整片编码后 park。选项 A `cpu_crf→24` / B 放行到 0.990。 +- [x] **cpu(x265)档门槛问题**(2026-10-25 结案):crf29 在 bpp 0.0147–0.0293 带成立(0.9958/0.9968),但 bpp ≳0.05 + 那一带 4/4 落到 0.9926–0.9946(720p、源 ~1.17 Mbps)→ 每项白烧 2 次整片编码后 park。 + **根因不是档位,是 `SIZE_CEIL=1.0` 的 `-maxrate` 与 0.995 互斥**:实测 720p/1832 kbps 源, + crf 19 在上限内 = 0.99192(87% 大小)、**crf 14 在同一上限内 = 0.99195**(五档只动 0.00003)、 + 放开上限 crf 19 = 0.99648 但要 **172%** 大小 ⇒ 到 0.995 需源码率的 **125%** 以上。 + **已定(业主 2026-10-25)**:走选项 B,但只对「本来就能播的源」——`plays_everywhere()`(h264+aac+mp4/m4v/mov) + 在 0.995 不过时直接按 `SSIM_MEAN_MIN_FALLBACK`(0.990) 收下,判决写 + `second tier 0.990: the source already plays everywhere, so this is a space-reclaim job`; + 不可播源仍 0.995,帧占比缺陷任何档位都拒。同时**不再跑那次注定无效的 quality+2 重试**。 + 同机实测:同一文件由 `FAIL quality 0.9923` 变为 `ok`,87.5% 大小,单次编码 120 s。 - [ ] 两档跑完 → **全库落地审计**:`D:\dev\hevc-transcode\cache\install_audit.py`(核对线上文件真实大小 + 编码器;曾一次抓到"报告成功没落地")+ `copy_land_check.py`(copy 档用音轨 aac/mp3 判定)。 - [ ] 失败项:无需清单,新一轮自动重做(失败时文件原样)。 - [ ] `2022年/0723 《走出强迫症》/走出强迫症.mp4` 用新下载(`D:\Download\0723走出强迫症.mp4`,618,696,954 B)已转好装好(450,502,893 B,HEVC+AAC,SSIM min 0.997,时长 3399.81 s)✓。**快照里那份仍是坏的**(618,697,011 B,moov 缺失)→ 待定:是否用干净副本替换快照里的坏档,以免将来"从原档重转"踩坑。 diff --git a/scripts/library_run.py b/scripts/library_run.py index 98793e5..9f94ff5 100644 --- a/scripts/library_run.py +++ b/scripts/library_run.py @@ -202,6 +202,9 @@ def _flat_frames(raw_path, n, w=480, h=270, thresh=FLAT_LUMA_STD): SIZE_CEIL = 1.0 # output video bitrate must not exceed the source's +CAP_BOUND_SHARE = 0.97 # an encode that spent >= 97% of the ceiling is no longer gear-limited: + # below the ceiling a lower CRF buys bits, AT it the encoder is throwing + # bits away, so the quality ladder stops being a ladder (owner 2026-10-25) QUALITY_STEPS = 2 # on a quality-gate failure, retry with the quality raised this many # steps (cq -2 / crf -2) before giving up; the retry only fires on a # file the cheaper setting could not carry @@ -764,7 +767,11 @@ def ssim_vs_source(src_local, out_local, info, workdir, tag, dur=SSIM_WINDOW): try: flat = _flat_frames(ref, n) except Exception as e: # numpy missing / unreadable raw: fall back to using every frame - log(" ! flat-frame scan skipped: %s" % e) + # This used to be one quiet line, and it silently changed what the verdict MEANS (measured + # 2026-10-25: 305 of 418 production runs were measured without the exclusion). numpy is a + # declared dependency now, so a failure here is a broken install and says so. + log(" ! INSTALL PROBLEM: flat-frame scan skipped (%s) - numpy is missing from this install, " + "so the picture verdict is measured WITHOUT excluding near-flat frames." % e) if flat and len(flat) < n * 0.5: vals = [v for i, v in enumerate(vals) if i not in flat] log(" %d near-flat source frame(s) excluded from the picture verdict (SSIM is " @@ -1247,6 +1254,20 @@ 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. + + 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. + """ + 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") + + def already_hevc(src, info, container="mp4"): """Self-describing resume test. @@ -1444,6 +1465,27 @@ def process(src, args, dest=None, origin=None): mean_min = SSIM_MEAN_MIN_FALLBACK systematic = bad_share > MAX_BAD_SHARE or ( mean is not None and mean < mean_min) + # Owner decision 2026-10-25 - the SECOND TIER for a source that already plays + # everywhere. Basis, measured on 用超富集植物种植金属 (1280x720@30, 1832 kbps source, + # 96 s): crf 19 under the "never bigger" ceiling = SSIM 0.99192 at 87% of the source, + # crf 14 under the SAME ceiling = 0.99195 (five quality steps moved the mean by + # 0.00003, because `-maxrate` throws away every extra bit the lower CRF asks for), + # while 0.995 needed 125% of the source's OWN bitrate - which this queue's promise + # forbids. So for an H.264+AAC mp4 the conversion's only job is reclaiming disk, which + # is the same situation `SSIM_MEAN_MIN_REDO` already rules on; the strict bar stays for + # sources whose playability is the thing being fixed. The frame-share test above is + # unchanged: a real defect is still refused at any tier. + 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)): + 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)" + % (SSIM_MEAN_MIN_FALLBACK, mean, + "capped " if capped else "", growth)) + log(" " + note) + ssim_note += " ; " + note # Name the criterion that ACTUALLY failed, at the bar that applied to this item. # Both tests used to print the same "mean X < bar Y" template, so a frame-share # refusal was reported as a mean one - and "mean 0.9972 < bar 0.995" was written into @@ -1459,12 +1501,23 @@ def process(src, args, dest=None, origin=None): ", " if why else "", 100.0 * bad_share, BAD_FRAME_SSIM, sstat.get("below", 0), nfr) if systematic: - if q_off < QUALITY_STEPS and (attempt == 1): + if q_off < QUALITY_STEPS and (attempt == 1) and not capped: q_off = QUALITY_STEPS log(" quality gate: %s - retrying at quality+%d" % (why, q_off)) continue - return ("FAIL quality: %s - systematic: %s%s" - % (ssim_note, why, + # Name the wall. For an already-playable source the second tier has ALREADY been + # offered (the branch above), so a refusal here means even 0.990 was missed - and + # 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: + 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, + " (output already at the ceiling: %s%.0f%% of the source video)" + % ("capped " if capped else "", growth))) + return ("FAIL quality: %s - systematic: %s%s%s" + % (ssim_note, why, tail, " (re-do of an already playable file)" if redo_playable else "")), None if lo is not None and lo < SSIM_TARGET: log(" %d scattered frame(s) below %.2f (%.2f%% of the window) with a healthy "