chapters

Watch on youtube.com
doc

https://ffmpeg.org/ffmpeg-formats.html#Metadata-1

set chapters

To set chapters to your video, prepare FFMETADATA file like this:

;FFMETADATA1

[CHAPTER]
; TIMEBASE=1/1: start/end times are considered to be seconds.
TIMEBASE=1/1
START=0
END=30
; Metadata keys or values containing special characters
; ('=’, ';’, '#’, '\’ and a newline) must be escaped with a backslash '\'.
title=example \#1

[CHAPTER]
; TIMEBASE=1/1000: start/end times are considered to be milliseconds.
TIMEBASE=1/1000
START=30000
END=60000
title=example \#2

[CHAPTER]
TIMEBASE=1/1
START=60
END=90
title=example \#3

[CHAPTER]
TIMEBASE=1/1
START=90
END=120
title=example \#4

[CHAPTER]
TIMEBASE=1/1
START=120
END=150
title=example \#5

[CHAPTER]
TIMEBASE=1/1
START=150
END=180
title=example \#6

[CHAPTER]
TIMEBASE=1/1
START=180
END=210
title=example \#7

[CHAPTER]
TIMEBASE=1/1
START=210
END=240
title=example \#8

And then,

[me@host: Videos]$ ffmpeg -y -i input.mp4 -i chaps.txt -map_metadata 1 -c copy output.mp4

(In this example, the index of input.mp4 is 0, and of chaps.txt is 1, so you have to specify 1 to -map_metadata.)

Some players such as MPC-HC (Media Player Classic - Home Cinema) can deal with the chapters, and when you use MPC-HC, you can jump next chapter by PGUP, and previous by PGDN.

Chapters are embedded in the uploaded video. However, unfortunately, Youtube doesn’t seem to have a special interface for this. As such, it is up to the player to decide whether a chapter is useful. That is, chapters are not well suited for distribution videos. However, I personally think that it is particularly useful for editing tasks that involve combining multiple videos.

see also

ffaddmeta.py

remove all chapters

Editing a video containing chapters, such as cutting it with -to or -ss, may produce strange videos. Clearing all chapters is easy:

[me@host: Videos]$ ffmpeg -y -i input.mp4 -c copy -map_chapters -1 output.mp4