Skip to content

alanhuang67/beatcut

Repository files navigation

Beatcut

Drop a song. Drop a folder of clips. Get a cut-to-the-beat video — automatically.

English · 中文

License: AGPL-3.0 Status Python

Beatcut — drop a song, drop your clips, get a cut to the beat


What it is

Beatcut is the decision and rendering layer between raw footage and a finished cut. You bring the music and clips; it analyzes the music's structure (beats, downbeats, sections, energy curve), looks at your clips (scene boundaries, motion), then arranges and renders an MP4 that lands cuts on the right notes.

Not a beat-detection library — it stands on beat-this and friends. Not AI video generation. Not a full NLE. It's the editorial brain that picks which clip lands on which beat, plus the render pipeline that ships an MP4.

Why it's different

  • Rhythm-reactive transitions — the same song picks flash_cut at drops, fade on quiet passages, hard cuts during fast sequences, and crossfades on energy buildups. Driven by the music's energy curve, not a static preset.
  • Cut feels, not just presets — pick EDM, Vlog, Cinematic, Punchy, or Single Take and the matcher's whole shape changes (slot density, scene-fit weighting, transition policy).
  • Hot-pluggable text templates — drop a folder into ~/.beatcut/plugins/text_templates/ and it appears in the WebUI. Templates are Jinja2-rendered ASS for libass.
  • Three interfaces, one core — Python SDK, CLI (Typer), local WebUI (FastAPI + React) all share the same library.

What it looks like

Editor — waveform with section markers, candidate windows, cut params

The Editor surfaces the musical structure first: section labels (INTRO / CHORUS / VERSE), beat-grid ruler, frequency-band energy bars, and candidate windows the system picked. Tweak MODE, DURATION, and CUT FEEL, then re-pick — every choice is reversible and re-runnable.

Quickstart · alpha (from source)

Until v0.2 ships to PyPI, install from source:

git clone https://github.com/alanhuang67/beatcut
cd beatcut
./scripts/install.sh
source .venv/bin/activate   # on Windows: .venv\Scripts\activate
beatcut serve               # → http://localhost:7860

install.sh does the full setup in one shot:

  • Validates Python ≥ 3.11 and Node ≥ 18
  • Auto-installs ffmpeg via Homebrew on macOS (skipped if already on PATH; Linux prints the apt install ffmpeg hint instead, since sudo would block the script)
  • Creates a .venv (uv if available, falls back to python -m venv)
  • Installs beatcut[full,gemini] (~500 MB — torch + beat-this + opencv + scenedetect + google-genai)
  • Builds the React WebUI bundle

Takes ~5 min on a clean macOS box. If ffmpeg isn't found and can't auto-install, Beatcut falls back to bundled imageio-ffmpeg at runtime (system ffmpeg is preferred for hardware encoders, but not strictly required).

Why no pip install beatcut yet? Beatcut depends on beat-this, which is currently distributed only as a git+ URL — and PyPI rejects packages that pull source dependencies. Once beat-this (or a fork) is republished as a regular PyPI package, install becomes a one-liner: pip install beatcut[full].

CLI

# One-shot end-to-end:
beatcut auto song.mp3 ./footage/ -o output.mp4

# Project flow:
beatcut project create "My Vlog"
beatcut project add-audio <id> song.mp3 --copy
beatcut project add-videos <id> ./footage/ --copy
beatcut auto --project <id> -o output.mp4

# Diagnostics:
beatcut doctor      # ffmpeg / torch / libass / cache report
beatcut cache info  # cache size + breakdown

What works today (v0.1.0-alpha)

  • ✅ Local project management (CLI + WebUI) with auto-cleanup of derived artifacts
  • ✅ Audio analysis — beat-this (SOTA beat / downbeat) + librosa for sections + frequency-band energy
  • ✅ Scene detection — PySceneDetect content-aware splitting + auto-proxy for big sources
  • ✅ Optional per-scene visual understanding via Gemini (bring your own API key)
  • ✅ Cut-feel matcher — 5 feels × variety window × scene-fit scoring
  • ✅ Multi-candidate batch picker — system finds N good musical windows, you pick the winner
  • ✅ Rhythm-reactive transitions — cut / fade / xfade_crossfade / flash_cut
  • ✅ Render pipeline — chunked, resumable, hardware-accelerated when available
  • ✅ Multi-version delivery gallery — render the same window with different feels and compare
  • ✅ Optional RIFE frame interpolation (NCNN / Vulkan, no CUDA required)

What's coming

  • 🔄 More cut feels and additional text templates (title_card, caption)
  • 🔄 Manual timeline editing — drag-to-replace clips, manual beat overrides
  • 🔄 Full xfade catalog (50+ transition variants)
  • 🔄 FCPXML export for Premiere / DaVinci / FCP roundtrips
  • 🔄 PyPI publication once beat-this is republished as a regular package

Acknowledgments

Beatcut stands on excellent open-source work. Credit where due:

Beatcut's contribution is the integration layer: rhythm-reactive transition policy, beat-aligned cut snapping, project-level state machine, hot-pluggable text effect templates, and the WebUI / CLI / SDK packaging that makes the above usable as one tool.

Development

git clone https://github.com/alanhuang67/beatcut
cd beatcut
uv venv --python 3.13 .venv
uv pip install -e ".[dev]"

# Run tests
uv run pytest

# Lint + format
uv run ruff check .
uv run ruff format .

# Build the React WebUI (one-time + after frontend changes)
bash scripts/build_frontend.sh

License

AGPL-3.0-or-later. External contributors are required to sign the CLA.

Disclaimer

Beatcut does not check copyright on the music or footage you use. You are responsible for ensuring you have rights to the media you process. For royalty-free music, try Pixabay Music or Free Music Archive.


Made by Alan Huang.

About

Music-driven automatic video editor

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors