from pathlib import Path
import subprocess
root=Path(__file__).parent
font='/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf'
for side,sha in [('before','d290c1f1b6'),('after','b6d06e4cc3')]:
 for location in ['outside','inside']:
  src=root/f'{side}-{location}-raw.png'; out=root/f'{side}-{location}.png'
  subprocess.run(['convert',str(src),'-crop','1078x1200+1802+184','+repage','-resize','539x600','-background','#070b13','-gravity','north','-splice','0x75','-font',font,'-fill','white','-pointsize','15','-gravity','northwest','-annotate','+14+8',f'{side.upper()} {sha} | {location} workspace','-pointsize','13','-annotate','+14+31','Web / Chromium / Linux | dark / 1440 x 1000','-annotate','+14+51','Rendered file preview (cropped from app)',str(out)],check=True)
 filters="scale=1440:1000,drawbox=x=300:y=128:w=600:h=115:color=black:t=fill,drawtext=fontfile="+font+":text='Outside workspace review (path redacted)':x=310:y=140:fontsize=16:fontcolor=white,drawtext=fontfile="+font+":text='Inside workspace review (path redacted)':x=310:y=188:fontsize=16:fontcolor=white,drawbox=x=901:y=52:w=400:h=28:color=black:t=fill,drawtext=fontfile="+font+":text='HTML file preview - path redacted':x=915:y=60:fontsize=13:fontcolor=white,pad=1440:1048:0:48:color=0x070b13,drawtext=fontfile="+font+f":text='{side.upper()} {sha} | Web / Chromium / Linux | dark / 1440 x 1000':x=20:y=14:fontsize=20:fontcolor=white"
 subprocess.run(['ffmpeg','-y','-i',str(root/f'{side}-final-raw.mp4'),'-vf',filters,'-c:v','libx264','-crf','20','-pix_fmt','yuv420p','-an','-movflags','+faststart',str(root/f'{side}-playback.mp4')],stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,check=True)
