Skip to main content

🎬 Shorts Factory

Turn one long video into a batch of ready-to-post 9:16 viral shorts — locally, free, offline.

PyPI Python License: MIT

long video ──▶ transcribe ──▶ pick highlight moments ──▶ reframe to 9:16 ──▶ burn karaoke captions ──▶ short_01.mp4 … short_05.mp4 + report

Features

  • 🗣 Transcription — faster-whisper (offline, free) with word-level timestamps; cached to JSON so re-runs are instant.
  • 🎯 Highlight picking — heuristic virality scoring: question hooks, numbers, power words, speech pace, clean pause boundaries. Optionally an LLM re-ranks candidates and writes titles + hashtags (set OPENAI_API_KEY).
  • 📱 Smart 9:16 reframe — face detection (OpenCV) picks the speaker and zooms/crops to 1080×1920; falls back to center crop. Loudness normalized to −14 LUFS.
  • 🎨 Karaoke captions — CapCut-style bold uppercase captions with the active word highlighted, burned in via ffmpeg ASS.
  • 🖼 Auto thumbnails — per clip it samples candidate frames, scores them on sharpness/exposure/face presence (the same face detector the reframe uses) and stamps the hook title + hashtags onto a 1080×1920 JPEG (thumb_01.jpg …).
  • 📊 Report — report.json + report.md with time ranges, titles, hashtags, scores, transcripts.
  • 🌐 Input — local files or YouTube/URL links (via yt-dlp).

Install

Requirements: Python 3.11+, FFmpeg on PATH.

# from PyPI
pip install shorts-factory        # gives you the `shorts-factory` command

# …or from a source checkout (for development)
git clone https://github.com/taifbintofa-commits/shorts-factory
cd shorts-factory
pip install -e ".[dev]"

Usage

cd D:\Cline\shorts-factory
python -m shorts_factory ui

CLI

cd D:\Cline\shorts-factory

# 5 clips from a local file
python -m shorts_factory run "C:\Videos\podcast.mp4"

# from YouTube, 3 clips, better accuracy, custom output dir
python -m shorts_factory run "https://youtu.be/XXXX" --top 3 --model small -o D:\outputs

# options
python -m shorts_factory run --help

Useful flags: --top N, --model tiny|base|small|medium, --min-dur 12, --max-dur 45, --language en, --no-llm, --no-captions, --no-thumbnails, --thumbnail-font <ttf>, --font "Impact", --no-uppercase, --no-loudnorm.

Optional: GPT-powered picks & titles

$env:OPENAI_API_KEY = "sk-…"
python -m shorts_factory run video.mp4 --llm

Any OpenAI-compatible endpoint works via OPENAI_BASE_URL / SF_LLM_MODEL.

Output layout

shorts_output/<video name>/
├── short_01.mp4 … short_05.mp4   # 1080×1920, captions burned, loudness-normalized
├── thumb_01.jpg … thumb_05.jpg   # 1080×1920 cover frame with the hook title baked in
├── report.json / report.md       # titles, hashtags, time ranges, transcripts
├── cache/*.transcript.json       # reused on re-runs
└── work/clip_XX/subs.ass         # generated caption files

How highlight scoring works

Candidates are built from sentence-like transcript units (pauses > 0.7 s + punctuation), sized 12–45 s, then scored on: question openers, concrete numbers/$/%, power words, speaking pace (2.2–4.6 words/s), clean pause boundaries, ideal length. Overlapping picks are removed (non-max suppression). With OPENAI_API_KEY, a GPT pass re-ranks and writes click-worthy titles + hashtags.

Tests

python -m pytest                        # unit tests (captions, scoring, reframe, transcript, utils)
python tests\karaoke_probe.py           # verifies caption highlight colors against libass
python tests\make_test_video.py         # builds a ~90 s speech demo video (needs network)
python -m shorts_factory run tests\data\test_input.mp4 --top 2   # end-to-end smoke test

Limitations / roadmap

  • Single frontal speaker assumed for reframing (multi-speaker tracking = future work).
  • Heuristic highlight picks are good but not semantic — enable the LLM option for best results.
  • CPU transcription: base ≈ realtime, small more accurate but slower; GPU supported by faster-whisper config.
  • Ideas next: auto B-roll from transcript keywords, split-screen layout for gameplay footage, TikTok-style zoom punch-ins, direct upload.

License

MIT — see LICENSE.

Metadata

Release files for shorts-factory 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shorts-factory 0.1.1
File Size Uploaded
shorts_factory-0.1.1.tar.gz 35.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shorts-factory 0.1.1
File Interpreter ABI Platform
shorts_factory-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 65.7 kB

Release files / shorts_factory-0.1.1.tar.gz

Download URL shorts_factory-0.1.1.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
93ee5e7e81f5eb3ebcc2c515d352bb13e916b1885a1ed2748d3192c82c086abc
BLAKE2b-256 checksum
How to use checksums
262aa27fbde5e285ba2571cadcb6c359476ef3bdfef70d94a7b895c434426227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release files / shorts_factory-0.1.1-py3-none-any.whl

Download URL shorts_factory-0.1.1-py3-none-any.whl
Size 30.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a26af0ec878354ac58a1d9c2eb05118d12cea0ed5a790e7c76cc71203085894e
BLAKE2b-256 checksum
How to use checksums
7bdcb04182667b38ac5a2a1e521f0a3ed4ef3931eb565874bf4c58f8e4ddb893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page