CLI

April 11, 2025 ยท View on GitHub

This will be removed from chaptertool at some point. Migrate to ffmpeg/pyscenedetect+chapconv!

Prerequisite

You need to install node and optionally ffmpeg on your system:

Windows: modern terminal, package manager, node, ffmpeg macOS: package manager, node, ffmpeg linux: node, ffmpeg

create chapters from video

npx chaptertool@latest generate YOUR_FILE.mp4

Wait for the process to finish, afterwards a new folder called YOUR_FILE_chapters should be present. It contains the screenshots from the video and a chapters.json-file that contains the automatically generated chapters.

commands

npx chaptertool@latest <command> <input?> --option-a --option-b=value

serve

Run the http-server that hosts the web ui.

optiondescriptiondefault
--portport for the http-server8989

generate

Generate raw chapters from video using ffmpeg.

optiondescriptiondefault
<input>the video file that you want to process
--ywhen set ffmpeg will always overwrite existing output
--nwhen set ffmpeg will never overwrite existing output
--output-formatoutput format for the chapters, see belowchaptersjson
--output-folderimage destination folder, $filename will be replaced with the input video filename minus the extension$filename_chapters
--chapter-templatetemplate string for the chapter names.Chapter $chapter of $total
--scene-valuemin value for ffmpeg's scene detection. If you only use a small portion of the screen, the value should be smaller. See the crop option0.1
--scalewhen given, images will be scaled to given width while keeping original aspect ratio
--force-darwhen used, the display aspect ratio will be used for generated images. Useful for some videos. overwrites --scale
--cropwhen set, it will apply the crop filter on the input to the given coordinates. General syntax is w:h:x:y
--use-crossfade-fixwhen set, a special filter setup will be used to handle crossfade situations
--crossfade-framesassuming your input video has a framerate of ~30fps and your average cross-fade transition is 2 seconds long, the amount of frame should be at least FPS * CROSSFADE_DURATION * 2120
--silentsuppress output
--img-uriuri to prepend to the images in the json
--prettypretty-print the output, if supported
--keep-infowhen set, info.txt will not be deleted
--configpoint to a yaml file that may contain all options for a enhanced re/usability, see below
--dump-ffmpegecho the generated ffmpeg-command to stdout
--ffmpeg-binarypath to the ffmpeg binary, optionalffmpeg
--ffprobe-binarypath to the ffprobe binary, optionalffprobe
--extract-audioextract the audio from video file
--audio-filenamefilename for the audio file. $filename will be replaced with input filename, same as --output-folder. Extension controls the output format$filename.mp3
--audio-optionsoptions for the ffmpeg command that extracts the audio-q:a 0 -map a
--audio-copy-streamcopy audio stream from video. Correct output file extension will be set automatically. --audio-options will be overwritten internally
--audio-onlycreate no chapters and images
--input-chapterspath to a chapters.json file. See below
--dump-optionsdump final options object, for debugging only
--min-chapter-lengthminimum chapter length. New chapters below that threshold are ignored10
--no-end-timeswhen set, no endTime-attributes are written on chapters.json

convert

Converts existing chapters between any of the supported formats:

optiondescriptiondefault
<input>the file that you want to convert, format will be detected
--output-formattarget format, one of those listed above. When omitted, detected input format is used
--prettysome formats support pretty printing
--img-urisee above, works only with chaptersjson
--output-filefile to write the output to. see below
--psd-omit-timecodesWhen set, first line of PySceneDetect-CSV will not be written
--psd-framerateset the framerate for PySceneDetect output
--ac-use-text-attruse the text-attribute for Apple Chapters

use --output-file when using powershell, otherwise you'll have BOMs in your output

config yaml and .env

Use any option (except input) listed above in a config file passed via --configto create reusable configurations:

# my-config.yaml
- --crop=616:410:554:46
- --silent

Additionally you can create an .env file in any directory and put in options like this:

# prefix with CT_, option name uppercase and replace all dashes with underscore
CT_CROP="616:410:554:46"
CT_SILENT=true
CT_DUMP_FFMEG=true

You can combine config with regular cli options. Evaluation occurs in this order:

  1. build-in default value
  2. .env values
  3. config yaml (if present) value
  4. explicit cli value