How to Extract Closed Captions to SRT Using FFmpeg
Extracting embedded closed captions from a video file and converting
them to an editable SubRip (SRT) format is a straightforward process
using FFmpeg. This guide explains how to identify closed caption
streams—including EIA-608 and CEA-708 formats embedded in broadcast or
digital files—and execute the correct FFmpeg commands to decode and save
them directly as standalone .srt files.
Step 1: Identify the Caption Stream
Before extracting the captions, inspect the video file using
ffprobe to determine where the captions reside. Open your
terminal and run:
ffprobe -v error -show_entries stream=index,codec_name,codec_type -of default=noprint_wrappers=1 input.mp4Look for streams where codec_type=subtitle or entries
specifying eia_608, cea_708, or
mov_text. Note the stream index number (e.g.,
0:2 or 0:s:0).
Step 2: Extract Dedicated Subtitle Streams
If the captions are already recognized as a distinct subtitle stream, extract and convert them to SRT with this command:
ffmpeg -i input.mp4 -map 0:s:0 output.srt-i input.mp4: Specifies the input video file.-map 0:s:0: Selects the first subtitle stream found in the container. If your file has multiple subtitle tracks, replace0with the appropriate index (e.g.,0:s:1for the second track).output.srt: Instructs FFmpeg to decode the format and write it to the SRT text format.
Step 3: Extract Bitstream-Embedded Captions (CEA-608 / ATSC / DVD)
In many broadcast recordings (like MPEG-2, transport streams, or certain MP4/MKV files), closed captions are embedded directly inside the video stream user data rather than being stored in an independent track. Standard stream mapping may fail on these files.
To decode raw user-data captions, use FFmpeg's subcc
filter:
ffmpeg -f lavfi -i "movie=input.mp4[out0+subcc]" -map s output.srt-f lavfi: Invokes the Libavfilter virtual input device.movie=input.mp4[out0+subcc]: Reads the video file and splits out the closed caption bitstream (subcc).-map s: Directs the generated subtitle stream to the output.output.srt: Formats the extracted captions into an SRT file.
Step 4: Extracting Specific Caption Channels (CC1 - CC4)
CEA-608 captions often carry multiple language channels (such as CC1 for English and CC2 for Spanish) within a single data track. If your file contains multiple channels, specify the exact channel using the stream specifier:
ffmpeg -i input.ts -map 0:s:0 -c:s srt output_cc1.srtIf using the subcc filter, you can configure the channel
parameter directly:
ffmpeg -f lavfi -i "movie=input.mp4,subcc=channel=1[out0][out1]" -map "[out1]" output_cc1.srtReplace channel=1 with channel=2 through
4 depending on which language track you want to
isolate.