import json, pathlib, subprocess, sys
from PIL import Image, ImageDraw
root=pathlib.Path(sys.argv[1]); out=pathlib.Path(__file__).parent
proof=json.loads((root/'scripts/.e2e/prove/proof.json').read_text())
for side,seek,duration in [('base',18.7,5),('head',16.7,2.6)]:
    src=proof[side]['captures'][0]
    im=Image.open(src)
    draw=ImageDraw.Draw(im)
    y=263 if side=='base' else 253
    draw.rectangle((375,y,577,y+18),fill='#eeeeee')
    draw.text((379,y+2),'[temporary workspace path]',fill='#666666')
    im.save(out/f'{side}.png')
    subprocess.run(['ffmpeg','-y','-loglevel','error','-ss',str(seek),'-t',str(duration),'-i',proof[side]['videos'][0],'-vf',"drawbox=x=375:y=250:w=205:h=70:color=0xeeeeee:t=fill,tpad=stop_mode=clone:stop_duration=3",'-an','-c:v','libx264','-pix_fmt','yuv420p',str(out/f'{side}.mp4')],check=True)
