Automated fancam generator. It takes a standard landscape video and a reference photo of a person (say, your bias), tracks them, and generates a stabilized, vertical (9:16) cropped video locked onto them.
It features a modular Rust core for high-speed video processing, a CLI for batch operations, and a modern Tauri v2 desktop application for easy usage.
This project is organized as a Cargo workspace:
fancam-core/ — Rust engine for detection, identity matching, tracking, and renderingcli/ — command-line interface for batch and scripted workflowssrc-tauri/ + ui/ — Tauri desktop app with a Svelte frontend
git clone https://github.com/wheevu/focus-lock-rs.git
cd focus-lock-rs
cargo build --release -p cli
Create a models/ directory in the project root and add:
yolov8n.onnxw600k_mbf.onnxosnet_x0_25_msmt17.onnx (optional but recommended for harder multi-person tracking / occlusion recovery)For macOS, ensure a CoreML-enabled libonnxruntime.dylib is available at models/onnxruntime/lib/ (or set ORT_DYLIB_PATH).
cd ui
npm install
npm run tauri:dev
For a production build:
npm run tauri:build
Generate a fancam from a landscape video and reference image:
cargo run --release -p cli -- fancam \
--video "/path/to/concert.mp4" \
--bias "/path/to/face_photo.jpg" \
--output "output_fancam.mp4" \
--yolo-model "models/yolov8n.onnx" \
--face-model "models/w600k_mbf.onnx" \
--threshold 0.6
MIT
The pipeline combines person detection and face recognition to keep the crop locked onto a specific subject rather than just the most visible person in frame.
--threshold value is used consistently across both CLI and GUI workflowsThis makes the tracker more stable in crowded performance footage where multiple people may appear and disappear across frames.
The desktop app includes a pre-tracking discovery flow designed to make target selection more reliable before rendering begins.
The Tauri backend persists scan sessions and validates review state server-side before allowing a render to begin.
To make the review and render flow more robust, scan sessions track explicit lifecycle states:
proposedvalidatedtrackingcompletedfailedAudit events are recorded through the session lifecycle, and run_fancam enforces that a validated session and selected identity match exist on the backend side, not just in the UI.
The GUI also supports manual split requests per identity, with a split-rescan path that refreshes candidate clustering when the initial grouping is not clean enough.
To avoid shaky or jumpy crops, the render path uses a 2D Kalman filter to smooth subject motion across frames.
This helps with:
If the subject becomes occluded, the filter predicts the next likely position based on previous motion until visual confirmation is regained.
The core processing path is built around a 3-thread decode / inference / encode pipeline with bounded channels.
Performance-oriented behavior includes:
detect, identify, and renderThese optimizations are aimed at keeping the pipeline responsive and practical for longer videos without turning the whole thing into a heater-core cosplay.
Rendering is optimized for vertical fancam output while remaining resilient when tracking quality changes.
fast_image_resizeThis keeps output usable even when the tracker cannot confidently maintain a tight crop for every frame.
The project supports two main usage paths:
The Tauri desktop application is intended for interactive use:
The CLI is better suited for:
The project is designed to run across Windows, macOS, and Linux, with a shared Rust processing core and a Tauri-based desktop frontend.