main
John Lauer Corrected Astra ESC routing: native zero-open result, full accounting and voiceover handoff a80479d 23d ago
from pathlib import Path
import subprocess,json,shlex,sys
D=Path(__file__).parent
inp=str(D/'raw/accepted.mp4');out=str(D/'docs/videos/astra-routing-esc-g431.mp4')
def run(a):
 with open(D/'evidence/media-commands.txt','a') as f:f.write(shlex.join(a)+'\n')
 subprocess.run(a,check=True)
def probe(p):return json.loads(subprocess.check_output(['ffprobe','-v','error','-show_format','-show_streams','-of','json',str(p)]))
p=probe(inp);dur=float(p['format']['duration']);(D/'evidence/raw-probe.json').write_text(json.dumps(p,indent=2))
if '--encode-only' not in sys.argv:
 for label,t in [('start',2),('middle',dur/2),('end',dur-2)]:run(['ffmpeg','-v','error','-ss',str(t),'-i',inp,'-frames:v','1','-y',str(D/f'evidence/raw-{label}.jpg')])
if '--frames-only' in sys.argv:sys.exit(0)
run(['ffmpeg','-i',inp,'-vf','scale=1920:-2','-c:v','libx264','-crf','22','-pix_fmt','yuv420p','-movflags','+faststart','-an','-y',out])
run(['ffmpeg','-v','error','-ss',str(dur-2),'-i',out,'-frames:v','1','-q:v','2','-y',str(D/'docs/videos/astra-routing-esc-g431-poster.jpg')])
run(['ffmpeg','-v','error','-i',out,'-f','null','-'])
meta=probe(out);stop=json.load(open(D/'evidence/final-recording-stop.json'))
(D/'evidence/media.json').write_text(json.dumps(dict(duration=float(meta['format']['duration']),rawDuration=dur,recorderWallSeconds=stop['elapsedMs']/1000,streams=meta['streams'],bytes=int(meta['format']['size']),cuts=False,speedChanges=False),indent=2))
print('MEDIA_READY',dur,flush=True)