main
John Lauer Keep all six R11 review clips clean; deliver captions through the Wiki player e1f6118
from pathlib import Path
import json,subprocess
R=Path(__file__).resolve().parents[1];O=R/'videos/compact-r11/chapter'
cues=[(0,1.8,'The bare board cleared the probes,'),(2.07,3.96,'but adding the cooler exposed a bug:'),(4.27,6.29,'the checker was skipping large objects.'),(6.72,10.89,'After fixing it, the replay found real collisions\nand wire snags.'),(11.32,13.56,'That sends this design back to placement,'),(13.92,18.44,'where we move the probe ground and the five-volt\ntest point into the access corridor.')]
def t(s):m=round(s*1000);return f'00:00:{m//1000:02}.{m%1000:03}'
(O/'04-clearance.vtt').write_text('WEBVTT\n\n'+''.join(f'{t(a)} --> {t(b)}\n{c}\n\n'for a,b,c in cues))
(O/'04-clearance.srt').write_text('\n'.join(f"{i+1}\n{t(a).replace('.',',')} --> {t(b).replace('.',',')}\n{c}\n"for i,(a,b,c)in enumerate(cues)))
n=json.loads((O/'04-clearance.json').read_text())['text'];(O/'04-clearance.txt').write_text(n+'\n')
vf=f"[0:v]trim=end=14.1,setpts=(PTS-STARTPTS)/{14.1/11.32},crop=2560:1396:0:132,scale=1280:698,pad=1280:720:0:0,fps=30,setsar=1[v0];[1:v]scale=-2:720,pad=1280:720:(ow-iw)/2:0,trim=duration=7.24,setpts=PTS-STARTPTS,fps=30,setsar=1[v1];[v0][v1]concat=n=2:v=1:a=0,pad=1280:810:0:0:color=0x101820[v];[2:a]atrim=end=18.56,loudnorm=I=-16:TP=-1.5:LRA=7[a]"
out=O/'04-clearance-review.mp4';subprocess.run(['ffmpeg','-y','-loglevel','error','-i',str(R/'videos/compact-r11/window-3147662-20261014-020304.mp4'),'-loop','1','-i',str(R/'revisions/compact-r11/kicad/probe-routed-review.png'),'-i',str(O/'04-clearance.mp3'),'-filter_complex',vf,'-map','[v]','-map','[a]','-t','18.56','-c:v','libx264','-preset','fast','-crf','23','-pix_fmt','yuv420p','-c:a','aac','-movflags','+faststart',str(out)],check=True)
q=subprocess.run(['ffmpeg','-hide_banner','-i',str(out),'-af','silencedetect=noise=-40dB:d=0.7','-f','null','-'],capture_output=True,text=True,check=True);(O/'04-clearance-silence.log').write_text(q.stderr);assert 'silence_start'not in q.stderr
subprocess.run(['adom-video-post','manifest','add',str(O/'storyboard.json'),'--id','04-clearance','--title','Probe checker repair sends the board back to placement','--description','Actual Pup saved-result review at 1.25x, followed by a native render of the DRC-clean relocation candidate. Cooler geometry is provisional; replay acceptance pending.','--raw',str(out),'--narration',n,'--warning','Saved-result review, not live solver footage. Revised cooler assembly is not qualified.'],check=True)
print('Fourth review clip prepared; final assembly still awaits per-clip review.')