# Usage: python3 redact.py RAW_RUN_DIRECTORY SHARE_DIRECTORY
# Redacts only the environment-name area. The model picker is already hidden
# by the driver before entering the draft. Raw files are preserved.
import pathlib, subprocess, sys
source, dest = map(pathlib.Path, sys.argv[1:])
dest.mkdir(parents=True, exist_ok=False)
filter_spec = "drawbox=x=1340:y=99:w=220:h=22:color=black:t=fill,drawtext=text='Environment redacted':x=1346:y=102:fontcolor=white:fontsize=12"
for original in sorted(source.iterdir()):
    if original.suffix not in ('.png', '.mp4'):
        continue
    args=['ffmpeg','-y','-loglevel','error','-i',str(original),'-vf',filter_spec]
    if original.suffix == '.mp4':
        args += ['-c:v','libx264','-preset','fast','-crf','20','-pix_fmt','yuv420p','-movflags','+faststart']
    else:
        args += ['-frames:v','1']
    subprocess.run(args+[str(dest/original.name)], check=True)
