main
John Lauer Add insulated sensor library and reconcile off-board harness and staged labels 10fc208
"""Draft two existing reviewed action clips; no final assembly or approval implied."""
from pathlib import Path
import json,subprocess,hashlib
R=Path(__file__).resolve().parents[1];story=json.loads((R/'videos/build-storyboard.json').read_text());rows=[]
def duration(p):return float(subprocess.check_output(['ffprobe','-v','error','-show_entries','format=duration','-of','default=nw=1:nk=1',str(p)],text=True))
for clip in story['clips']:
 if clip['id']not in ['library-candidate-native','marked-ic-native']:continue
 name=clip['id'];audio=R/'videos/narration'/(name+'.mp3');text=audio.with_suffix('.txt');text.write_text(clip['narration']+'\n')
 subprocess.run(['adom-tts','say','@'+str(text),'--out',str(audio),'--thread','adom-custom-load'],check=True)
 sources={'library-candidate-native':'videos/library-candidate/library-candidate-orbit-2x.mp4','marked-ic-native':'videos/marked-ic-candidate/marked-ic-orbit-2x.mp4'}
 source=R/sources[name];vd,ad=duration(source),duration(audio);row={'id':name,'narration':clip['narration'],'sourceVideo':str(source.relative_to(R)),'sourceAudio':str(audio.relative_to(R)),'videoDuration':vd,'audioDuration':ad,'status':'draft; human review pending'}
 if ad+.15>vd:row['status']='audio too long; no video rendered'
 else:
  out=R/'videos/narrated-review'/(name+'.mp4')
  subprocess.run(['ffmpeg','-hide_banner','-loglevel','error','-y','-i',str(source),'-i',str(audio),'-map','0:v:0','-map','1:a:0','-c:v','copy','-af','adelay=75|75,apad','-c:a','aac','-b:a','128k','-t',str(vd),'-movflags','+faststart',str(out)],check=True)
  subprocess.run(['ffmpeg','-hide_banner','-loglevel','error','-i',str(out),'-f','null','-'],check=True)
  row.update(video=str(out.relative_to(R)),videoSha256=hashlib.sha256(out.read_bytes()).hexdigest(),fullDecode='pass')
 rows.append(row);print(json.dumps(row),flush=True)
(R/'videos/narrated-review/latest-drafts.json').write_text(json.dumps({'status':'No approvals or final assembly','clips':rows},indent=2)+'\n')