konradre/video-production-skills / skills/video-finish-qc
video-finish-qc
VerifiedRuns the FINISH of a whole spot from its EDL — part of every video job; a builder's render before it is PRE-FINISH — and the QC of the delivered master: the per-shot upscale tier (after approval and a cost line), the per-shot normalise, the hero pass, the three-stage finish (graded cut, master, deliverable), the finals run, and the one-pass QC (duration, loudness, true peak, cuts, take-cut leaks, VO placement, the finish against the previous version). Use when approved keepers must be upscaled, shots normalised, a hero pass is due, a spot must be rendered from its EDL, finals are requested, or a delivered file must be verified or sent. Triggers — "upscale the keepers", "run the hero pass", "normalise the shots", "apply the ads look", "has it been finished", "render the spot", "finish it", "final renders", "QC the deliverable", "rogue frames", "is the loudness right", "send me the 1080p", "starlight on the wides". Not for the per-clip ordering doctrine — use video-finish. Not for the cut or the beat gate — use video-edit-edl. Not for voicing or sourcing the sound — use spot-audio-assembly. Not for LUFS mastering of a standalone mix — use mastering-audio.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 32.3 KB |
| references/FAQ.md | markdown | 3.4 KB |
| references/PIPELINE.md | markdown | 13.7 KB |
| references/QC.md | markdown | 26.4 KB |
| scripts/aac_packet_clock.pyexecutable | script | 7.8 KB |
| scripts/decoded_checks.py | script | 65.1 KB |
| scripts/final_renders.shexecutable | script | 1.9 KB |
| scripts/finish_clip.pyexecutable | script | 11.9 KB |
| scripts/finish_spot.pyexecutable | script | 41.0 KB |
| scripts/hero_distinct.pyexecutable | script | 2.1 KB |
| scripts/hero_pass.shexecutable | script | 3.8 KB |
| scripts/look_sheet.py | script | 9.7 KB |
| scripts/matrix_check.pyexecutable | script | 23.6 KB |
| scripts/normalise_shots.pyexecutable | script | 18.9 KB |
| scripts/phone_texture_probe.py | script | 7.0 KB |
| scripts/qc_deliverable.pyexecutable | script | 61.8 KB |
| scripts/upscale_fal_topaz.pyexecutable | script | 8.5 KB |
| scripts/upscale_local.shexecutable | script | 3.4 KB |
scripts/matrix_check.py
View on GitHub#!/usr/bin/env python3
"""matrix_check.py — does a render path convert RGB → YUV with the matrix its file is tagged with?
ffmpeg converts RGB → YUV with BT.601 unless a filter names the matrix, and our files are tagged bt709. A frame born RGB
(a HyperFrames render, a PNG layer, a caption card, a shot graded through a cube) then plays back with its saturated
colours moved — pure green read back (0,215,0), pink #FF4FA3 read (255,99,163) — while grey, black and white stay exact,
so no grey or white-text check ever sees it (measured 2026-10-21 on ffmpeg 6.1.1, up to 40 levels).
The card is 16 flat patches: primaries, secondaries, white, black, mid grey, a skin tone, and six mid-saturated colours.
`measure` decodes ONE frame the way a player does — by the file's own colour tag — and compares each patch's mean to
the card's source RGB. Run the card through the path under test (render_hyper.sh, a finish with the card as a post_layer,
a caption, a cube), then measure what that path delivered.
matrix_check.py card <out.png> [--size 1920x1080] # the 16-patch card as an RGB PNG
matrix_check.py card --html <composition dir> [--size 1920x1080] # the same card as a HyperFrames index.html
matrix_check.py measure <video|png> [--at 1.0] [--as tag|bt709|bt601] [--max 3] [--size 1920x1080] [--json]
# exit 1 over --max, 2 when it cannot decode
matrix_check.py --selftest # a 709 encode passes; ffmpeg's default FAILS;
# finish_spot's three RGB steps pass
matrix_check.py --finish-e2e [--keep <dir>] # the REAL finish_spot.py, one event per colour
# branch, overlays over grey; exit 1 on any FAIL
`--as tag` (the default) reads the stream's `color_space`: bt709 → BT.709; smpte170m / bt470bg → BT.601; anything
else exits 2 rather than guess. A patch is read on its inner half, away from chroma-subsampled edges, and decoded with
accurate rounding (swscale's default rounding alone read 2-4 on a correct file and hid a real 2-4 level loss under the
old limit of 6); a correct 8-bit 4:2:0 encode reads within 1.
"""
import argparse, importlib.util, json, os, struct, subprocess, sys, tempfile, zlib
COLS = ["FF0000", "00FF00", "0000FF", "FFFF00", "00FFFF", "FF00FF", "FFFFFF", "000000",
"808080", "C89678", "BF0000", "FF4FA3", "B42828", "28A03C", "283CB4", "7F3FBF"]
SRC = [tuple(int(c[i:i + 2], 16) for i in (0, 2, 4)) for c in COLS]
TAGS = {'bt709': 'bt709', 'smpte170m': 'bt601', 'bt470bg': 'bt601'}
LIMIT = 3 # every correct path reads 0-1 once the decode rounds accurately; ffmpeg's default matrix reads ~40 (measured 2026-10-25)
def size(s):
w, h = (int(v) for v in s.lower().split('x')); return w, h
def cell(i, W, H):
return (i % 4) * W // 4, (i // 4) * H // 4, W // 4, H // 4
def card_png(path, W, H, gutter=0):
"""the card as an RGB PNG; with gutter > 0 an RGBA PNG whose cells are opaque and whose gutters are transparent"""
rows = []; cw, ch = W // 4, H // 4
for y in range(H):
r = bytearray(b'\x00')
for x in range(W):
px = bytes(SRC[(y * 4 // H) * 4 + x * 4 // W])
if gutter: px += b'\x00' if (x % cw < gutter or x % cw >= cw - gutter or y % ch < gutter or y % ch >= ch - gutter) else b'\xff'
r += px
rows.append(bytes(r))
def chunk(t, d): return struct.pack('>I', len(d)) + t + d + struct.pack('>I', zlib.crc32(t + d) & 0xffffffff)
with open(path, 'wb') as f:
f.write(b'\x89PNG\r\n\x1a\n' + chunk(b'IHDR', struct.pack('>IIBBBBB', W, H, 8, 6 if gutter else 2, 0, 0, 0))
+ chunk(b'IDAT', zlib.compress(b''.join(rows), 6)) + chunk(b'IEND', b''))
def card_html(d, W, H, dur=2.0, fps=24):
os.makedirs(d, exist_ok=True); cid = os.path.basename(os.path.abspath(d))
cells = '\n'.join(f' <div class="p" style="left:{x}px;top:{y}px;width:{w}px;height:{h}px;background:#{c}"></div>'
for c, (x, y, w, h) in ((c, cell(i, W, H)) for i, c in enumerate(COLS)))
html = f'''<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width={W}, height={H}" />
<title>{cid} — matrix_check patch card</title>
<script src="https://cdn.jsdelivr.net/npm/gsap@3.14.2/dist/gsap.min.js"></script>
<style>
html, body {{ margin:0; background:#000; }}
#root {{ position:relative; width:{W}px; height:{H}px; overflow:hidden; background:#000; }}
.clip {{ position:absolute; inset:0; }}
.p {{ position:absolute; }}
</style>
</head>
<body>
<div id="root" data-composition-id="{cid}" data-start="0" data-width="{W}" data-height="{H}" data-duration="{dur}" data-fps="{fps}">
<section class="clip" data-start="0" data-duration="{dur}">
{cells}
</section>
</div>
<script>
(function(){{
var ID='{cid}', st={{t:0}};
var tl=gsap.timeline({{paused:true}});
tl.to(st,{{t:{dur},duration:{dur},ease:'none'}},0); // static card: nothing moves
window.__timelines=window.__timelines||{{}}; window.__timelines[ID]=tl; if(window.__hfForceTimelineRebind) window.__hfForceTimelineRebind();
}})();
</script>
</body>
</html>
'''
with open(os.path.join(d, 'index.html'), 'w') as f: f.write(html)
def card_video(path, W, H, dur=2.0, fps=24):
"""the card as a KNOWN-CORRECT BT.709 tv-range YUV video (H.264 4:2:0, tagged): the reference a builder's YUV decode
is tested with — the PNG card alone cannot see a wrong decode (measured 2026-10-25: a BT.601 decode with a correct encode
read 1 on the PNG and 24 on a tagged video). Measured before it is kept: it must read within LIMIT itself."""
import tempfile
with tempfile.TemporaryDirectory() as d:
png = os.path.join(d, 'card.png'); card_png(png, W, H)
subprocess.run(['ffmpeg', '-v', 'error', '-y', '-loop', '1', '-t', f'{dur}', '-r', f'{fps}', '-i', png,
'-vf', 'scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p',
'-c:v', 'libx264', '-crf', '12', '-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709',
'-color_range', 'tv', path], check=True)
r = measure(path, min(1.0, dur / 2), 'tag', W, H)
if r.get('ok') is None or r['max_err'] > LIMIT: sys.exit(f'card video {path} reads {r.get("max_err")} — not a usable reference')
return r
def probe(path):
r = subprocess.run(['ffprobe', '-v', 'error', '-select_streams', 'v:0', '-show_entries',
'stream=codec_name,pix_fmt,color_space,color_range,width,height', '-of', 'json', path],
capture_output=True, text=True)
s = json.loads(r.stdout or '{}').get('streams') or [{}]
return s[0]
def measure(path, at=1.0, as_='tag', W=1920, H=1080):
st = probe(path)
if not st.get('codec_name'): return {'ok': None, 'reason': f'cannot read a video stream in {path}'}
rgb_src = st.get('pix_fmt', '').startswith(('rgb', 'bgr', 'gbr', 'pal')) or st.get('codec_name') == 'png'
if rgb_src: vf, used = f'scale={W}:{H}', 'rgb (no matrix)'
else:
m = TAGS.get(st.get('color_space') or '') if as_ == 'tag' else as_
if not m: return {'ok': None, 'reason': f"untagged or unknown color_space {st.get('color_space')!r}: pass --as bt709|bt601"}
rng = 'pc' if st.get('color_range') == 'pc' else 'tv'
vf, used = f'scale={W}:{H}:in_color_matrix={m}:in_range={rng}:flags=accurate_rnd+full_chroma_int', f'{m} {rng} ({"tag" if as_ == "tag" else "forced"})'
seek = [] if rgb_src else ['-ss', str(at)]
r = subprocess.run(['ffmpeg', '-v', 'error'] + seek + ['-i', path, '-vf', vf, '-frames:v', '1', '-f', 'rawvideo',
'-pix_fmt', 'rgb24', '-'], capture_output=True)
buf = r.stdout
if len(buf) < W * H * 3: return {'ok': None, 'reason': f'decode failed: {r.stderr.decode()[-200:]}'}
out = []
for i in range(16):
x0, y0, w, h = cell(i, W, H); acc = [0, 0, 0]; n = 0
for y in range(y0 + h // 4, y0 + 3 * h // 4, 4):
for x in range(x0 + w // 4, x0 + 3 * w // 4, 4):
p = (y * W + x) * 3; acc[0] += buf[p]; acc[1] += buf[p + 1]; acc[2] += buf[p + 2]; n += 1
m = tuple(round(v / n) for v in acc)
out.append({'patch': COLS[i], 'src': SRC[i], 'read': m, 'err': max(abs(a - b) for a, b in zip(SRC[i], m))})
worst = max(out, key=lambda p: p['err'])
return {'ok': True, 'decoded_as': used, 'tags': st, 'max_err': worst['err'], 'worst': worst, 'patches': out}
def report(res, mx):
if res.get('ok') is None: print('MATRIX-CHECK CANNOT', res['reason']); return 2
for p in res['patches']:
print(f" #{p['patch']} src {str(p['src']):16s} read {str(p['read']):16s} err {p['err']:3d}{' <-' if p['err'] > mx else ''}")
v = 'PASS' if res['max_err'] <= mx else 'FAIL'
print(f"MATRIX-CHECK {v} max err {res['max_err']} (limit {mx}) decoded as {res['decoded_as']}; worst #{res['worst']['patch']} read {res['worst']['read']}")
return 0 if v == 'PASS' else 1
def selftest():
W, H = 640, 360
spec = importlib.util.spec_from_file_location('finish_spot', os.path.join(os.path.dirname(os.path.abspath(__file__)), 'finish_spot.py'))
fs = importlib.util.module_from_spec(spec); spec.loader.exec_module(fs); TO709 = fs.TO709
ok = True
with tempfile.TemporaryDirectory() as d:
png = os.path.join(d, 'card.png'); card_png(png, W, H)
r = measure(png, W=W, H=H); ok &= r['max_err'] == 0; print(f"selftest card png: max err {r['max_err']} (want 0)")
cv = os.path.join(d, 'card.mp4'); rv = card_video(cv, W, H); okv = rv['max_err'] <= LIMIT
wrong = os.path.join(d, 'wrongdecode.mp4') # a builder that decodes the video as BT.601 and encodes BT.709 correctly
subprocess.run(['ffmpeg', '-v', 'error', '-y', '-i', cv, '-vf', 'scale=in_color_matrix=bt601:in_range=tv:flags=accurate_rnd+full_chroma_int,format=gbrp16le,'
'scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p', '-c:v', 'libx264', '-crf', '12',
'-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709', wrong], check=True)
rw = measure(wrong, W=W, H=H); okw = rw['max_err'] > LIMIT; ok &= okv and okw
print(f"selftest card video: max err {rv['max_err']} (want <= {LIMIT}); a BT.601 decode of it reads {rw['max_err']} (want > {LIMIT})")
def ff(args): subprocess.run(['ffmpeg', '-v', 'error', '-y'] + args, check=True)
tag = ['-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709']
cases = []
good = os.path.join(d, 'good.mp4'); ff(['-loop', '1', '-t', '1', '-r', '24', '-i', png, '-vf', f'{TO709},format=yuv420p', '-c:v', 'libx264', '-crf', '12'] + tag + [good]); cases.append(('TO709 → yuv420p', good, True))
bad = os.path.join(d, 'bad.mp4'); ff(['-loop', '1', '-t', '1', '-r', '24', '-i', png, '-vf', 'format=yuv420p', '-c:v', 'libx264', '-crf', '12'] + tag + [bad]); cases.append(("ffmpeg's default matrix", bad, False))
base = os.path.join(d, 'base.mov'); ff(['-f', 'lavfi', '-i', f'color=black:s={W}x{H}:r=24:d=1', '-vf', 'format=yuv422p10le', '-c:v', 'prores_ks', '-profile:v', '3'] + tag + [base])
lay = os.path.join(d, 'layer.mov'); ff(['-i', base, '-loop', '1', '-t', '1', '-r', '24', '-i', png, '-filter_complex',
f'[0:v]format=yuv422p10le[b0];[1:v]scale={W}:{H}:flags=lanczos,{TO709},format=yuva422p10le[ov0];[b0][ov0]overlay=eof_action=pass:format=yuv422p10[out]',
'-map', '[out]', '-c:v', 'prores_ks', '-profile:v', '3'] + tag + [lay]); cases.append(('finish_spot post_layer', lay, True))
cap = os.path.join(d, 'caption.mp4'); ff(['-i', base, '-loop', '1', '-t', '1', '-r', '24', '-i', png, '-filter_complex',
f"[0:v]format=yuv420p[v0];[1:v]{TO709},format=yuva420p[c0];[v0][c0]overlay=0:0:enable='gte(t,0)*lt(t,1)'[v1]",
'-map', '[v1]', '-c:v', 'libx264', '-crf', '12'] + tag + [cap]); cases.append(('finish_spot caption overlay', cap, True))
cube = os.path.join(d, 'id_33.cube')
with open(cube, 'w') as f: f.write('LUT_3D_SIZE 33\n' + ''.join(f'{r / 32:.6f} {g / 32:.6f} {b / 32:.6f}\n' for b in range(33) for g in range(33) for r in range(33)))
lut = os.path.join(d, 'lut.mov'); ff(['-i', good, '-vf', f'format=gbrp16le,lut3d=file={cube}:interp=tetrahedral,{TO709},format=yuv422p10le',
'-c:v', 'prores_ks', '-profile:v', '3'] + tag + [lut]); cases.append(('finish_spot look (identity cube)', lut, True))
for name, f, want in cases:
r = measure(f, at=0.5, W=W, H=H); got = r['max_err'] <= LIMIT; ok &= got == want
print(f"selftest {name:32s} max err {r['max_err']:3d} → {'PASS' if got else 'FAIL'} (want {'PASS' if want else 'FAIL'})")
print('SELFTEST', 'OK' if ok else 'FAILED'); return 0 if ok else 1
def finish_e2e(keep=None):
"""The REAL finish_spot.py on the card, all stages. Every branch that converts colour gets its own event: a cube on a
tagged and an untagged source; look none on a BT.709, a BT.601-tagged and an RGB (png-codec) source; an RGBA post
layer and an RGBA caption, each over FLAT GREY so an overlay that never composited reads grey and fails; an RGB end
card; an untagged SD source with its in_matrix declared; a luma-only source
under the cube and under look none (its 16 / 128 / 235 levels kept). Each row is measured on the file the finisher wrote."""
W, H, FPS = 1280, 720, 24 # 720p: an untagged source is BT.709 by the HD rule
here = os.path.dirname(os.path.abspath(__file__)); SK = os.path.abspath(os.path.join(here, '..', '..'))
d = keep or tempfile.mkdtemp(prefix='matrix-e2e-'); os.makedirs(d, exist_ok=True)
def ff(args): subprocess.run(['ffmpeg', '-v', 'error', '-y'] + args, check=True, cwd=d)
for p in ('edit/layers/card', 'edit/captions', 'takes', 'cubes'): os.makedirs(os.path.join(d, p), exist_ok=True)
card_png(os.path.join(d, 'card.png'), W, H); card_png(os.path.join(d, 'card-rgba.png'), W, H, gutter=12)
tag = ['-colorspace', 'bt709', '-color_primaries', 'bt709', '-color_trc', 'bt709']
still = ['-loop', '1', '-t', '4', '-r', str(FPS), '-i', 'card.png', '-f', 'lavfi', '-t', '4', '-i', 'anullsrc=r=48000:cl=stereo']
enc = ['-c:v', 'libx264', '-crf', '10', '-c:a', 'aac', '-shortest']
ff(still + ['-vf', 'scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p'] + enc + tag + ['takes/tagged.mp4'])
ff(still + ['-vf', 'scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p'] + enc
+ ['-bsf:v', 'h264_metadata=matrix_coefficients=2:colour_primaries=2:transfer_characteristics=2', 'takes/untagged.mp4'])
ff(still + ['-vf', 'scale=out_color_matrix=bt601:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p'] + enc
+ ['-colorspace', 'smpte170m', '-color_primaries', 'smpte170m', '-color_trc', 'smpte170m', 'takes/bt601.mp4'])
ff(still + ['-c:v', 'png', '-c:a', 'pcm_s16le', '-shortest', 'takes/rgb.mov'])
ff(still + ['-vf', 'scale=640:360,scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p'] + enc
+ ['-bsf:v', 'h264_metadata=matrix_coefficients=2:colour_primaries=2:transfer_characteristics=2', 'takes/usd.mp4'])
with open(os.path.join(d, 'bands.pgm'), 'wb') as f: # luma-only: 16 / 128 / 235 thirds, untagged range
f.write(b'P5 %d %d 255\n' % (W, H) + (bytes([16] * (W // 3) + [128] * (W // 3) + [235] * (W - 2 * (W // 3))) * H))
ff(['-loop', '1', '-t', '4', '-r', str(FPS), '-i', 'bands.pgm', '-f', 'lavfi', '-t', '4', '-i', 'anullsrc=r=48000:cl=stereo',
'-vf', 'format=gray,setparams=range=unknown', '-c:v', 'ffv1', '-c:a', 'pcm_s16le', '-shortest', 'takes/gray.mkv'])
ff(still + ['-vf', 'scale=out_color_matrix=bt709:out_range=pc:flags=accurate_rnd+full_chroma_int,format=yuvj420p'] + enc + tag + ['-color_range', 'pc', 'takes/pc.mp4'])
ff(['-f', 'lavfi', '-t', '4', '-i', f'color=0x808080:s={W}x{H}:r={FPS}', '-f', 'lavfi', '-t', '4', '-i', 'anullsrc=r=48000:cl=stereo',
'-vf', 'scale=out_color_matrix=bt709:out_range=tv:flags=accurate_rnd+full_chroma_int,format=yuv420p'] + enc + tag + ['takes/grey.mp4'])
for i in range(FPS): shutil_copy(os.path.join(d, 'card-rgba.png'), os.path.join(d, f'edit/layers/card/frame_{i:06d}.png'))
shutil_copy(os.path.join(d, 'card-rgba.png'), os.path.join(d, 'edit/captions/cap-00.png'))
with open(os.path.join(d, 'cubes', 'idtest_33.cube'), 'w') as f:
f.write('LUT_3D_SIZE 33\n' + ''.join(f'{r / 32:.6f} {g / 32:.6f} {b / 32:.6f}\n' for b in range(33) for g in range(33) for r in range(33)))
plan = [('tagged', 'idtest'), ('untagged', 'idtest'), ('tagged', 'none'), ('bt601', 'none'), ('rgb', 'none'), ('grey', 'none'), ('grey', 'none'),
('pc', 'none'), ('usd', 'none'), ('gray', 'idtest'), ('gray', 'none')]
ev = []
for k, (src, look) in enumerate(plan):
f = {'rgb': 'takes/rgb.mov', 'gray': 'takes/gray.mkv'}.get(src, f'takes/{src}.mp4')
ev.append({'id': f'E{k:02d}', 'take': f, 'src': f, 'in': 0.5, 'out': 2.0, 'tl': [1.5 * k, 1.5 * k + 1.5], 'handle_head': 0.5, 'look': look})
if src == 'usd': ev[-1]['in_matrix'] = 'bt709' # an untagged SD clip encoded BT.709: the size rule alone reads it BT.601 (26 off)
T = 1.5 * len(plan)
ev.append({'id': 'EC', 'role': 'endcard', 'source': 'designed', 'take': 'takes/rgb.mov', 'in': 0.0, 'out': 1.5, 'tl': [T, T + 1.5]})
E = {'spot': 'MX', 'deliver_base': 'MX', 'runtime_s': T + 1.5, 'canvas': [W, H], 'events': ev,
'post_layers': [{'frames': 'edit/layers/card/frame_%06d.png', 'at': 7.75}],
'audio': {'vo': {'stem': 'edit/mix/MX-vo-stem.wav', 'peak_cap_dbfs': -1.0, 'target_lufs': -16.0}, 'sfx': {}, 'music': {},
'loudnorm': {'I': -16, 'TP': -1.5, 'LRA': 11}, 'captions_dir': 'edit/captions'}}
os.makedirs(os.path.join(d, 'edit'), exist_ok=True); json.dump(E, open(os.path.join(d, 'edit', 'MX-EDL.json'), 'w'), indent=1)
stub = os.path.join(d, 'caps.py')
with open(stub, 'w') as f:
f.write("import json; json.dump([{'file': 'edit/captions/cap-00.png', 'tl': [9.25, 10.25]}], open('edit/captions/manifest.json', 'w'))\n")
r = subprocess.run([sys.executable, os.path.join(SK, 'video-finish-qc', 'scripts', 'finish_spot.py'), '--root', d, '--edl', 'edit/MX-EDL.json',
'--stage', 'all', '--look', 'idtest', '--cubes', os.path.join(d, 'cubes'), '--canvas', f'{W}x{H}', '--fps', str(FPS), '--no-gate',
'--min-free-gb', '0', '--stem-builder', os.path.join(SK, 'spot-audio-assembly', 'scripts', 'build_vo_stem.py'),
'--captions-builder', stub], capture_output=True, text=True)
if r.returncode != 0 or 'FINISH-END' not in r.stdout:
print('FINISH-E2E CANNOT: finish_spot.py failed\n' + (r.stdout + r.stderr)[-1200:]); return 2
M, Mm, Dv = 'edit/mezz/MX-footage-graded.mov', f'edit/mezz/MX-master-{W}x{H}.mov', 'deliver/MX-v1.mp4'
rows = [('cube, tagged bt709 source', M, 0.75), ('cube, untagged HD source', M, 2.25), ('look none, bt709 source', M, 3.75),
('look none, bt601-tagged source', M, 5.25), ('look none, RGB (png) source', M, 6.75),
('look none, full-range source', M, 11.25), ('untagged SD, in_matrix bt709', M, 12.75), ('RGBA post_layer over grey', Mm, 8.25), ('RGB end card', Mm, T + 0.75),
('RGBA caption over grey, delivered', Dv, 9.75), ('cube path, delivered', Dv, 0.75)]
ok = True
for name, f, at in rows:
res = measure(os.path.join(d, f), at, 'tag', W, H)
if res.get('ok') is None: print(f'e2e {name:34s} CANNOT {res["reason"]}'); ok = False; continue
good = res['max_err'] <= LIMIT; ok &= good
print(f"e2e {name:34s} max err {res['max_err']:3d} {'PASS' if good else 'FAIL'} ({os.path.basename(f)} @ {at}s, as {res['decoded_as']})")
ff(['-f', 'lavfi', '-t', '4', '-i', 'sine=frequency=440:sample_rate=48000', '-af', 'volume=-20dB', '-c:a', 'pcm_s16le', 'takes/tone.wav'])
r = subprocess.run([sys.executable, os.path.join(SK, 'video-finish-qc', 'scripts', 'finish_clip.py'), '--root', d, '--hero', 'takes/bt601.mp4',
'--take', 'takes/tone.wav', '--in', '0.5', '--out', '2.0', '--handle', '0.5', '--name', 'MXC', '--canvas', f'{W}x{H}'],
capture_output=True, text=True)
if r.returncode != 0 or not os.path.exists(os.path.join(d, 'deliver', 'MXC.mp4')):
print('e2e finish_clip, bt601-tagged hero CANNOT: finish_clip.py failed\n' + (r.stdout + r.stderr)[-600:]); ok = False
else:
res = measure(os.path.join(d, 'deliver', 'MXC.mp4'), 0.5, 'tag', W, H)
good = res.get('ok') is not None and res['max_err'] <= LIMIT; ok &= good
print(f"e2e {'finish_clip, bt601-tagged hero':34s} max err {res.get('max_err', -1):3d} {'PASS' if good else 'FAIL'} (MXC.mp4 @ 0.5s, as {res.get('decoded_as')})")
for name, at in (('luma-only source, cube', 14.25), ('luma-only source, look none', 15.75)): # the bands keep their levels
g = subprocess.run(['ffmpeg', '-v', 'error', '-ss', str(at), '-i', os.path.join(d, M), '-frames:v', '1', '-vf',
'scale=in_range=tv:out_range=pc,format=gray', '-f', 'rawvideo', '-'], capture_output=True).stdout
lv = [round(sum(g[y * W + x] for y in range(H // 4, 3 * H // 4, 8) for x in range(c - 40, c + 40, 4)) / (len(range(H // 4, 3 * H // 4, 8)) * 20))
for c in (W // 6, W // 2, 5 * W // 6)] if len(g) >= W * H else []
good = len(lv) == 3 and all(abs(x - y) <= LIMIT for x, y in zip(lv, (16, 128, 235))); ok &= good
print(f"e2e {name:34s} levels {lv} (want 16/128/235 ±{LIMIT}) {'PASS' if good else 'FAIL'}")
print('FINISH-E2E', 'OK' if ok else 'FAILED', '' if keep else '(scratch removed)')
if not keep: shutil_rmtree(d)
return 0 if ok else 1
def shutil_copy(a, b):
import shutil; shutil.copyfile(a, b)
def shutil_rmtree(d):
import shutil; shutil.rmtree(d, ignore_errors=True)
def main():
if '--selftest' in sys.argv: sys.exit(selftest())
if '--finish-e2e' in sys.argv:
k = sys.argv[sys.argv.index('--keep') + 1] if '--keep' in sys.argv else None; sys.exit(finish_e2e(k))
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
sp = ap.add_subparsers(dest='cmd', required=True)
c = sp.add_parser('card'); c.add_argument('out', nargs='?'); c.add_argument('--html'); c.add_argument('--size', default='1920x1080')
m = sp.add_parser('measure'); m.add_argument('file'); m.add_argument('--at', type=float, default=1.0)
m.add_argument('--as', dest='as_', default='tag', choices=['tag', 'bt709', 'bt601']); m.add_argument('--max', type=int, default=LIMIT)
m.add_argument('--size', default='1920x1080'); m.add_argument('--json', action='store_true')
a = ap.parse_args(); W, H = size(a.size)
if a.cmd == 'card':
if not (a.out or a.html): ap.error('card needs <out.png> or --html <dir>')
if a.out and a.out.lower().endswith(('.mp4', '.mov', '.mkv')):
r = card_video(a.out, W, H); print('card video', a.out, f'{W}x{H}', f"BT.709 tv YUV, reads {r['max_err']} (the reference)")
elif a.out: card_png(a.out, W, H); print('card', a.out, f'{W}x{H}')
if a.html: card_html(a.html, W, H); print('card', os.path.join(a.html, 'index.html'), f'{W}x{H}')
return
res = measure(a.file, a.at, a.as_, W, H)
if a.json: print(json.dumps(res)); sys.exit(2 if res.get('ok') is None else 0 if res['max_err'] <= a.max else 1)
sys.exit(report(res, a.max))
if __name__ == '__main__':
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |