Skip to content
FramesField
Intermediate Light CLI / Copy-Paste Script
Verified Dec 1, 2026

Automated Speech-to-Text Subtitles, Karaoke Captions & Chapter Clips Pipeline

What you’ll make

A synced 38-character YouTube SRT file, a speaker-diarized chapter timestamp transcript, and a word-highlighted 9:16 ASS subtitle track ready for FFmpeg burn-in or Remotion.

Extract a timeline-locked 16 kHz mono WAV from any video or podcast, transcribe it via ElevenLabs Scribe v2 on fal.ai ($0.008/min, or $0.0104/min with custom brand keyterms and speaker diarization), and deterministically emit both 38-char YouTube SRT subtitles and 3-word active-highlight ASS captions positioned cleanly inside 9:16 Reels/Shorts safe zones.

Before you start
  • A finished constant-frame-rate (CFR) MP4 video or podcast audio track
  • A fal.ai API key (FAL_KEY) for ElevenLabs Scribe v2 ($0.008/min · $0.0104/min w/ keyterms)
  • Python 3 and FFmpeg 7.x installed locally (use ffmpeg-full on macOS for libass hard-burn)
Estimated cost
$0.08 per 10-min YouTube video · $0.48 per 60-min podcast ($0.62 w/ keyterms)
Time needed
15 min
Jump to section (2)
  1. 01Why Scribe v2 + deterministic word wrapping replaces paid clipping SaaS
  2. 02Step-by-step execution & burn-in commands
Step-by-step overview
SIGNAL PATH READY Click any node or press “Step Through” to trace data flow from input plate to final deliverable.
01–04
Aligned 16 kHz WAV → Scribe v2 Keyterms ($0.008/min) → 38-Char SRT & 9:16 Karaoke ASS
Official Demo · Privacy-Enhanced Player (Zero Cookies Until Click)

Aligned 16 kHz WAV → Scribe v2 Keyterms ($0.008/min) → 38-Char SRT & 9:16 Karaoke ASS

Remotion (Official Tutorial) · youtube-nocookie.com
Frame 01 EXTRACT · $0.00
Timeline-Zero 16k WAV
aresample=async=1:first_pts=0

Strips MP4 container edit-list offsets so caption timing stays tight even at minute 55.

Frame 02 ASR · $0.008/m
Scribe v2 + Keyterms
Word Start/End + Diarization

Pin /scribe-v2 (3.75× cheaper than v1) and lock brand names and acronyms via keyterms.

Frame 03 EXPORT · $0.00
SRT + 9:16 ASS Burn-In
<=38 Chars SRT · MarginV 500 ASS

Generates clean YouTube soft subtitles plus 3-word active-color Reels burn-in captions.

Word-level timestamps and speaker_id diarization from Scribe v2 eliminate manual caption syncing and drive both accessible YouTube SRTs and Reels word highlights.

Source: Remotion (Official Tutorial) Model: ELEVENLABS SCRIBE V2 STT + PYTHON WORD FORMATTER + FFMPEG Verified Dec 1, 2026
Original source ↗

Why Scribe v2 + deterministic word wrapping replaces paid clipping SaaS

Paying $30–$60/month for browser subtitle apps locks creators into proprietary templates, sluggish re-exports, and messy misspelled brand names. Calling ElevenLabs Scribe v2 directly on fal.ai ($0.008/min, or $0.0104/min with keyterms) returns exact word-level timestamps and speaker_id diarization in one JSON payload—giving you total control over both YouTube accessibility SRTs and active-color Reels captions for pennies per video.

Step-by-step execution & burn-in commands

1. Extract timeline-aligned audio & call Scribe v2

Always pull audio from your final locked constant-frame-rate (CFR) video so timestamps never drift near the end of long cuts:

# Extract aligned 16 kHz mono WAV
ffmpeg -y -i master_cfr.mp4 -vn -ac 1 -ar 16000 -af "aresample=async=1:first_pts=0" audio_16k.wav

