---
title: "Extract teletext subtitles from MPEG-TS in C#"
url: https://recursiveai.org/onemedia/cookbook/read-teletext-subtitles-from-mpeg-ts/
description: "Extract DVB teletext subtitles from an MPEG-TS file in C# with OneMedia. Read the text by page number and save a selected page as SRT."
version: "1.0.2"
---

# Extract teletext subtitles from MPEG-TS in C#

**OneMedia** is a free, open-source media library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OneMedia) · [GitHub](https://github.com/recursive-ai-oss/onemedia-csharp) · [Docs](https://recursiveai.org/onemedia/docs/) · [Download example (.zip)](https://recursiveai.org/onemedia/cookbook/read-teletext-subtitles-from-mpeg-ts/read-teletext-subtitles-from-mpeg-ts.zip)

Read caption text without decoding the video. The zip’s `sample.ts` carries Italian teletext on page 777, starting with “città” and “sera.”

```shell
dotnet add package RecursiveAI.OneMedia
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
using RecursiveAI.OneMedia;
using RecursiveAI.OneMedia.Captions.Teletext;

using var media = Media.Open("sample.ts");
var tracks = TeletextExtractor.ReadAll(
    media.Demuxer!);
foreach (var track in tracks)
foreach (var page in track.Subtitles)
{
    var label = $"Page {page.Page} ({page.Language})";
    Console.WriteLine(label);
    foreach (var cue in page.Document.Cues)
        Console.WriteLine(cue.Text);
}
```

Unzip [the example](https://recursiveai.org/onemedia/cookbook/read-teletext-subtitles-from-mpeg-ts/read-teletext-subtitles-from-mpeg-ts.zip), then `dotnet run`.

Prints the page, language and caption text:

```text
Page 777 (ita)
città
sera
citéà
sera
циттш
сера
```

The sample deliberately switches character sets, which is why the same caption appears as “citéà” and then “циттш.”

## Full program

`sample.ts` is a generated stream, not a recording. Its Italian language tag stays the same while the sample switches character sets. To try a recording, replace `sample.ts` with an MPEG-TS file containing DVB teletext.

```csharp
using RecursiveAI.OneMedia;
using RecursiveAI.OneMedia.Captions.Teletext;

using var media = Media.Open("sample.ts");
var tracks = TeletextExtractor.ReadAll(media.Demuxer!);
if (tracks.Count == 0)
    Console.WriteLine("No teletext subtitle pages found.");
foreach (var track in tracks)
foreach (var page in track.Subtitles)
{
    Console.WriteLine($"Page {page.Page} ({page.Language})");
    foreach (var cue in page.Document.Cues)
        Console.WriteLine(cue.Text);
}
```

`dotnet run` prints:

```text
Page 777 (ita)
città
sera
citéà
sera
циттш
сера
```

If the extractor finds no subtitle pages, this program prints `No teletext subtitle pages found.`

## Variations

### Save page 777 as SRT

Replace everything after `Media.Open` with this. The filename includes the track index so two tracks carrying the same page don’t overwrite each other.

```csharp
var options = new TeletextOptions
{
    Pages = [new(7, 0x77)]
};
var tracks = TeletextExtractor.ReadAll(
    media.Demuxer!, options);
foreach (var track in tracks)
foreach (var page in track.Subtitles)
{
    var index = track.TrackIndex;
    string path = $"teletext-{index}-{page.Page}.srt";
    Subtitles.Write(page.Document, path);
    Console.WriteLine(path);
}
```

Prints `teletext-0-777.srt`. Choose a new output name before rerunning; `Subtitles.Write` won’t overwrite an existing file. The file starts with:

```srt
1
00:00:01,000 --> 00:00:03,000
città
<font color="#ffff00">sera</font>
```

## Related recipes

[Read MPEG-TS programs and PIDs](https://recursiveai.org/onemedia/cookbook/read-mpeg-ts-info/) · [Extract closed captions](https://recursiveai.org/onemedia/cookbook/extract-closed-captions/) · [Convert SRT to WebVTT](https://recursiveai.org/onemedia/cookbook/convert-srt-to-webvtt/)

---

## The short answer

Open the MPEG-TS file and pass its demuxer (the reader that separates its tracks) to `TeletextExtractor.ReadAll`. Each result groups the subtitle pages on one teletext track. Read `page.Document.Cues` for text and timing, or pass that document to `Subtitles.Write` to save it as SRT. OneMedia reads DVB teletext but does not write teletext back into the transport stream.

## How do I extract subtitles from a .ts file?

Start by identifying the type of subtitles in the recording. DVB teletext carries characters and page controls. DVB bitmap subtitles carry images, and subtitles burned into the video are part of the picture. The teletext extractor handles the first case only. For a transport stream, OneMedia looks for a teletext descriptor in the program map table, which tells the reader which streams and services a program carries.

Use a fresh demuxer for caption extraction. `ReadAll` reads forward from the starting position and disables other tracks on that reader. Don’t first consume the packets to look for video and then expect to extract all the subtitles from the same position. Use this extractor rather than `MediaFile.Subtitles`: the latter doesn’t list teletext pages at this version. An empty result is not proof the file has no captions of any kind.

## How do I select the right teletext subtitle page?

With no options, the extractor selects pages marked as subtitles in the page header or announced as subtitle pages by the transport stream. Look at the page number and advertised language in the results before choosing. To restrict the read, set `TeletextOptions.Pages`, as in the SRT variation: the first digit is the magazine number, and the other two are hexadecimal digits. Page 777 is magazine `7` and page number `0x77`. If you don’t know the page and it wasn’t marked as a subtitle, `AllPages` can include ordinary teletext pages too.

A cue normally starts at the page’s transmission time and ends at the next transmission of that page. An empty transmission clears the previous text. Live subtitles sometimes repeat an expanding line as each word arrives; by default, OneMedia joins those updates into one cue with the completed text. If you need each update as it was transmitted, set `TeletextOptions.Progressive` to `true`.

SRT carries the text and cue times, not the full teletext page. Inspect `page.Report` when character mapping or visual fidelity matters. The [teletext documentation](https://recursiveai.org/onemedia/docs/teletext/) lists what the cue model can’t represent, including mosaics and flashing text. Some characters have no mapping; for instance, Arabic letters can appear as the Unicode replacement character `�`.
