Skip to content

SamarthaJ/Clipper

Repository files navigation

Clipper

Banner

Clipper is a Python-based pipeline that takes a YouTube URL and produces TikTok-style vertical clips (9:16).
By default, it generates 8 clips of 45 seconds each.

Note: Clipper currently crops from the center of the video. Face-aware framing/motion tracking will be added in future releases.


✨ Features

  • ✅ Input: YouTube URL
  • ✅ Output: Multiple 9:16 vertical clips
  • ✅ Defaults: 8 clips × 45 seconds
  • ✅ Automatic temp & output folder creation
  • ✅ Simple CLI interface

📦 Requirements

  • OS: Windows / macOS / Linux
  • Python: 3.9–3.12
  • GPU: NVIDIA GPU recommended (CUDA) for best performance
  • FFmpeg: Required and must be available on PATH
  • PyTorch: Install with the CUDA build that matches your system (see below)

🚀 Installation

1) Create & activate a virtual environment

Windows (PowerShell):

python -m venv venv
.\venv\Scripts\activate

macOS/Linux (bash/zsh):

python -m venv venv
source venv/bin/activate
  1. PyTorch + CUDA note (important) Before installing requirements.txt, ensure the PyTorch wheels match your CUDA runtime.

In requirements.txt, you will see entries like:

torch --index-url https://download.pytorch.org/whl/cu<Version>
torchvision --index-url https://download.pytorch.org/whl/cu<Version>
torchaudio --index-url https://download.pytorch.org/whl/cu<Version>

Replace with the compatible CUDA build for your system, e.g.:
cu121 → CUDA 12.1
cu122 → CUDA 12.2
cu124 → CUDA 12.4
cu128 → CUDA 12.8
Example replacement:

torch --index-url https://download.pytorch.org/whl/cu128
torchvision --index-url https://download.pytorch.org/whl/cu128
torchaudio --index-url https://download.pytorch.org/whl/cu128

If you don’t have an NVIDIA GPU or prefer CPU-only, use the CPU wheels from the official PyTorch site and remove the CUDA suffix.

  1. Install dependencies

    pip install --upgrade pip
    pip install -r requirements.txt

    FFmpeg: If you don’t have FFmpeg, install it and make sure it’s on PATH.

Windows: winget install Gyan.FFmpeg or download a static build and add bin to PATH

macOS: brew install ffmpeg

Linux (Debian/Ubuntu): sudo apt-get install ffmpeg

▶️ Usage

Copy the YouTube URL of the video you want to clip.
Open a terminal in the project directory and activate your virtual environment.

Run the pipeline:

python main.py "https://www.youtube.com/watch?v=dQw4w9WgXcQ" 45 8

Arguments
arg1 (required): YouTube URL (wrap in quotes)
arg2 (optional): Clip duration in seconds (default: 45)
arg3 (optional): Number of clips to generate (default: 8)

Examples

# Defaults: 8 clips × 45s

python main.py "https://www.youtube.com/watch?v=abcdef"

# Custom: 6 clips × 30s

python main.py "https://www.youtube.com/watch?v=abcdef" 30 6

Important constraint: Total requested time must fit within the source video. Example: For an 8×45s request you need ≥ 360s of source. If the video is only 300s, the run will fail.

📂 Project Structure

After the first run, output/ and temp/ are created automatically.

alt text

📸 Output

Format: vertical 9:16 (1080×1920 by default, unless configured otherwise)
Count: as specified by number_of_clips
Location: output/

❓ FAQ

Q: Do I need an NVIDIA GPU?
A: Not strictly, but a CUDA-capable GPU speeds up processing significantly. CPU-only mode is possible with CPU PyTorch wheels.

Q: The script errors with duration mismatch. Why?
A: Your requested clip_duration × number_of_clips exceeds the video's total length. Reduce duration or the number of clips.

Q: Audio desync or quality issues?
A: Make sure FFmpeg is installed and up to date. Try re-running with fewer concurrent processes if your system is under heavy load.

Q: Face tracking?
A: Not yet. Current version crops from center. Face-aware framing is on the roadmap.

🧭 Roadmap

  • Face-aware framing / motion tracking
  • Smart cut-points via speech/scene detection
  • Auto B-roll insertion (royalty-free sources)
  • GUI wrapper
  • Presets for TikTok/Reels/Shorts export

🛡️ Legal & Usage Notes

Ensure you have the right to download, process, and redistribute any content you clip.Respect YouTube’s Terms of Service and copyright laws in your jurisdiction. Generated clips are for lawful use only.

🤝 Contributing

Contributions are welcome!
Open an issue for bugs/feature requests
Submit a PR with a clear description and testing notes
Follow conventional commit messages if possible

📜 License

This project is licensed under the MIT License. See LICENSE for details.

🗒️ Changelog

v0.1.0 – Initial public release: URL input → 9:16 clips (center-crop), defaults 8 × 45s.

About

Clipper is a youtube video to 9:16 Video clipper

Topics

Resources

License

Stars

Watchers

Forks

Languages