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 <source kbps>), 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 后也按二档跑」).
Measured on 用超富集植物种植金属 (1280x720@30, 1832 kbps source, 96 s):
crf 19 under -maxrate 1832k -> 20.6 MB, SSIM mean 0.99192 REFUSED
crf 14 under the SAME ceiling -> 22.9 MB, SSIM mean 0.99195 five steps, +0.00003
crf 19 uncapped -> 40.6 MB, SSIM mean 0.99648 passes at 172% of the source
Reaching 0.995 needs >=125% of the source's own bitrate, which SIZE_CEIL=1.0 forbids, so
every gear below the ceiling produces the same file. Production: 487 FAIL quality rounds,
106.2 h of encoding; 194 of 202 files with two measured rounds moved < 0.0015.
Rule (owner 2026-10-25): a source that already plays everywhere (h264+avc1, aac/mp4a, mp4/m4v/mov)
is a space-reclaim job - the same situation SSIM_MEAN_MIN_REDO already rules on - so when 0.995
is missed it is accepted at SSIM_MEAN_MIN_FALLBACK (0.990), and the provably inert quality+2
retry is skipped. Unplayable sources keep 0.995; a frame-share defect is still refused at any tier.
Also: numpy is now a declared dependency and its absence is an INSTALL PROBLEM, not a silent
fallback - 305 of 418 production run logs were measured with the flat-frame scan skipped.
packaged builds ship ffmpeg inside their own tree; tracks.py called `ffprobe` by
bare name, which only resolved because this host has ffmpeg on PATH. The bundle
acceptance strips PATH on purpose, so probe() raised FileNotFoundError [WinError 2]
two seconds into the item and the queue logged it as a quality refusal.
Mirror transcode.py:36-37 (TRANSCODE_*/RT_* with a bare fallback).
MP4 (default) keeps the 'opens anywhere' promise: all audio tracks become AAC at the
source's own channel layout (5.1 stays 5.1), text subtitles become mov_text, bitmap
subtitles are skipped with a logged note, font attachments are not carried.
container=mkv is the explicit fidelity mode: every audio/subtitle/attachment stream is
copied bit-for-bit, chapters and tags ride along.
New scripts/tracks.py holds the pure plan + the container-aware gate; library_run.py
uses it for mapping, per-track codecs, container extension, install-path names and the
hvc1 check (Matroska has no codec tag). Capability report gains container/audio_downmix/
subs and 'containers' (contract 3, version 1.2.0).
Verified: scripts/test_tracks.py 55/55 (both containers end to end, per-packet md5),
plus two real library_run.py runs (MP4 3x AAC incl. 6ch + 2x mov_text; MKV bit-exact).
Three changes, each from a measured failure on 2026-10-12:
* pin_to_e_cores(mask) - the old code called ctypes' GetCurrentProcess() without declaring a
restype, so the pseudo-handle -1 was truncated to 32 bits and SetProcessAffinityMask failed with
ERROR_INVALID_HANDLE; since the call's return value was never inspected it logged
"E-core pinning: on" while the process kept every CPU (read back: 0x3FFFFFF = all 26 CPUs).
Now the prototype is declared, the mask is a parameter (--affinity-mask, default unchanged) and
the log prints the mask READ BACK from the kernel.
* --stage-dir: scratch can live on another drive; the ledger, the locks and gate_policy.json stay in
WORK (records, not cache).
* the quality gate now says WHICH criterion failed. Both tests shared one "mean X < bar Y" template,
so a frame-share refusal was filed as a mean one - ledger example: "ssim min 0.9917 mean 0.9972
(1199 frames) ... systematic: mean 0.9972 < bar 0.995, 1.67% of frames below 0.85" (0912 洞见),
a healthy mean refused by the share test. The distinction decides the fix: a mean shortfall
answers to a higher CRF, a frame-share defect does not.
Engine defaults are unchanged: a standalone run behaves exactly as before.
Every item left its SSIM windows (291 MB each), per-offset pairs, VMAF pairs and stats logs behind;
anything killed mid-item left them for ever. Measured 2026-10-12: 6 windows + 123 gate logs, work
drive at 3.9 GB, both lanes idle on the guard. process() now purges its own tag/pid artefacts in the
finally, and sweep_stage() clears leftovers older than STAGE_MAX_AGE_H while skipping any tag that has
a fresh <tag>_out.mp4.err (i.e. is encoding right now). Regression: scripts/test_stage_cleanup.py.
Measured 2026-10-11: an item parked at 2 rounds was released by the owner (park entry deleted) so it
could be retried at a lower crf - and the very next failure of ANOTHER item restored the entry, from
the stale in-memory snapshot of the engine that had loaded the file before the edit. The released
item was then SKIPped as parked. save_policy now re-reads the file and writes only the counters this
process bumped (POLICY_DIRTY), so a deleted park entry or an added accept entry survives.
Regression: scripts/test_policy_merge.py (4 checks: released item stays released, external accept
entry kept, counter reaches disk, and the old behaviour would have restored it).
The queues run the engines under pythonw.exe (no console). A console-subsystem child spawned by a
console-less parent without CREATE_NO_WINDOW makes Windows allocate a NEW console and SHOW it - one
visible window per ffprobe/ffmpeg call (measured 2026-10-11: Windows Terminal windows titled with the
ffmpeg binary while two encodes ran).
Fixed: transcode.run(), library_run.run()/run_watched() and the three gate helpers that call ffmpeg
directly (SSIM filtergraph, per-offset pairs, VMAF).
Proof (cache/scratch/nowin_test4.py, run in a DETACHED pythonw: GetConsoleWindow()==0, like the
engine): raw Popen without the flag -> 1 new visible console window; with the flag -> none) -> 0;
transcode.run() -> 0 windows, library_run.run() -> 0, library_run.run_watched() -> 0.
The SSIM gate compared frame i with frame i of the other file. Measured 2026-10-11 on two
installed outputs: -fps_mode cfr inserts a duplicate wherever a frame is dropped, so the whole
window sits at a constant -1 frame; the old sweep stepped by 10 (it could never see +-1) and its
max(0, off) seek made every NEGATIVE offset identical to 0. Cost: 14 items refused in 9.6 h
(12.4 h of lane time, then parked) while healthy encodes read 0.9808/0.9862 instead of
0.9976/0.9974.
* alignment: fine step-1 +-6 -> coarse step-10 +-100 -> per-frame +-2 best match, each stage named
in the verdict, PID-tagged temp files (two lanes share the stage dir), pair stats logs pruned
* the alignment note is INFORMATION now: it used to arrive in the irregular-timeline slot, which
skips the whole picture verdict - the canary and two x265 items were accepted that way with the
mean bar never enforced
* a window decode that fails is retried once and its ffmpeg stderr is kept (a transient decode
killed a finished 16.7-minute encode with a bare 'no frames compared'); gate decodes get their
own 60-minute stall window because trim writes nothing before the window starts; the ssim filter
and the pair comparisons are time-bounded so a wedged ffmpeg cannot hang a lane
* bars (owner decision): mean 0.995, redo/owner-released 0.990
* VMAF, observe-only and reported as vmaf480 because the window is the 480x270 one the gate already
decoded (480p reads ~+2.4/+3.2 points above native on the item measured) - the evidence base for
a threshold is two items, so it accumulates instead of gating
An owner decision can say a LEAN source is still worth re-encoding (measured: x265 crf27 lands at
33-53% of the source video bitrate at SSIM mean >=0.996). --tier cannot express that: it SKIPS any
file whose classification disagrees. --force-tier applies the requested tier instead, with two
guards that stay: copy is refused for a VP9/AV1 source (iOS cannot play the result) and a re-encode
is refused for a file that is already HEVC hvc1 (that is the --overwrite decision).
Owner decision 2026-10-10. Eight items were livelocked in the nvenc tier, burning ~3.3
GPU-hours per pass (initial encode + quality+2 retry) and never converting: they missed the
mean bar by 0.2-1.7 thousandths (0.9626-0.9778) while keeping only 0.20-0.93% of frames
below 0.85 - and per this repo's own comment the FRAME-SHARE test is the one that actually
catches a defect, the mean bar splits a continuum. With SIZE_CEIL=1.0 the mean bar is
unreachable for them by construction.
- library_run.py: POLICY (C:\AI\transcode-run\gate_policy.json) with
* accept - named items are judged by the frame-share test; a mean under the bar is logged,
not enforced. An item that trips the frame-share test is refused even if listed
(0912 洞见, 1.33%, is deliberately absent).
* park - failed quality ROUNDS per item; at PARK_AFTER=2 the item is skipped with a
visible SKIP status instead of being re-encoded. Counters persist in the same file.
- scripts/build_gate_policy.py: builds that file from the run log, taking each key verbatim
from the '--- i/n <relative path>' line (no hand-copying). Result: 7 accepted, 1 refused.
- run/relaunch_nvenc.sh: start the GPU tier ALONE (relaunch_tiers.sh hardcodes both tiers).
- STATE.md: the policy, its rationale and the round counter.
- run/relaunch_x265.sh: start ONLY the x265 tier. run/relaunch_tiers.sh hardcodes
`for t in x265 nvenc`, and the nvenc tier must not start while another job owns the
GPU (the TubeSync 58-file repair batch holds it since 2026-10-09 20:36). x265 is
pinned to the E-cores, so it shares only the RaiDrive mount -- 2 concurrent share
jobs is the documented safe limit.
- The launcher redirects its own banners into the log (under -WindowStyle Hidden,
stdout goes nowhere) and documents the -ArgumentList form: the script path alone.
- STATE.md: LastBootUpTime 2026-10-09 16:51:58 -- both tiers stopped by a REBOOT, not a
bug (x265 404/589, nvenc 308/589); the stale lock pids need no cleanup because
transcode.Lock is staleness-aware. Memory after reboot: 13 GB free / 50.3 of 55.9 GB
committed, but the commit limit fell from 79.6 GB because D: is 92% full.
崇祯传: the 493 MB <live>.new.mp4 the MemoryError left behind was complete. Passed, on a
local copy, structure + FULL DECODE + the picture gate (min 0.9980 / mean 0.9988, 1500
frames, 0 below 0.85) and a hash read-back against the share copy, only then renamed over
the live file (install read-back sha256 5a903ab8a3d1, 493,366,137 B, hevc/hvc1, 3616.8 s).
Saves a 3616 s re-encode: 822,288,651 B h264 -> 493,366,137 B HEVC.
The other 7 were truncated prefixes -> deleted; their live originals are untouched and the
tiers will redo them. 0 *.new.mp4 remain on the share.
Host hit 0 GB physical free / 76.8 of 79.6 GB commit while both tiers ran (pagefile
capped at 32 GB on a 97%-full D:), and the Dokan write of the batch's largest output
raised MemoryError. except OSError does not catch that, so the item was logged
'!! FAIL MemoryError:' with an empty message and the complete 493 MB <live>.new.mp4
stayed on the share; 8 such orphans had accumulated.
- _sha_remote / copy_remote_to_local / copy_local_to_remote: except (OSError, MemoryError)
so a transient host hiccup retries instead of failing the item
- same widening for both partial-file cleanups
- per-item handler: delete <dest>.new.mp4 unconditionally (os.remove + ignore
FileNotFoundError, never gated on os.path.exists - stale metadata on this share)
Verified by injecting MemoryError: the upload path returns False with the partial
deleted, the source read retries then raises a clean IOError, the hash retries twice.
One pass measured 11 attempts rejected purely on the window mean (0.9655-0.9795)
while accepted encodes had worse frame minima (0.33-0.90): the bar was splitting a
continuum, not separating defects. 0718 马斯克原理 failed with min 0.887 and 0.00% of
frames below 0.85. Those files already play (HEVC hvc1 + AAC) and a re-do exists only
to reclaim an old setting's bloat; reaching a 0.98 mean costs more than the source's
own bitrate, which the size ceiling forbids - so the strict bar stranded them with
their bloat while burning an encode every pass.
SSIM_MEAN_MIN_REDO = 0.975 now applies only when the run is re-doing a file that is
genuinely playable (HEVC hvc1 AND aac) from the snapshot original. The frame-share
test (>1% of frames below 0.85) is unchanged and is what catches a real defect.
Verified on ONE file before the tiers were restarted: 0321 随他们去 (rejected last
pass at mean 0.9789) -> ok, mean 0.9786, min 0.5092 with 5 of 1500 frames below 0.85
(fades), 633 MB -> 418 MB installed, live byte count == the encoded output.
The x265/nvenc tiers launched as Hermes background processes were killed
mid-encode at 10:37 when the user's session was closed, so persist_on_release
is not enough here: run/relaunch_tiers.sh starts them orphaned from Hermes
(Start-Process) with a retry loop, which is why they are no longer tracked and
must be stopped by PID only.
STATE.md now carries the progress table (242/589 done, 347 pending: 169 x265 +
174 nvenc + 4 copy), the reason a full `--tier copy` pass must NOT be run (its
only skip test is "already HEVC", which a copy output never satisfies - it
would redo all 193), and the four new weekly episodes handled one file at a
time.
STATE.md carries what the next session needs: the two commands that keep the tiers running, where
the logs/stage/locks/ledger live, the eight bugs this round produced (each with the measurement that
proved it), and the open items. The skill's body now keeps only the load-bearing rules; every
measured case moved to references/pitfalls.md, so the always-loaded part stays readable.
The GPU tier sat frozen for 1.5 hours: the user updated the NVIDIA driver while a hevc_nvenc encode
was running, which wedges in-flight GPU work with no error at all - the process stays alive, the
output stops growing, the encoder reads 0%, and nothing anywhere reports a problem. A multi-day
unattended run cannot park like that, so every long command that writes a file (the encode, and the
gate's decodes) is now watched: no growth for 300 s and the wedged process is killed and reported as
a failure for the normal retry path to pick up. Self-checked with a process that writes once and
then sleeps: killed at ~35 s for a 20 s stall window.
The three tiers run side by side by design (copy is I/O, x265 is CPU, nvenc is the GPU ASIC) and
they share the stage directory - but the gate's raw frame files had FIXED names, so two concurrent
gates overwrote each other's decodes. Measured: a comparison reported 100% of frames below 0.85 -
which reads exactly like a systematic defect and was nothing but two runs writing ssim_ref.yuv at
once. The raws are now tagged with the pid and the file tag. A single-file conversion failed its
gate on this and the 'defect' was entirely my own harness.
A freshly downloaded replacement has to go through the SAME pipeline as the library - same bpp
tier rule, same gates, same hash-verified install - rather than a hand-rolled ffmpeg one-off. So:
--path converts one file anywhere on disk (its tier is still chosen by bpp; the dest defaults next
to it), --dest installs the result at an exact path (e.g. back into the library), --keep-source
never deletes the source after a verified install. Also fixes a cross-drive crash: os.path.relpath
raises ValueError when the file is on D: and the library on Z:, so logs/ledger fall back to the
absolute path (measured on the first run of this feature).
A 30 MB file timed out a 120 s ffprobe on the share. The main loop's per-item try/except keeps the
run alive (good) but turns that hiccup into a FAIL, leaving the file unconverted for the rest of the
pass - so a probe is now retried three times before it is allowed to fail an item.
One file was reported converted and was not: 'ok 1085 MB -> 478 MB' printed, every metadata probe
agreed, and the live file was still the H.264 original afterwards, with no error anywhere. RaiDrive
/ Dokan serves cached attributes, so a rename can appear to succeed while nothing landed. The
install step now reads the live file back and compares its SHA-256 with the encode it just made -
the one check a cache cannot satisfy. Costs a read per file; catches a whole class of silent
no-ops that today's 'success' reports hid.