main
John Lauer
Add 4:21 narrated Board34 R9 review draft with captions and current thermal limits
f42ada4
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
"""Build the authorized narrated review draft, preserving historical source takes.
Not a publication master: human editorial approval and thermal acceptance remain open.
"""
from pathlib import Path
import hashlib
import json
import subprocess
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / 'videos/full-edit-r9'
SEG = OUT / 'segments'
SEG.mkdir(parents=True, exist_ok=True)
FONT = '/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
def run(args):
subprocess.run(args, check=True, stdout=subprocess.DEVNULL)
def duration(path):
return float(subprocess.check_output([
'ffprobe', '-v', 'error', '-show_entries', 'format=duration',
'-of', 'default=nw=1:nk=1', str(path)], text=True))
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
plan = json.loads((ROOT / 'videos/four-minute-edit-plan.json').read_text())
excluded = {'peek-fastener-review', 'installed-fan-states', 'control-panel-twin',
'aln-stack-review', 'sensor-harness-review', 'board-glb-review',
'board32-results-review'}
scenes = [{
'id': 'opening-r9',
'source': 'docs/clips/board34-r9-carrier-narrated-review.mp4',
'audio': 'videos/full-edit-r9/narration/opening.mp3',
'narration': (OUT / 'narration/opening.txt').read_text().strip(),
'take': 11.708,
'tag': 'ADOM ELECTRONIC LOAD | Board34 / R9 engineering prototype'}]
for item in plan['selected']:
if item['id'] in excluded:
continue
narration = item.get('narration')
if item['id'] == 'temperature-bound-replay':
narration = (ROOT / 'videos/temperature-safety/narration.txt').read_text().strip()
assert narration, f"Missing actual spoken script: {item['id']}"
scenes.append({'id': item['id'], 'source': item['path'], 'narration': narration,
'tag': 'RECORDED DESIGN ITERATION | historical checkpoint'})
scenes += [
{'id': 'r9-carrier', 'source': 'docs/clips/board34-r9-carrier-narrated-review.mp4',
'narration': 'The probe simulation caught a real obstruction. We moved the heatsink support behind the board, cleared the corner pin, and checked the revised assembly again. These are design checks, not a tested hardware rating.',
'tag': 'BOARD34 / R9 | connected carrier and fastener clearance | CAD inspection 1.5x'},
{'id': 'r9-simulated-fan', 'source': 'docs/clips/board34-r9-fan-start-stop.mp4',
'audio': 'videos/full-edit-r9/narration/fan.mp3',
'narration': (OUT / 'narration/fan.txt').read_text().strip(),
'tag': 'PROBING SIMULATION | authored RPM | slowed rotor presentation'},
{'id': 'current-status', 'source': 'docs/clips/board34-r9-carrier-narrated-review.mp4',
'audio': 'videos/full-edit-r9/narration/closing.mp3', 'take': 13.5,
'narration': (OUT / 'narration/closing.txt').read_text().strip(),
'tag': 'CURRENT + MODELED PROBING PASS | THERMAL OPEN | BUILD QUOTE INCOMPLETE'}]
records = []
for i, scene in enumerate(scenes):
src = ROOT / scene['source']
audio = ROOT / scene['audio'] if scene.get('audio') else src
take = scene.get('take', duration(src))
label = OUT / f'label-{i:03}.txt'
label.write_text(scene['tag'])
dst = SEG / f'{i:03}.mp4'
vf = (f'scale=1920:1000:force_original_aspect_ratio=decrease,'
f'pad=1920:1080:(ow-iw)/2:60:color=0x151923,setsar=1,fps=30,'
f'drawtext=fontfile={FONT}:textfile={label}:fontcolor=white:fontsize=24:x=30:y=18')
args = ['ffmpeg', '-v', 'error', '-y', '-i', str(src)]
if audio != src:
args += ['-i', str(audio)]
args += ['-map', '0:v:0', '-map', '1:a:0' if audio != src else '0:a:0',
'-vf', vf, '-af', 'apad', '-t', str(take), '-c:v', 'libx264',
'-preset', 'veryfast', '-threads', '2', '-crf', '21', '-pix_fmt', 'yuv420p',
'-c:a', 'aac', '-b:a', '128k', '-ar', '48000', '-ac', '2', str(dst)]
run(args)
records.append({**scene, 'source': str(src.relative_to(ROOT)),
'sourceSha256': digest(src), 'audioSha256': digest(audio),
'output': str(dst.relative_to(ROOT)), 'duration': duration(dst)})
print(f'{i + 1}/{len(scenes)} {scene["id"]}', flush=True)
concat = OUT / 'concat.txt'
concat.write_text(''.join(f"file '{ROOT / x['output']}'\n" for x in records))
final = OUT / 'electronic-load-r9-review-1080p.mp4'
run(['ffmpeg', '-v', 'error', '-y', '-f', 'concat', '-safe', '0', '-i', str(concat),
'-c', 'copy', '-movflags', '+faststart', str(final)])
def stamp(seconds):
ms = round(seconds * 1000)
return f'{ms // 3600000:02}:{ms // 60000 % 60:02}:{ms // 1000 % 60:02}.{ms % 1000:03}'
t = 0
chapters, captions = [], ['WEBVTT\n']
for scene in records:
chapters.append({'t': round(t, 3), 'title': scene['id'].replace('-', ' ')})
captions.append(f"{stamp(t)} --> {stamp(t + scene['duration'])}\n{scene['narration']}\n")
t += scene['duration']
(OUT / 'captions.vtt').write_text('\n'.join(captions))
(OUT / 'chapters.json').write_text(json.dumps(chapters, indent=2) + '\n')
assert 240 <= duration(final) <= 300, 'Review cut must stay within requested 4–5 minutes'
report = {'status': 'narrated-review-draft-human-editorial-approval-pending',
'board': 'Board34/R9', 'thermalAccepted': False, 'youtubePublished': False,
'file': str(final.relative_to(ROOT)), 'sha256': digest(final),
'durationSeconds': duration(final), 'scenes': records,
'limitations': ['Historical clips retain their original revision-specific results.',
'Caption timing is per scene, not word-aligned.',
'No fabricated hardware, airflow or complete cost claim.',
'Brand stings and final human editorial review remain open.']}
(OUT / 'edit-report.json').write_text(json.dumps(report, indent=2) + '\n')
print(json.dumps({k: v for k, v in report.items() if k != 'scenes'}), flush=True)