"""
Example integration snippet for the Fumoca worker pipeline.

Expected flow:
1. download queued video from storage
2. run frame extraction engine
3. feed selected_frames into COLMAP / splat pipeline
4. upload outputs and manifest
5. update job columns:
   - extracted_frame_count
   - selected_frame_count
   - frame_strategy
"""

from pathlib import Path
import json
import subprocess

def run_frame_extraction(video_path: str, work_dir: str, profile: str = "standard") -> dict:
    out_dir = Path(work_dir) / "frame_selection"
    out_dir.mkdir(parents=True, exist_ok=True)

    cmd = [
        "python",
        str(Path(__file__).parent / "frame_extraction_engine.py"),
        "--input", video_path,
        "--output", str(out_dir),
        "--profile", profile,
    ]
    subprocess.run(cmd, check=True)

    with open(out_dir / "summary.json", "r", encoding="utf-8") as f:
        return json.load(f)
