Editing Chapter Markers in .mkv files

This entry was published at least two years ago (originally posted on November 13, 2019). Since that time the information may have become outdated or my beliefs may have changed (in general, assume a more open and liberal current viewpoint). A fuller disclaimer is available.

A gorgeous, fully restored Monty Python’s Flying Circus Norwegian Blu-ray Edition box set has just been released, and while I can definitely say that it looks great, others have reviewed it far more comprehensively than I’m able to do, and if you’re into the technical details, there’s some fascinating information about the restoration process in this article.

However, there is one small thing about the set that is a little unfortunate: Each episode only has three chapter stops.

Since I’m in the habit of ripping all of my DVDs and Blu-rays for storage and playback through my Plex media server, I decided to see if there was something I could do about that. Turns out there is! Here’s a rundown of the process, in case anyone else is curious (or if I need to remind myself how to do it for future projects).

  1. Rip the disc using MakeMKV to individual .mkv files for each episode (and while you’re doing so, you might want to pay attention to the subtitles as well.

  2. For each episode, open the .mkv file with the MKVToolNix GUI. Go to the “Chapter Editor” tab, and (at least in this case) remove the existing chapters.

  3. At the same time, open the .mkv file with a video player that allows for frame-by-frame scanning and that can display timecodes down to the millisecond (I use Aegisub).

  4. In MKVToolnix, use the “Add Chapter” button to create the first chapter; you’ll see it appear in the “Chapters:” list. Click on the chapter to enable editing. Set the start time to “00:00:00.000”. Optionally (but recommended), set the “Name” for the chapter: This could be as simple as “Chapter 1”, or a more descriptive chapter name (in this particular case, the highly detailed books of notes that came with the Monty Python set came in very handy for identifying the chapters and titles).

  5. Scan through the video file with your video player until you find the end point of the opening chapter/beginning point of the next chapter. Read the timecode from the video player, and use that to set the “End:” time in MKVToolnix (for example, “00:00:30.831” is zero hours, zero minutes, 30.831 seconds into the video).

  6. Click the “Add chapter” button to add the next chapter, and set its start time to the same timecode as the end time of the prior chapter.

  7. Continue on until all chapters have been defined.

  8. Once all chapters are defined, in MKVToolnix’s “Chapter Editor” window, choose “Save to Matroska file”. Select the .mkv file you’re working with, and click “Save”. Don’t worry if you get a warning that the file will be replaced, MKVToolnix will only replace the chapter markers, and will not wipe out the rest of the file.

Once that’s done, the .mkv file will have correct chapter markers set. If you then do any further encoding (such as converting from .mkv to .mp4 with Handbrake, which I do for my video storage to save space), those chapter markers will be preserve. This makes skipping around and finding particular points in the video (in this particular case, going directly to specific sketches within each episode) much easier.

It’s the one downside to an otherwise incredible set, and while this solution isn’t exactly simple or fast, neither is it terribly difficult or time consuming, and makes for a much better final experience.

Bonus: If others are ripping their Python box sets and would prefer not to go through the trouble of finding the chapter stops themselves, here’s a 73KB .zip file with .xml files for (nearly*) every episode’s chapter stops as I defined them. These files should be importable into MKVToolnix, replacing steps four through seven above (and saving you a lot of time).

* At present, I’m missing files for episodes 12 and 13 of Series 1, as I seem to have gotten a bad pressing of disc 2 of that set. I’ll add those two episodes and remove this qualifier once I’ve received a replacement disc.