Use RetinaFace to detect and automatically track faces in video sequences with smooth camera movement effects
Automatically track faces in video sequences with smooth camera movement effects. This node processes a batch of video frames and creates a cinematic tracking effect that follows the largest face in the scene.
-
images: Input video frames as a batch of images with shape (batch, height, width, channels) -
smoothness: Controls camera movement smoothness (default: 0.85, range: 0.0-0.98). 0=no smoothing, 0.85=recommended, 0.95=ultra smooth (eliminates jitter) -
responsiveness: Controls reaction speed to face movement (default: 0.3, range: 0.1-1.0). 0.1=very stable, 0.3=recommended, 1.0=fast response (may jitter) -
detect_interval: Face detection frequency for performance optimization (default: 1, range: 1-30). 1=every frame (most accurate), 5=5x speed boost -
aspect_ratio: Output aspect ratio for the tracked video (default: 16:9) -
output_width: Output video width, 0=auto calculate based on aspect ratio (default: 0, range: 0-8192) -
output_height: Output video height, 0=auto calculate based on aspect ratio (default: 0, range: 0-8192) -
scale_factor: How much padding to add around detected faces (default: 8.5, range: 1.0-10.0) -
shift_factor: Vertical positioning of face in frame (default: 0.33, range: 0-1). 0=top edge, 0.5=center, 1.0=bottom edge
Returns:
tracked_video: The processed video with smooth face trackingtracking_info: Detailed tracking report including statistics and frame-by-frame information
Algorithm Features:
- Intelligent keyframe selection for optimal performance
- Exponential Moving Average (EMA) smoothing with adaptive speed limits
- Subpixel smoothing to eliminate tiny camera jitter
- Automatic resolution calculation based on input and aspect ratio
- Smooth interpolation between detection frames
- Comprehensive tracking statistics and reporting
Performance Tips:
- Higher
detect_intervalvalues provide significant speed boosts (e.g., 5x faster with interval=5) - The algorithm automatically balances detection accuracy with performance
- Use reasonable
scale_factorvalues (0.8-0.9) for best results - For videos with fast-moving subjects, increase
responsivenessslightly
Forked and modified from liusida/ComfyUI-AutoCropFaces