# Call Scribe v2 on fal.ai (after uploading audio_16k.wav to a signed/public URL)
curl -sS -X POST "https://fal.run/fal-ai/elevenlabs/speech-to-text/scribe-v2" \
  -H "Authorization: Key ${FAL_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "audio_url": "https://cdn.example.com/audio_16k.wav",
    "diarize": true,
    "tag_audio_events": false,
    "keyterms": ["FramesField", "SeedVR2", "FASHN", "ComfyUI", "Remotion"]
  }' > scribe.json

2. Run the dual SRT + 9:16 ASS formatter

python3 scribe_v2_to_captions.py scribe.json youtube_subs.srt reels_karaoke.ass

Notice two built-in guardrails in scribe_v2_to_captions.py:

  • YouTube SRT: Splits cleanly whenever speaker_id switches, pause exceeds 0.65s, line length passes 38 characters, or duration exceeds 3.2s.
  • Reels / Shorts ASS: Groups words into punchy 3-word chunks, highlights the currently spoken word in signal vermilion (&H002044E0& in ASS BGR hex), and locks Alignment=2, MarginV=500 on 1080×1920 so bottom TikTok/Reels buttons and descriptions never cover your captions.

3. Soft-mux SRT (universal FFmpeg) or hard-burn ASS (ffmpeg-full / Linux)

# Option A: Soft-mux SRT into MP4 (works on EVERY FFmpeg build, toggleable captions)
ffmpeg -y -i master_cfr.mp4 -i youtube_subs.srt -c:v copy -c:a copy -c:s mov_text output_softsub.mp4

# Option B: Hard-burn 9:16 active-word ASS (requires FFmpeg built with libass)
ffmpeg -y -i vertical_916.mp4 -vf "ass=reels_karaoke.ass" \
  -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy -movflags +faststart vertical_captioned.mp4

On macOS, if default Homebrew ffmpeg lacks libass, see Fix: Missing libass & drawtext on macOS to install ffmpeg-full, or run our turnkey Skill 67: ElevenLabs Scribe v2 to SRT & ASS Captions Skill. If captions still drift or misspell proper nouns, check Fix AI Subtitles Out of Sync & Wrong Names.

Copy-paste template

ElevenLabs Scribe v2 Word JSON → Synced SRT & 9:16 Karaoke ASS Builder (Python) scribe_v2_to_captions.py
Reads ElevenLabs Scribe v2 JSON word timestamps and generates BOTH a 38-char speaker-aware YouTube .srt file AND a 3-word active-highlight 9:16 Reels .ass subtitle track.
cat <<'PY' > scribe_v2_to_captions.py
import json, sys

def srt_ts(sec: float) -> str:
    ms = max(0, int(round(sec * 1000)))
    h, ms = divmod(ms, 3600000); m, ms = divmod(ms, 60000); s, ms = divmod(ms, 1000)
    return f"{h:02d}:{m:02d}:{s:02d},{ms:03d}"

def ass_ts(sec: float) -> str:
    cs = max(0, int(round(sec * 100)))
    h, cs = divmod(cs, 360000); m, cs = divmod(cs, 6000); s, cs = divmod(cs, 100)
    return f"{h}:{m:02d}:{s:02d}.{cs:02d}"

if len(sys.argv) < 4:
    sys.exit("Usage: python3 scribe_v2_to_captions.py scribe.json out.srt out.ass")

data = json.load(open(sys.argv[1], "r", encoding="utf-8"))
words = [w for w in data.get("words", []) if w.get("type") == "word"]

# 1) Build YouTube 38-char speaker-aware SRT
srt_cues, buf = [], []
def flush_srt():
    if buf:
        srt_cues.append((buf[0]["start"], buf[-1]["end"], " ".join(x["text"] for x in buf)))
        buf.clear()

