Turn any landscape video into a vertical 9:16 clip that automatically follows the main face. Perfect for repurposing horizontal content into TikTok / Reels / Shorts.
- 🎯 Robust face detection powered by MediaPipe (much more reliable than Haar cascades)
- 🎚️ Smooth tracking with an exponential moving average — no jumpcuts, no jitter
- 📐 Auto 9:16 framing centered on the subject
- 🖼️ Optional debug video with face + crop window overlays
- 🛠️ Simple CLI with sensible defaults
- 🪶 Single file, ~250 lines
git clone https://github.com/amys94fr/FaceFollow.git
cd FaceFollow
pip install -r requirements.txtPython 3.9+ recommended.
python main.py my-landscape-video.mp4This produces output_vertical.mp4 next to it.
python main.py interview.mp4 \
--output reel.mp4 \
--debug debug.mp4# Very smooth (slow camera)
python main.py video.mp4 --smoothing 0.05
# Snappier (follows fast movement)
python main.py video.mp4 --smoothing 0.4python main.py video.mp4 --preview| Flag | Default | Description |
|---|---|---|
input |
— | Path to the landscape input video (positional) |
-o, --output |
output_vertical.mp4 |
Path to the cropped vertical output |
-d, --debug |
(none) | Optional debug video with overlays |
--smoothing |
0.15 |
EMA factor (0, 1] — lower = smoother, higher = more reactive |
--confidence |
0.5 |
Min face detection confidence [0, 1] |
--preview |
off | Show realtime preview windows |
- Each frame is fed to MediaPipe's face detector.
- The largest face is selected (assumed to be the main subject).
- Its horizontal center is smoothed with an exponential moving average to avoid camera jitter.
- A 9:16 crop window is centered on the smoothed position and clamped to the frame.
- Frames are written to the output video using the
mp4vcodec.
output_vertical.mp4— the final 9:16 cropped video, ready for upload.debug.mp4(optional) — the original landscape video with the detected face (red) and the crop window (green) drawn on top. Useful to tune--smoothing.
MIT © amys94fr