Copy Video Chapters with FFmpeg

This article explains how to preserve and copy chapter markers from an input video to an output video using FFmpeg. You will learn the specific command-line flags required to transfer chapter metadata, whether you are transcoding the video, copying the streams directly, or merging chapters from a separate file.

The Default Behavior

By default, FFmpeg attempts to copy global metadata, including chapters, from the first input file to the output file. However, to guarantee that chapters are successfully transferred—especially when working with complex commands, multiple inputs, or specific container formats—you should explicitly use the -map_chapters flag.

Copying Chapters in a Standard Pass-Through

If you are copying the video and audio streams without re-encoding (stream copying) and want to ensure the chapters are preserved, use the following command:

ffmpeg -i input.mp4 -map_metadata 0 -map_chapters 0 -c copy output.mp4

Command Breakdown:


Copying Chapters During Transcoding

If you are re-encoding the video (for example, compressing it or changing the format), the exact same mapping flags apply. Simply replace the stream copy argument with your encoding parameters:

ffmpeg -i input.mp4 -map_metadata 0 -map_chapters 0 -c:v libx264 -crf 23 -c:a aac output.mp4

In this case, FFmpeg transcodes the video to H.264 and the audio to AAC, while precisely mapping the original chapter timestamps and titles to the new file.


Copying Chapters from One File to a Different Video File

If you have a source file that contains chapter markers (source_with_chapters.mp4) and you want to inject those chapters into a different video file (target_video.mp4), you can map them from different inputs:

ffmpeg -i source_with_chapters.mp4 -i target_video.mp4 -map 1 -map_chapters 0 -c copy output.mp4

Command Breakdown: