main
John Lauer
Lead with 4m34 narrated build plus recorded 3D thermal comparison and captions
136ebf1
from pathlib import Path
import json,subprocess,time
R=Path(__file__).resolve().parents[1];O=R/'videos/cooling-volume'
def ab(verb,args):
p=subprocess.run(['adom-bridge','--ai-thread','adom-custom-load',verb,json.dumps(args)],capture_output=True,text=True,check=True);r=json.loads(p.stdout)
if r.get('success') is False or r.get('ok') is False or r.get('error'):raise RuntimeError(str(r))
return r
def ev(s):return ab('pup_eval',{'expression':s})
scenes=json.loads((O/'narration.json').read_text());records=[]
for n,s in enumerate(scenes):
name,h=[('chipset40',100),('chipset40',5),('preferred50',100),('pi5',100),('chipset40',100)][n]
ev(f"selectThermal('{name}',{h})")
ev("(()=>{for(const id of ['sink','layers']){document.getElementById(id).checked=true;document.getElementById(id).dispatchEvent(new Event('change'));}const c=thermalViewer.getCamera();c.alpha=.8;c.beta=.55;return window.thermalState;})()")
if n==0:ev("document.getElementById('scale').click()")
if n==1:ev("document.getElementById('scale').click()")
if n==2:ev("document.getElementById('scale').click()")
d=float(subprocess.check_output(['ffprobe','-v','error','-show_entries','format=duration','-of','csv=p=0',str(O/(s['id']+'.mp3'))],text=True))
start=ab('pup_record_start',{});t=time.monotonic()
try:
time.sleep(2)
if n==0:
ev("(()=>{document.getElementById('sink').checked=false;document.getElementById('sink').dispatchEvent(new Event('change'));return true;})()")
time.sleep(3);ev("document.getElementById('section').click()")
elif n==4:
ev("document.getElementById('section').click()")
time.sleep(4)
ev("(()=>{document.getElementById('sectionImage').src='./power-comparison.png';return true;})()")
else:
ev("(()=>{let n=0;const timer=setInterval(()=>{thermalViewer.getCamera().alpha+=.008;if(++n>=60)clearInterval(timer);},100);return true;})()")
time.sleep(max(0,d-(time.monotonic()-t)+.5))
finally:stop=ab('pup_record_stop',{})
rec={**s,'audioSeconds':d,'startReceipt':start,'stopReceipt':stop};records.append(rec);(O/'native-recordings.json').write_text(json.dumps(records,indent=2));print(s['id'],json.dumps(stop)[:400],flush=True)