Skip to content
franra18Public

About

🎬 Turn YouTube videos into vertical 9:16 Shorts with face-tracked framing and animated AI subtitles. FastAPI + Redis worker + OpenCV + Whisper + FFmpeg, React frontend, all in Docker.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

26 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 ClipSync

Turn any YouTube video into a vertical 9:16 Short, with face-tracked framing and animated subtitles, in one click.

ClipSync is a full-stack, containerised video clipping tool. Paste a YouTube link, pick a start and end time, and an asynchronous worker downloads the segment, transcribes it, detects the speaker's face and renders a ready-to-post vertical clip.

Python FastAPI React OpenCV Redis MinIO Docker


πŸ“‘ Table of Contents


πŸŽ₯ Demo

Video.demo.clipsync.mp4

✨ Features

  • πŸ”— YouTube in, Short out: paste a link and a time range (MM:SS or HH:MM:SS). Only that segment is downloaded.
  • πŸ“± Vertical 9:16 output: 1080 Γ— 1920 MP4 (H.264 + AAC), ready for YouTube Shorts, TikTok or Reels.
  • πŸ™‚ Face-tracked framing: a neural face detector finds the speaker and builds a close-up "facecam" panel.
  • πŸ’¬ Animated subtitles: word-level transcription burned into the video in short, punchy 2-word chunks with a pop-in animation.
  • ⚑ Asynchronous processing: jobs are queued in Redis and processed by a background worker, so the API responds instantly.
  • πŸ“¦ Object storage: finished clips are stored in MinIO (S3-compatible), downloaded through a presigned URL and deleted automatically after 7 days (CLIP_RETENTION_DAYS).
  • 🐳 One-command setup: the whole stack runs with Docker Compose.

βš™οΈ How It Works

Each job goes through this pipeline in the worker:

  1. Download: yt-dlp fetches only the requested range (video up to 1440p plus audio), with keyframes forced at the cuts and a near-lossless intermediate encode so the face close-up stays sharp.
  2. Transcribe: faster-whisper (base model, CPU, int8) generates word-level timestamps, which are turned into an animated .ass subtitle file.
  3. Detect the face: OpenCV's DNN module runs a Caffe SSD ResNet-10 face detector (300 Γ— 300 input) on sampled frames and keeps the most confident detection. If no face is found, it falls back to the top-left corner, where stream webcams usually sit.
  4. Render: FFmpeg stacks two panels into a 1080 Γ— 1920 frame, a lightly sharpened 1080 Γ— 720 face close-up on top and a 1080 Γ— 1200 view of the full scene below, and burns in the subtitles.
  5. Store: the clip is uploaded to MinIO and the job is marked COMPLETED. The frontend polls the job and shows the download link.

Job states: QUEUED β†’ PROCESSING β†’ COMPLETED / FAILED. If the worker restarts mid-job, the job goes back to the queue. Job state is kept in Redis for 24 hours.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  POST /api/clips   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   push job    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Frontend  β”‚ ─────────────────▢ β”‚  FastAPI   β”‚ ────────────▢ β”‚  Redis  β”‚
β”‚ React+Vite β”‚ ◀───────────────── β”‚    API     β”‚ ◀──── status ─│ (queue) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  GET /{job_id}     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
      β–²            (polling)            β”‚ presigned URL             β”‚ pop job
      β”‚                                 β–Ό                           β–Ό
      β”‚                           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   upload clip β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
      └──────── download ──────── β”‚   MinIO    β”‚ ◀──────────── β”‚  Worker  β”‚
                                  β”‚ (S3 store) β”‚               β”‚ yt-dlp Β· β”‚
                                  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚ Whisper Β·β”‚
                                                               β”‚ OpenCV Β· β”‚
                                                               β”‚ FFmpeg   β”‚
                                                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Tech Stack

Area Technology
API Python 3.11, FastAPI, Uvicorn, Pydantic
Worker yt-dlp, faster-whisper, OpenCV DNN (Caffe SSD face detector), FFmpeg
Queue & state Redis 7
Storage MinIO (S3-compatible) via boto3
Frontend React 18, Vite 5, Tailwind CSS, Lucide React
Infrastructure Docker, Docker Compose, pnpm (Corepack) on Node 20 Alpine

πŸ”Œ API

Interactive docs are available at http://localhost:8000/docs.

Method Endpoint Description
POST /api/clips Queues a new clip. Body: { "video_url", "start_time", "end_time" }. Returns 202 with the job_id, or 422 if the times are invalid or the end is not after the start.
GET /api/clips/{job_id} Returns the job status, the error message if it failed and, once completed, a presigned download_url.
curl -X POST http://localhost:8000/api/clips \
  -H "Content-Type: application/json" \
  -d '{"video_url": "https://www.youtube.com/watch?v=...", "start_time": "00:05", "end_time": "00:35"}'

πŸ“ Project Structure

clipsync/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ backend/
β”‚   β”‚   β”œβ”€β”€ Dockerfile                 # Python 3.11 + FFmpeg + face detector model
β”‚   β”‚   β”œβ”€β”€ requirements.txt
β”‚   β”‚   β”œβ”€β”€ tests/test_timecode.py     # Run with: python -m tests.test_timecode
β”‚   β”‚   └── src/
β”‚   β”‚       β”œβ”€β”€ api/
β”‚   β”‚       β”‚   β”œβ”€β”€ main.py            # FastAPI app + CORS
β”‚   β”‚       β”‚   └── routes/clips.py    # POST /api/clips, GET /api/clips/{job_id}
β”‚   β”‚       β”œβ”€β”€ core/
β”‚   β”‚       β”‚   β”œβ”€β”€ config.py          # Redis, MinIO and clip retention settings
β”‚   β”‚       β”‚   β”œβ”€β”€ storage.py         # S3 client, bucket setup + presigned URLs
β”‚   β”‚       β”‚   └── timecode.py        # MM:SS / HH:MM:SS parsing and validation
β”‚   β”‚       β”œβ”€β”€ services/
β”‚   β”‚       β”‚   └── video_processor.py # Download β†’ subtitles β†’ face crop β†’ render β†’ upload
β”‚   β”‚       └── worker/main.py         # Redis job consumer
β”‚   └── frontend/
β”‚       └── src/
β”‚           β”œβ”€β”€ App.jsx                # Form, job polling and download
β”‚           └── TimeInput.jsx          # MM:SS / HH:MM:SS time input
└── docker-compose.yaml                # api, worker, frontend, redis, minio

πŸš€ Getting Started

Requirements: Docker and Docker Compose.

  1. Clone the repository:

    git clone https://github.com/franra18/clipsync.git
    cd clipsync
  2. Start every service:

    docker compose up --build
  3. Open the services:

    Service URL
    Frontend http://localhost:5173
    API docs (Swagger) http://localhost:8000/docs
    MinIO console http://localhost:9001 (admin / password123)
    MinIO API http://localhost:9000
    Redis localhost:6379

    All ports are bound to 127.0.0.1, so the services are only reachable from your own machine.

    The API reloads on code changes, the worker does not: after editing the pipeline, run docker compose restart worker.

  4. Stop the stack:

    docker compose down

⚠️ The MinIO credentials in docker-compose.yaml are for local development only. Change them before deploying anywhere public.


Made by Francisco RamΓ­rez CaΓ±adas

About

🎬 Turn YouTube videos into vertical 9:16 Shorts with face-tracked framing and animated AI subtitles. FastAPI + Redis worker + OpenCV + Whisper + FFmpeg, React frontend, all in Docker.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages