Extract Closed Captions to SRT Using FFmpeg

Extracting embedded closed captions (such as EIA-608/708 or teletext) from a video file into a standalone SRT subtitle file is a common task in video post-production and archiving. This guide provides a straightforward, step-by-step process using the command-line tool FFmpeg to identify, decode, and export raw closed caption data into the widely compatible SubRip (SRT) format.

Step 1: Identify the Caption Stream

Before extracting, you need to inspect the video file to locate the subtitle or closed caption stream. Run the following command in your terminal:

ffmpeg -i input.mp4

Look through the output for streams labeled Subtitle. You will see lines similar to:

  • Stream #0:2: Subtitle: mov_text ...
  • Stream #0:2: Subtitle: eia_608 ...

Note the stream index (e.g., 0:2 or 0:s:0 for the first subtitle stream).

Step 2: Extract Standard Subtitle Streams

If FFmpeg detects the closed captions as a distinct subtitle stream, you can extract and convert them directly to an SRT file using the -map flag:

ffmpeg -i input.mp4 -map 0:s:0 output.srt
  • -i input.mp4: Specifies the input video file.
  • -map 0:s:0: Selects the very first subtitle stream (index 0) of the input file.
  • output.srt: The destination file where the converted captions will be saved.

If there are multiple subtitle tracks and you want to extract the second one, change the map parameter to -map 0:s:1.

Step 3: Extract Embedded EIA-608/708 Captions

In many broadcast files (like MXF, TS, or certain MP4s), closed captions are embedded directly inside the video stream data rather than as a separate, easily readable subtitle track. To extract these, use FFmpeg's lavfi (libavfilter) tool to decode and isolate the CC data:

ffmpeg -f lavfi -i "movie=input.mp4[out0+sub1]" -map 1 output.srt
  • -f lavfi: Forces the use of the libavfilter input virtual device.
  • movie=input.mp4[out0+sub1]: Instructs FFmpeg to read the video file and split it into a video stream (out0) and an embedded subtitle stream (sub1).
  • -map 1: Maps the extracted subtitle stream (sub1) to the output.
  • output.srt: The final SRT output file.