How to add chapters to a video with FFMPEG on Windows 10
Videos you play from a DVD and/or BluRay disc have chapters but chapters aren’t specific to videos played from these storage devices. You can add chapters to any video that you want. There are a few tools that allow you to add chapters to a video but we recommend using FFMPEG since it’s free and reliable. Using it to add chapters to a video is a bit complicated but we’re going to simplify it as much as possible.
You can also use ffmpeg to create GIFs.
Create metadata file
The tricky part is creating the metadata file which will define the chapters in the video. In this file, you need to mention the time in the video where a chapter begins or ends. This time is expressed in nanoseconds.
Open the video and decide how many chapters you want to add to it. Figure out the time in the video where the chapter should start and end, and convert it to nanoseconds. You can use Google to convert the time. The time value in nanoseconds is going to be a big number so you want to note it down in a file.
Open a new Notepad file and paste the following in it. You will need to extensively edit it to add chapters to your video.
;FFMETADATA1 title=MyVideo [CHAPTER] TIMEBASE=1/1000 START=0 #chapter ends at 00:30 END=30000 title=Chapter 1 [STREAM] title=MyVideo
This will add one chapter to the video however if you need to add more chapters, simply copy and paste the following into the same notepad file. You will of course need to edit it and change the value for when the chapter starts and ends.
[CHAPTER] TIMEBASE=1/1000 START=0 #chapter ends at 00:30 END=30000 title=Chapter 1
Edit metadata file
Anything in the file that is preceded by the # sign is a comment however, you shouldn’t remove it and you should update it for each chapter so that it’s easier to manage.
Edit the START value for each chapter and replace it with the time, in nanoseconds, when the chapter should start. Edit the value for END and replace it with the time, in nanoseconds, when the chapter should end.
Last, edit the title value and enter whatever name you want to give the chapter. The chapter names will show up in whichever app you use to play the video.
Once you’ve made all the edits, save the file with the name “metadata.”. Make sure you add the full stop at the end of the file. It will not have any sort of file extension.
Add Chapters to video
Download and extract ffmpeg. To keep things simple, move the video that you want to add chapters to and the metadata. file you just created to the bin folder inside the extracted ffmpeg folder.
Open Command Prompt and use the CD command to move to bin folder in the extracted ffmpeg folder. Alternatively, you can open the bin folder in File Explorer and type cmd in the location bar, and tap enter.
Run the following command but replace ‘MyVideo.mp4’ with the name of the video that you want to add chapters too. Change the file extension if you need to. Replace ‘MyVideo_1.mp4’ with the name of the output file. This command will create a copy of the video and the name you give at the end is what the new file will be named. Tap Enter.
ffmpeg -i MyVideo.mp4 -i metadata -map_metadata 1 MyVideo_1.mp4
Depending on the size of the file, the process will take a while.
Viewing Chapters
You can view chapters once they’ve been added in media players that support it. VLC player is a good option since it’s so feature rich. Open the video in VLC player and go to Playback>Chapters.
Taken From Toca Blocks The Movie
It should be edited that is not necessary to give the time in “nanoseconds”, but rather in milliseconds (ms) which is more logical anyway. 1 second = 1 000 ms.
There are some tools online btw, which can translate h:m:s timestamps (like youtube) to seconds. For milliseconds just add three zeros at each end, e.g. by ‘Search+Replace’.
Furthermore, it is worth noting that the comment (#), the end (END=) and the title (title=) line are not mandatory to produce a satisfying result.