for w in words:
    if buf:
        spk_flip = w.get("speaker_id") != buf[-1].get("speaker_id")
        gap = w["start"] - buf[-1]["end"] > 0.65
        too_long = len(" ".join(x["text"] for x in buf)) + 1 + len(w["text"]) > 38
        too_slow = w["end"] - buf[0]["start"] > 3.2
        if spk_flip or gap or too_long or too_slow:
            flush_srt()
    buf.append(w)
flush_srt()

with open(sys.argv[2], "w", encoding="utf-8") as f:
    for i, (st, en, txt) in enumerate(srt_cues, 1):
        f.write(f"{i}\n{srt_ts(st)} --> {srt_ts(en)}\n{txt}\n\n")

# 2) Build 9:16 Reels 3-word active-highlight ASS (MarginV=500 safe zone)
chunks, cbuf = [], []
for w in words:
    if cbuf and (len(cbuf) >= 3 or w["start"] - cbuf[-1]["end"] > 0.55 or w.get("speaker_id") != cbuf[-1].get("speaker_id")):
        chunks.append(cbuf); cbuf = []
    cbuf.append(w)
if cbuf:
    chunks.append(cbuf)

ass_header = """[Script Info]
ScriptType: v4.00+
PlayResX: 1080
PlayResY: 1920
WrapStyle: 2

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Reels,Arial,74,&H00FFFFFF,&H002044E0,&H00111111,&H80000000,-1,0,0,0,100,100,0,0,1,6,2,2,80,80,500,1

[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
"""
ass_lines = [line.lstrip() + "\n" for line in ass_header.strip().splitlines()]
for ch in chunks:
    st, en = ch[0]["start"], ch[-1]["end"]
    for i, active in enumerate(ch):
        w_st = active["start"]
        w_en = ch[i + 1]["start"] if i + 1 < len(ch) else en
        parts = []
        for j, tok in enumerate(ch):
            txt = tok["text"].upper()
            parts.append(f"{{\\c&H002044E0&}}{txt}{{\\c&H00FFFFFF&}}" if j == i else txt)
        ass_lines.append(f"Dialogue: 0,{ass_ts(w_st)},{ass_ts(max(w_en, w_st + 0.05))},Reels,,0,0,0,,{' '.join(parts)}\n")

with open(sys.argv[3], "w", encoding="utf-8") as f:
    f.writelines(ass_lines)
print(f"Wrote {len(srt_cues)} SRT cues ({sys.argv[2]}) and {len(ass_lines) - 12} ASS lines ({sys.argv[3]})")
PY

Helpful prompts & skills for this workflow

Frequently Asked Questions

Why must I pin /scribe-v2 instead of calling fal-ai/elevenlabs/speech-to-text?
The root endpoint maps to legacy Scribe v1 at $0.03/minute. Pinning fal-ai/elevenlabs/speech-to-text/scribe-v2 lowers transcription cost by 3.75× to $0.008/minute and unlocks keyterms vocabulary boosting for brand names and acronyms.
Why did my macOS Homebrew FFmpeg throw an error on -vf ass=out.ass?
Default Homebrew ffmpeg omits libass and libfreetype. Install homebrew-ffmpeg/ffmpeg/ffmpeg-full (see our macOS libass fix playbook) for hard-burned ASS captions, or soft-mux out.srt directly using -c:s mov_text, which works in every standard FFmpeg build.
How do I use Scribe v2 speaker_id timestamps to cut podcast chapter clips automatically?
Because every word carries exact start/end floats and speaker_id, you can pass the grouped speaker transcript to an LLM to pick 30–55 second highlight timestamps, then slice master_cfr.mp4 via ffmpeg -ss <start> -to <end> and regenerate per-clip ASS offsets.
How much does it cost to transcribe and caption a 1-hour interview with custom brand terms?
At $0.0104/minute with keyterms enabled ($0.008 base + 30%), an entire 60-minute podcast costs $0.62—with word timestamps and speaker diarization included in the single pass.
Use this page in AI tools or notes
raw .md