Found a way to do it myself, so I'll post it here to help future readers. This is not done using only javascript and rely on third part tools that you should find online. If someone has a better answer I'll be glad to read it!
You should find a tool that is able to extract the chapters from videos that works as standalone from the console. Then you can start the standalone as a child process and get the output. I used ffprobe in my test.
Example code
const child_process = require("child_process");
var output = child_process.execSync("./tools/ffprobe -show_chapters path_to_video.mp4");
var string = Utf8ArrayToStr(output);
Here i downloaded a standalone of the ffprobe program and put it in the tools folder inside my project directory. Then i start that program as a child process and get the output. The output is in utf8 array, so i had to convert it. A function to translate utf8 array to string can be found in this stack overflow question. After that, you should just parse the output as your program requires.