Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Add Chapters To MKV File

Chapters allow you to skip to key points in a video. This is particularly useful if you are watching a recording of a meeting/conference and want to skip the introductions etc. This tutorial will show you how to easily add chapters to a MKV file using the mkvmerge tool on Ubuntu 16.04.

Steps

Firstly, install the mkvmerge command by installing the mkvtoolnix package.

sudo apt-get install mkvtoolnix -y

Now use your text editor of choice to create a simple text file using the "simple chapter format" as shown below (self-explanatory):

CHAPTER01=00:00:00.000
CHAPTER01NAME=Intro
CHAPTER02=00:02:30.000
CHAPTER02NAME=Baby prepares to rock
CHAPTER03=00:02:42.300
CHAPTER03NAME=Baby rocks the house

Now use mkvmerge to add that to your mkv file (this will remove any existing chapters in the file).

mkvmerge \
  --chapters chapters.txt \
  -o output.mkv \
  input-file.mkv

Wait for the processing to complete (shou'dn't take long), and now you will be able to use your video-player's buttons to skip between chapters.

MPV player helpfully shows the chapter names on screen when you do this:

References

Last updated: 6th May 2019
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch