Turn raw screen recordings + narration text into polished narrated screencasts
Project description
screencast-narrator
Turn raw screen recordings + narration text into polished narrated screencasts.
screencast-narrator is a Python library and CLI that takes a browser screen recording together with a narration timeline and produces a final video with:
- Text-to-speech narration synced to on-screen actions
- QR-code-based frame-accurate synchronization
- Automatic freeze-frame insertion when narration overflows action duration
- Dead-air gap detection and cutting
- Interactive HTML timeline visualization
Installation
pip install screencast-narrator
For TTS support (Kokoro):
pip install screencast-narrator[tts]
System dependencies:
# macOS
brew install ffmpeg zbar
# Ubuntu/Debian
apt-get install ffmpeg libzbar0
# Windows
winget install GyanDev.FFmpeg
# The pyzbar Python package ships its own libzbar DLL but needs the Visual C++ 2013 runtime:
winget install Microsoft.VCRedist.2013.x64
Quick Start
As a library with Playwright
from pathlib import Path
from playwright.sync_api import sync_playwright
from screencast_narrator.storyboard import Storyboard
from screencast_narrator.sync_frames import inject_sync_frame
from screencast_narrator.merge import process
output_dir = Path("my-screencast")
storyboard = Storyboard(output_dir)
with sync_playwright() as p:
browser = p.chromium.launch()
context = browser.new_context(
record_video_dir=str(output_dir / "videos"),
record_video_size={"width": 1280, "height": 720},
)
page = context.new_page()
# Narration bracket with sync frames
nid = storyboard.begin_narration("We open the example website.")
inject_sync_frame(page, nid, "START")
storyboard.add_screen_action("Navigate to example.com")
page.goto("https://example.com")
inject_sync_frame(page, nid, "END")
storyboard.end_narration()
context.close()
browser.close()
# Produce the final narrated video
process(output_dir)
As a CLI
screencast-narrator /path/to/recording-output/
The directory must contain:
- A
storyboard.jsonfile (produced byStoryboardor hand-written) - A video file (
.webm) in avideos/subdirectory with sync frames embedded
API
The screencast-narrator API is JSON-based and language-agnostic. Any browser automation framework that can record video and execute JavaScript can produce the inputs.
See docs/api.md for:
- Timeline JSON schema
- Sync frame protocol specification
- Sample code in Python, Java, and TypeScript
- Pipeline processing details
Architecture
The pipeline has these stages:
-
Storyboard (
storyboard.py) — Declares narration text and screen actions. No timestamps — timing comes from sync frames. -
Sync frame injection (
sync_frames.py) — Inject green QR-code overlay frames into the browser at narration bracket boundaries for frame-accurate sync. -
TTS generation (
tts.py) — Convert narration text to speech audio files. Pluggable backend; ships with Kokoro TTS. -
Sync detection (
sync_detect.py) — Extract frames from the recorded video, detect green sync frames, decode QR codes to map video frames to narration events. -
Freeze frame calculation (
freeze_frames.py) — When narration audio is longer than the on-screen action, calculate where to insert freeze frames so audio and video stay in sync. -
Video merge (
merge.py) — Orchestrate FFmpeg to build the final video: strip sync frames, insert freeze frames, overlay audio, cut dead air gaps. -
Timeline visualization (
timeline_html.py) — Generate an interactive HTML timeline showing bracket positions, freeze frames, gap cuts, and audio durations.
Custom TTS Backend
Implement the TTSBackend protocol:
from screencast_narrator.tts import TTSBackend
from pathlib import Path
class MyTTS(TTSBackend):
def generate(self, text: str, output_path: Path) -> None:
# Generate audio file at output_path
...
# Use it
from screencast_narrator.merge import process
process(target_dir, tts_backend=MyTTS())
Development
git clone https://github.com/mmarinschek/screencast-narrator.git
cd screencast-narrator
pip install -e ".[dev,tts]"
# Run tests
pytest tests/ -v
# On macOS, if pyzbar can't find libzbar:
DYLD_LIBRARY_PATH=/opt/homebrew/lib pytest tests/ -v
License
Apache License 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file screencast_narrator-0.2.1.tar.gz.
File metadata
- Download URL: screencast_narrator-0.2.1.tar.gz
- Upload date:
- Size: 44.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6493ec6b7ab762485f0e9afc8007d14217201ba51520fced53b6f0913483dc6
|
|
| MD5 |
bde98ab12fa626b30cc274b5e3177318
|
|
| BLAKE2b-256 |
59f0550a7f06a2fcfacb82f4bb9811626180646c5257d6a9cc88cea0db8951f7
|
Provenance
The following attestation bundles were made for screencast_narrator-0.2.1.tar.gz:
Publisher:
publish.yml on mmarinschek/screencast-narrator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
screencast_narrator-0.2.1.tar.gz -
Subject digest:
c6493ec6b7ab762485f0e9afc8007d14217201ba51520fced53b6f0913483dc6 - Sigstore transparency entry: 1059438931
- Sigstore integration time:
-
Permalink:
mmarinschek/screencast-narrator@fdc8621c87b59bcda93205a3d3e7ccf51e3a70ff -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mmarinschek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fdc8621c87b59bcda93205a3d3e7ccf51e3a70ff -
Trigger Event:
push
-
Statement type:
File details
Details for the file screencast_narrator-0.2.1-py3-none-any.whl.
File metadata
- Download URL: screencast_narrator-0.2.1-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cf148a3edac6a1da8335d7b82982d12b4f60c2cf35834b04ca5ecfe22f60c5e
|
|
| MD5 |
42a0286ffe408ceea595743c95512542
|
|
| BLAKE2b-256 |
5971abc3dc342c995af779f7be1d27b456ad30735925fd3588b00d153fb7af33
|
Provenance
The following attestation bundles were made for screencast_narrator-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on mmarinschek/screencast-narrator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
screencast_narrator-0.2.1-py3-none-any.whl -
Subject digest:
9cf148a3edac6a1da8335d7b82982d12b4f60c2cf35834b04ca5ecfe22f60c5e - Sigstore transparency entry: 1059438937
- Sigstore integration time:
-
Permalink:
mmarinschek/screencast-narrator@fdc8621c87b59bcda93205a3d3e7ccf51e3a70ff -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/mmarinschek
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fdc8621c87b59bcda93205a3d3e7ccf51e3a70ff -
Trigger Event:
push
-
Statement type: