Ffmpeg Captions
Context: $ARGUMENTS
CEA-608/708 closed captions are carried inside the H.264 video stream (A53 SEI NAL units) or in sidecar SCC/MCC/STL files. They are NOT subtitle tracks. For subtitle-file workflows (SRT/ASS/VTT), use the ffmpeg-subtitles skill.
Quick start
- Preserve captions during H.264 re-encode: → Step 3,
-a53cc 1recipe - Check whether a file has embedded 608/708: → Step 1, detect
- Extract embedded CC to SRT: → Step 3,
ccextractorrecipe - Remux without losing captions: → Step 3, passthrough recipe
- Burn captions into the picture: → Step 3, extract then hand off to
ffmpeg-subtitles
When to use
- Source is MPEG-TS, MP4, MOV, or MXF with embedded 608/708 (broadcast, ATSC, FCC-compliant deliverables).
- You have a sidecar
.scc,.mcc, or.stland need to mux or convert it. - You are re-encoding H.264 and must not lose the SEI caption data.
- You need a plain
.srtfrom 608/708 for downstream tools.
Step 1 — Identify caption location
Captions can live in one of five places. Check all of them:
- Embedded SEI A53_CC in H.264 video (MPEG-TS, MP4, MOV, MXF) — invisible to
ffprobe -show_streams. - Dedicated c608/c708 track in MOV/MP4 — appears in
ffprobeascodec_name=eia_608orclosed_caption. - SCC sidecar file (
.scc) — timecoded hex byte pairs, NTSC drop-frame usually. - MCC sidecar file (
.mcc) — MacCaption, SCC's modern descendant with explicit frame-rate header. - STL sidecar file (
.stl) — EBU 3264, European broadcast. - Open (burned-in) captions in the picture on NTSC line 21 — read via
readeia608filter.
To detect embedded SEI captions:
ffprobe -loglevel error -select_streams v:0 -show_entries frame=side_data_list \
-of default=noprint_wrappers=1 in.ts | grep -i a53 | head -5
If nothing is returned, try the filter path (picture line 21):
ffmpeg -hide_banner -i in.mov -vf "readeia608,metadata=mode=print" -an -f null - 2>&1 | head -40
Or hand off to the external detector:
ccextractor in.mov --stdout > /dev/null # exits nonzero if no CC found
Step 2 — Pick the operation
| Goal | Operation | Command |
| --- | --- | --- |
| Keep captions when transcoding H.264 | preserve | -a53cc 1 on libx264 |
| Keep captions when remuxing (no re-encode) | passthrough | -c copy |
| Get a .srt from embedded 608/708 | extract | ccextractor |
| Get a .srt from .scc / .mcc | convert | ccextractor |
| Burn captions into the picture | burn | extract to SRT, then ffmpeg-subtitles |
| Import SCC as a subtitle stream into TS | mux | -f scc -i ... -c:s copy |
Step 3 — Run the command
Preserve embedded 608 during H.264 re-encode
ffmpeg -i in.ts -c:v libx264 -crf 20 -a53cc 1 -c:a copy out.ts
Without -a53cc 1, libx264 silently discards SEI CC data. This flag only preserves what the source already has — it does not create captions.
Passthrough remux (fastest, lossless)
ffmpeg -i in.ts -c copy -map 0 out.mp4
Copying the video stream preserves the A53 SEI NAL units automatically. MPEG-TS → MP4 and MP4 → MOV generally survive; verify with Step 4.
Extract 608/708 to SRT via ccextractor
ccextractor in.ts -o out.srt
ccextractor in.mov -out=srt -o out.srt # explicit
ccextractor in.ts -o out.vtt -out=webvtt # VTT instead
ccextractor in.mcc -o out.srt # MCC → SRT
ccextractor in.scc -o out.srt # SCC → SRT
Install on macOS: brew install ccextractor. On Debian/Ubuntu: apt install ccextractor.
readeia608 filter (open captions on line 21 of NTSC)
ffmpeg -i in.mov -vf "readeia608,metadata=mode=print:file=captions.txt" \
-an -f null -
This only works when 608 bytes are drawn into the picture on lines 0–1 (legacy NTSC line 21). It does NOT read SEI-embedded CC. Output is frame-level metadata (lavfi.readeia608.0.cc, .sub, etc.) which you then parse into SRT yourself.
Import SCC sidecar as a subtitle stream
ffmpeg -i video.mp4 -f scc -i captions.scc \
-c:v copy -c:a copy -c:s copy -map 0:v -map 0:a -map 1 out.mp4
SCC demuxer support depends on ffmpeg build; verify with ffmpeg -formats | grep -i scc. If missing, fall back to ccextractor round-trip: SCC → SRT → mux as soft subtitle (see ffmpeg-subtitles).
Burn broadcast captions into the picture
Two-step: extract to SRT, then hand off.
ccextractor in.ts -o captions.srt
# now use the ffmpeg-subtitles skill:
ffmpeg -i in.ts -vf "subtitles=captions.srt" -c:a copy out.mp4
Step 4 — Verify captions survived
# 1. Probe for A53 side data on first video frames
ffprobe -loglevel error -select_streams v:0 \
-show_entries frame=side_data_list -read_intervals "%+#20" out.ts \
| grep -i a53
# 2. Decode and re-read via readeia608 (after on-screen render)
ffmpeg -i out.ts -vf "readeia608,metadata=mode=print" -an -f null - 2>&1 \
| grep -i 'lavfi.readeia608' | head
# 3. External sanity check
ccextractor out.ts -o /tmp/verify.srt && wc -l /tmp/verify.srt
If all three return empty, captions were dropped.
Available scripts
scripts/cc.py— detect / preserve / extract / passthrough helper around ffmpeg + ccextractor. Subcommands:detect,preserve,extract,passthrough.--dry-run,--verbose.
uv run ${CLAUDE_SKILL_DIR}/scripts/cc.py detect --input in.ts
uv run ${CLAUDE_SKILL_DIR}/scripts/cc.py preserve --input in.ts --output out.ts --crf 20
uv run ${CLAUDE_SKILL_DIR}/scripts/cc.py extract --input in.ts --output captions.srt
uv run ${CLAUDE_SKILL_DIR}/scripts/cc.py passthrough --input in.ts --output out.mp4