Extract Video Chapters to Text with FFmpeg
Extracting chapter information from a video file is an efficient way to manage media metadata, document video structures, or prepare assets for editing. This guide provides a straightforward, step-by-step walkthrough on how to use the command-line tool FFmpeg to extract embedded chapters from a video file (such as MP4, MKV, or MOV) and save them directly into a standardized metadata text file.
Step 1: The Extraction Command
To extract chapters and other metadata from a video file, you need to use FFmpeg’s metadata muxer. Open your command line interface (Terminal on macOS/Linux or Command Prompt/PowerShell on Windows) and run the following command:
ffmpeg -i input.mp4 -f ffmetadata metadata.txtStep 2: Understanding the Command Arguments
-i input.mp4: Specifies the path to your source video file. Replaceinput.mp4with the actual name and extension of your video file.-f ffmetadata: Tells FFmpeg to use the internal metadata format for the output.metadata.txt: The name of the output text file where the metadata and chapter information will be saved. You can change this to any filename you prefer.
Step 3: Analyzing the Output File
Once the command finishes executing, a new text file named
metadata.txt will appear in your working directory. When
you open this file in a text editor, you will see global metadata at the
top, followed by specific blocks for each chapter.
The chapter blocks will look similar to this:
[CHAPTER]
TIMEBASE=1/1000
START=0
END=30000
title=Introduction
[CHAPTER]
TIMEBASE=1/1000
START=30000
END=120000
title=Chapter 1: Getting Started
Key Chapter Metadata Fields
TIMEBASE: The time unit used for the start and end times (e.g.,1/1000means the times are in milliseconds).START: The beginning of the chapter, expressed in the units defined by the timebase.END: The end of the chapter, expressed in the units defined by the timebase.title: The actual name of the chapter as embedded in the video.
This generated text file can now be edited, stored as a backup, or imported into another video file using FFmpeg.