Clipcraft is a video clipping backend built with FastAPI and FFmpeg. Give it a video URL and one or more time ranges; it downloads the source once, cuts each range (optionally adding a 2× slow-motion copy), merges everything, and can swap in a background audio track.
- Download any yt-dlp-supported URL (cached and deduplicated per video).
- Extract multiple segments (
start-end start-end ...) in parallel. - Optional 2× slow motion per segment.
- Optional background-audio replacement (looped to fit).
- Async task pipeline with progress, cancel, retry, edit, and resume-on-restart.
- Web UI served at
/.
| File | Responsibility |
|---|---|
clipcraft.py |
FastAPI app and API routes |
pipeline.py |
TaskManager: async orchestration, caching, cancellation, resume |
media.py |
Async ffmpeg / ffprobe / yt-dlp subprocess wrappers |
db.py |
SQLite (WAL) + SQLAlchemy model |
Performance design:
- Every ffmpeg/yt-dlp call runs as an async subprocess — the API never blocks.
- Each clip is produced in a single encode pass straight from the source
(input seeking with
-ss/-to, slow-motion filter applied in the same pass). - All clips encode concurrently (bounded by
CLIPCRAFT_PARALLEL_ENCODES, default 2) with identical codec settings. - The final merge is a stream copy (concat demuxer) — zero re-encode.
- Audio replacement stream-copies the video and loops the audio in one pass.
- Downloads, clips, and outputs are written atomically and cached, so retries and restarts skip completed work.
pip install -r requirements.txt # plus ffmpeg on your PATH
cd py
uvicorn clipcraft:app --port 8000Open http://localhost:8000.
docker build -t clipcraft .
docker run -p 8000:8000 clipcraft