import subprocess
import sys
from pathlib import Path

# Keep Git's diagnostic output; remove incidental shell prompts and error paths.
proof, output = map(Path, sys.argv[1:])
for side, start, reveal in [('base', 14.5, 26.5), ('head', 8.8, 20)]:
    source = next((proof / side / 'results').rglob('video.webm'))
    filters = (
        'drawbox=x=255:y=650:w=1025:h=65:color=white:t=fill,'
        f"drawbox=x=255:y=520:w=1025:h=280:color=white:t=fill:enable='lt(t,{reveal})',"
        'drawbox=x=900:y=120:w=380:h=80:color=white:t=fill,'
        f'trim=start={start},setpts=PTS-STARTPTS'
    )
    subprocess.run(['ffmpeg', '-v', 'error', '-i', str(source), '-vf', filters,
                    '-an', '-c:v', 'libx264', '-crf', '19', '-pix_fmt', 'yuv420p',
                    '-movflags', '+faststart', str(output / f'{side}-verified-interaction.mp4')], check=True)
