How naufalrizqullah/opensource-clipping works
1. The repository has two main surfaces: a batch video-processing pipeline driven from the CLI, and a web control plane built from the FastAPI backend plus React dashboard. The CLI path does the heavy media work; the web path mainly manages jobs, settings, and file access.
2. The core pipeline lives in clipping/ and is orchestrated by main.py → clipping.runner. config.py parses the large CLI surface, runner.py coordinates the stages, and engine.py handles the “analysis” side of the workflow. This is the backbone for turning one source URL into one or more finished clips.
3. Source ingestion and analysis form the first data plane. The pipeline can pull from YouTube, TikTok, Instagram, or Google Drive, then transcribe with Faster-Whisper, optionally reuse built-in subtitles, and send transcript/context to an LLM provider. engine.py, metadata.py, and hook_manager.py are the main pieces involved in extracting moments, normalizing metadata, and selecting hook material.
4. AI selection is separated from rendering. Gemini is the default analysis provider, with NVIDIA NIM as an alternative. The AI layer decides clip ranks, titles, descriptions, tags, hook candidates, and segment trimming decisions; the render layer consumes those decisions rather than re-analyzing content.
5. clipping/studio/ is the media-rendering subsystem. It contains the FFmpeg-driven composition logic for subtitles, typography, transitions, effects, B-roll, BGM, thumbnail generation, and layout modes. The modular files here show that rendering is composed from specialized renderers rather than one monolith.
6. Face tracking and podcast layouts are a major rendering boundary. face_detection.py, render_split_screen.py, render_camera_switch.py, and render_hybrid.py handle vertical framing, split-screen podcasts, and active-speaker switching. These modes depend on face detection and, for audio-driven speaker logic, diarization.py plus HuggingFace/Pyannote.
7. Story Clip mode is its own mini-pipeline under clipping/story/. loader.py, source_manager.py, and assembler.py suggest a multi-source narrative workflow where a recipe and multiple assets are assembled into a single story sequence. This is distinct from the normal “one source URL, many highlights” clip pipeline.
8. Outputs are file-based and job-scoped. The README indicates each run produces an outputs/ folder with final MP4s, thumbnails, render manifests, and metadata previews. That makes the pipeline effectively a file-producing batch job, with intermediate artifacts likely used for retries and post-processing.
9. The YouTube uploader is a separate executable boundary. run_upload.py and youtube_uploader/uploader.py consume the rendered outputs and scheduling metadata to publish clips to YouTube. This is intentionally decoupled from rendering so uploads can be run later or independently.
10. The web backend is a job-management layer around the same media pipeline. web/api/app.py, routes/jobs.py, routes/files.py, and routes/settings.py expose job submission, status, artifact access, and configuration. store.py implies persistent job/state storage, while worker.py suggests an asynchronous background executor for running clipping jobs.
11. The dashboard is a separate frontend client for that API. web/dashboard/ is a Vite/React app that calls the API through src/api.js and presents job creation, job detail, and settings pages. It is not the processing engine; it is the operator UI for the web layer.
12. External dependencies materially shape the architecture. FFmpeg is a hard runtime dependency for rendering, Faster-Whisper requires GPU-friendly compute for transcription, Gemini/NVIDIA NIM are used for semantic clip selection, Pexels/Pixabay provide optional media assets, and HuggingFace tokens enable diarization-based podcast modes.
13. Deployment is container-friendly but still batch-oriented. The repo includes a Dockerfile, docker-compose, env sample, and a Colab notebook, which indicates the project is designed to run as a reproducible media batch system across local GPU, container, and notebook environments.
14. Architecturally, the key boundary is: analysis → render → publish. The analysis stage creates structured decisions, the render stage converts them into media assets, and the upload/web layers consume those assets for distribution and management. An architecture diagram should keep those as separate boxes with file-based handoff between them.
Main entry points: runner.py Runner · studio.py Studio · engine.py Engine · story_runner.py Story runner
Components 30
CLI pipeline
Batch clip generation and rendering pipeline driven from the command line.
- CLI entry · Starts the batch clipping workflow.
main.py - Config · Parses the large command-line surface and run options.
clipping/config.py - Runner · Coordinates the end-to-end clip job pipeline.
clipping/runner.py - Engine · Runs source ingestion, transcription, analysis, and moment selection.
clipping/engine.py - Metadata · Builds and normalizes clip metadata and output descriptors.
clipping/metadata.py - Hook manager · Selects and manages hook material and attention-grabbing segments.
clipping/hook_manager.py - Studio · FFmpeg-driven media rendering and composition layer.
clipping/studio.py - Face tracking · Detects faces for framing and speaker-aware layouts.
clipping/studio/face_detection.py - Split screen · Renders split-screen podcast and multi-camera compositions.
clipping/studio/render_split_screen.py - Camera switch · Performs active-speaker switching and dynamic framing.
clipping/studio/render_camera_switch.py - Hybrid render · Combines speaker, face, and layout logic for mixed formats.
clipping/studio/render_hybrid.py - Story clip · Multi-source story workflow for assembling narrative clips.
clipping/story/assembler.py - Story loader · Loads story assets and source definitions.
clipping/story/loader.py - Source manager · Coordinates multiple sources for story assembly.
clipping/story/source_manager.py - Story runner · Runs the story-specific pipeline from recipe to output.
clipping/story_runner.py
Web control plane
FastAPI backend and React dashboard for job management and file access.
- API app · FastAPI application that exposes job and file APIs.
web/api/app.py - Jobs API · Submits jobs and reports job status.
web/api/routes/jobs.py - Files API · Serves rendered artifacts and job files.
web/api/routes/files.py - Settings API · Exposes configuration and runtime settings.
web/api/routes/settings.py - Store · Persists job state and backend data.
web/api/store.py - Worker · Runs clipping jobs asynchronously in the web backend.
web/api/worker.py - Dashboard · React/Vite operator UI for jobs, details, and settings.
web/dashboard/src/App.jsx - API client · Frontend client for calling the FastAPI backend.
web/dashboard/src/api.js
Publishing
Decoupled upload boundary for distributing rendered clips.
- YouTube upload · Consumes rendered outputs and scheduling metadata to publish clips.
run_upload.py - Uploader · Implements the YouTube upload flow.
youtube_uploader/uploader.py
External systems
Third-party runtimes, model providers, and asset sources used by the pipeline.
- FFmpeg · Media encoding and composition runtime.
- Faster-Whisper · Speech transcription engine for source media.
- Gemini/NIM · Semantic analysis provider for clip selection and copy generation.
- Pyannote · Speaker segmentation for podcast and active-speaker modes.
clipping/diarization.py - Media sources · YouTube, TikTok, Instagram, Drive, and optional stock asset providers.
Connections 30
- CLI entry → Config: parse args · Command-line options are parsed before the job starts.
- CLI entry → Runner: start job · Entry point hands control to the pipeline orchestrator.
- Runner → Engine: analyze · Runner invokes analysis and ingestion stages.
- Runner → Metadata: build metadata · Runner collects normalized clip metadata.
- Runner → Hook manager: select hooks · Runner requests hook material and segment choices.
- Engine → Media sources: ingest source · Engine pulls media from supported source systems.
- Engine → Faster-Whisper: transcribe · Speech is converted to transcript text for analysis.
- Engine → Gemini/NIM: rank clips · Transcript and context are sent to an AI provider for clip decisions.
- Engine → Pyannote: speaker map · Podcast modes use diarization for speaker-aware analysis.
- Runner → Studio: render · Structured analysis results are handed to the render subsystem.
- Studio → FFmpeg: encode · Rendering is executed through FFmpeg-based composition.
- Studio → Face tracking: track faces · Layout modes use face detection for framing.
- Studio → Split screen: compose mode · Split-screen podcast layouts are rendered here.
- Studio → Camera switch: compose mode · Active-speaker switching layouts are rendered here.
- Studio → Hybrid render: compose mode · Hybrid render mode combines multiple layout strategies.
- Runner → Story runner: story mode · Story clip jobs follow a dedicated entry path.
- Story runner → Story loader: load recipe · Story runner loads narrative sources and assets.
- Story runner → Source manager: plan sources · Story runner coordinates multiple source inputs.
- Story runner → Story clip: assemble · Assets are assembled into a story sequence.
- Runner → YouTube upload: publish handoff · Rendered outputs can be passed to the uploader boundary.
- YouTube upload → Uploader: upload clip · Upload executable delegates to the YouTube uploader implementation.
- API app → Jobs API: route · Job submission and status endpoints are mounted on the API.
- API app → Files API: route · Artifact access endpoints are mounted on the API.
- API app → Settings API: route · Settings endpoints are mounted on the API.
- Jobs API → Worker: enqueue · Submitted jobs are handed to the background worker.
- Worker → Runner: run pipeline · The web backend executes the same clipping pipeline asynchronously.
- Jobs API → Store: persist state · Job records and status updates are stored persistently.
- Files API → Store: read artifacts · File views resolve outputs and job artifacts from backend storage.
- Dashboard → API client: call api · Frontend pages use a shared API client.
- API client → API app: http · Dashboard communicates with the FastAPI backend.