Skip to content

amys94fr/FaceFollow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📱 FaceFollow

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.

Python OpenCV MediaPipe License


✨ Features

  • 🎯 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

📦 Installation

git clone https://github.com/amys94fr/FaceFollow.git
cd FaceFollow
pip install -r requirements.txt

Python 3.9+ recommended.


🚀 Usage

Basic

python main.py my-landscape-video.mp4

This produces output_vertical.mp4 next to it.

With debug overlay & custom output

python main.py interview.mp4 \
    --output reel.mp4 \
    --debug debug.mp4

Tune the smoothing

# Very smooth (slow camera)
python main.py video.mp4 --smoothing 0.05

# Snappier (follows fast movement)
python main.py video.mp4 --smoothing 0.4

Live preview while processing

python main.py video.mp4 --preview

⚙️ All options

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

🧠 How it works

  1. Each frame is fed to MediaPipe's face detector.
  2. The largest face is selected (assumed to be the main subject).
  3. Its horizontal center is smoothed with an exponential moving average to avoid camera jitter.
  4. A 9:16 crop window is centered on the smoothed position and clamped to the frame.
  5. Frames are written to the output video using the mp4v codec.

🗂️ Output

  • 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.

📝 License

MIT © amys94fr

About

Auto-crop landscape videos into vertical 9:16 clips that follow the main face. Perfect for TikTok, Reels & Shorts.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages