Extract Specific Teletext Subtitle Page Using FFmpeg
Extracting teletext subtitles from video streams is a common task, but media files often contain multiple teletext pages corresponding to different languages or services. This article provides a quick, step-by-step guide on how to use FFmpeg to target and extract a specific teletext page number, converting it into a standard subtitle format like SRT.
1. Identify the Teletext Stream
Before extracting, you need to find the stream index of the teletext
data. Use ffprobe to inspect your input file:
ffprobe input.tsLook for a stream labeled subtitles with the codec
dvb_teletext or teletext. Note its index
(e.g., 0:s:0 or 0:3).
2. The Extraction Command
To select a specific teletext page, use the -txt_page
option. This option tells the FFmpeg teletext decoder which page number
to parse (page 888 is the most common page for default
subtitles in many regions).
Run the following command to extract the subtitles:
ffmpeg -txt_page 888 -i input.ts output.srtCommand Breakdown:
-txt_page 888: Specifies the teletext page number you want to extract (replace888with your desired page, such as777or150). This must be placed before the input file if you are treating it as an input decoder option.-i input.ts: The path to your input video file containing the teletext stream.output.srt: The desired output file name and format (typically.srtor.vtt).
3. Handling Multiple Subtitle Streams
If your file contains multiple subtitle streams and FFmpeg is not
selecting the correct one automatically, use the -map
option to specify the exact stream index you identified with
ffprobe:
ffmpeg -txt_page 888 -i input.ts -map 0:s:0 output.srtIn this command, -map 0:s:0 explicitly tells FFmpeg to
use the first subtitle stream of the first input file.