import argparse, pathlib, subprocess
p=argparse.ArgumentParser(); p.add_argument('input');p.add_argument('output');p.add_argument('--side',choices=['base','head','manual'],required=True); a=p.parse_args()
filters=[]
def box(x,y,w,h,enable=None):
 s=f'drawbox=x={x}:y={y}:w={w}:h={h}:color=0x34343b:t=fill'
 if enable:s+=f":enable='{enable}'"
 filters.append(s)
if a.side=='head':
 box(405,1040,270,85,"between(t,7,18)")
 box(290,1160,410,85,"between(t,7,18)")
 
if a.side=='base':
 box(650,1040,380,85,"between(t,6,34.5)")
 box(290,1040,740,85,"between(t,6,8)")
 
filters+=['crop=1080:1452:0:0','scale=540:726','fps=15']
subprocess.run(['ffmpeg','-y','-v','error','-i',a.input,'-vf',','.join(filters),'-c:v','libx264','-preset','fast','-crf','22','-pix_fmt','yuv420p','-movflags','+faststart',a.output],check=True)
