import ffmpeg


def extract_frame(video_path: str, timestamp_ms: int, output_path: str):
    """Extract a single frame from video at timestamp."""
    ss = timestamp_ms / 1000.0
    try:
        (
            ffmpeg.input(video_path, ss=ss)
            .output(output_path, vframes=1)
            .overwrite_output()
            .run(capture_stdout=True, capture_stderr=True)
        )
        return True
    except ffmpeg.Error as e:
        print(f"Error extracting frame: {e.stderr.decode()}")
        return False
