---
title: "Read MP4 chapter markers in C#"
url: https://recursiveai.org/onemedia/cookbook/read-mp4-chapter-markers/
description: "Extract chapter titles and start timestamps from an MP4 file in C# with OneMedia. Includes a sample MP4 with two Nero chapter markers."
version: "1.0.2"
---

# Read MP4 chapter markers 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-mp4-chapter-markers/read-mp4-chapter-markers.zip)

MP4 files can store chapters in a Nero `chpl` list or in QuickTime chapter tracks. OneMedia reads only the Nero list, so it returns no chapters for files with only a QuickTime chapter track. Try `chapters.mp4` from the zip.

```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 var media = Media.Open("chapters.mp4");
foreach (var chapter in media.Metadata.Chapters)
    Console.WriteLine("{0:c}  {1}",
        chapter.Start.ToTimeSpan(),
        chapter.Title);
```

Prints each start time and title:

```text
00:00:00  Opening
00:00:01.2500000  Closing
```

Unzip [the example](https://recursiveai.org/onemedia/cookbook/read-mp4-chapter-markers/read-mp4-chapter-markers.zip), then `dotnet run`.

## The full program

The sample is a three-second solid-color clip with no audio and only a Nero chapter list. To open your own file, run `dotnet run -- "my video.mp4"`.

```csharp
using RecursiveAI.OneMedia;

string path = args.Length > 0 ? args[0] : "chapters.mp4";
using var media = Media.Open(path);
var chapters = media.Metadata.Chapters;
if (chapters.Count == 0)
{
    Console.WriteLine("No Nero chapter markers found.");
    return;
}

foreach (var chapter in chapters)
{
    var start = chapter.Start.ToTimeSpan();
    Console.WriteLine($"{start:c}  {chapter.Title}");
}
```

```text
00:00:00  Opening
00:00:01.2500000  Closing
```

If no supported list is found, `Chapters` is empty; the full program prints `No Nero chapter markers found.`

## Variations

**Print decimal seconds instead of a clock time.** In the full program’s loop, replace the two lines inside the braces with:

```csharp
var seconds = chapter.Start.ToTimeSpan().TotalSeconds;
Console.WriteLine(FormattableString.Invariant(
    $"{seconds:0.#######}\t{chapter.Title}"));
```

This prints `0` and `1.25` before the corresponding titles, separated by a tab.

## Related recipes

- [Read MP4 metadata tags in C#](https://recursiveai.org/onemedia/cookbook/read-mp4-metadata/)
- [List video tracks in C#](https://recursiveai.org/onemedia/cookbook/list-video-tracks/)
- [Trim an MP4 without re-encoding](https://recursiveai.org/onemedia/cookbook/trim-video-without-reencoding/)

## The short answer

Open the MP4 with `Media.Open` and enumerate `media.Metadata.Chapters`. Each entry gives you a `Title` and a `Start`. Convert `Start` to a `TimeSpan` to print it as elapsed time, or use the decimal-seconds variation above for a tab-separated list. The reader is for Nero chapter lists. An empty result means it found no readable Nero markers, not necessarily that a player will show no chapters.

## Does MP4 support chapter markers?

Yes. The [OneMedia metadata docs](https://recursiveai.org/onemedia/docs/tags/) describe two forms to distinguish: a Nero `chpl` list stores titles and start times together, while a QuickTime text chapter track is a separate track. OneMedia 1.0.2 reads the Nero form and does not read QuickTime text chapter tracks or Matroska `Chapters` elements. Changing the filename extension does not change how the markers are stored.

If a player lists chapters but this program prints none, check how the file was authored. A Nero list and a QuickTime chapter track can coexist; the sample in this recipe contains only the list. For an app that reads files from different sources, report “No Nero chapter markers found” rather than “This video has no chapters.” That distinguishes what the reader returned from what the file may contain.

## How do I extract chapter timestamps from an MP4?

Use `Start` as a position on the video timeline, not as the length of the chapter. Nero version 1 stores each start in 100-nanosecond units and each title as length-prefixed UTF-8. Here the second marker starts one and a quarter seconds into the clip. The `TimeSpan` `c` format prints `00:00:01.2500000`; the decimal variation prints the same position as `1.25` seconds. Both avoid rounding the start to a whole second.

`Chapter` has no end timestamp. A list of chapter starts is enough to build a menu or an index of jump points, but it is not a list of clip ranges. If you treat each chapter as running until the next marker, that is a boundary you infer. For the last chapter you would need a separate endpoint, such as the duration of the video you’re indexing. Keep the original start values rather than parsing back the strings you print for display.
