Configuration File

A configuration file path can be specified using the -c/--config argument. PySceneDetect also looks for a config file named scenedetect.cfg in one of the following locations:

  • Windows:
    • C:/Users/%USERNAME%/AppData/Local/PySceneDetect/scenedetect.cfg

  • Linux:
    • ~/.config/PySceneDetect/scenedetect.cfg

    • $XDG_CONFIG_HOME/scenedetect.cfg

  • Mac:
    • ~/Library/Preferences/PySceneDetect/scenedetect.cfg

Run scenedetect help to see the exact path on your system which will be used. Values set on the command line take precedence over those set in the config file.

Most command line parameters can be set using a configuration file. See the Template below for an example scenedetect.cfg file containing every possible option, along with comments that describe each one. Note that lines starting with a # are comments and will be ignored.

The syntax of a configuration file is:

[command]
option_a = value
#comment
option_b = 1

Example

[global]
min-scene-len = 0.8s

[detect-content]
threshold = 26

[split-video]
# Use higher quality encoding
preset = slow
rate-factor = 17
filename = $VIDEO_NAME-Clip-$SCENE_NUMBER

[save-images]
format = jpeg
quality = 80
num-images = 3

Template

This template shows every possible configuration option and default values. It can be used as a scenedetect.cfg file. You can also download it from Github.

#
# This file contains every possible PySceneDetect config option.
#
# A config file path can be specified via the -c/--config option, or
# creating a `scenedetect.cfg` file the following location:
#
#   Windows: C:/Users/%USERNAME%/AppData/Local/PySceneDetect/scenedetect.cfg
#
#   Linux:   ~/.config/PySceneDetect/scenedetect.cfg
#            $XDG_CONFIG_HOME/scenedetect.cfg
#
#   Mac:     ~/Library/Preferences/PySceneDetect/scenedetect.cfg
#
# Run `scenedetect help` to see the exact path on your system which will be
# used (it will be listed under the help text for the -c/--config option).
#


#
# GLOBAL OPTIONS
#

[global]
# Output directory for written files. If unset, defaults to working directory.
#output = /usr/tmp/scenedetect/

# Video backend interface, must be one of: opencv, pyav.
#backend = opencv

# Downscale frame using sub-sampling ratio of N. Set to 1 for no downscaling.
# If unset, applied automatically based on input video resolution.
#downscale = 1

# Minimum length of a given scene (shorter scenes will be merged).
#min-scene-len = 0.6s

# Merge last scene if it is shorter than min-scene-len (yes/no)
#merge-last-scene = no

# Drop scenes shorter than min-scene-len instead of merging (yes/no)
#drop-short-scenes = no

# Verbosity of console output (debug, info, warning, error, or none).
# Set to none for the same behavior as specifying -q/--quiet.
#verbosity = debug

# Amount of frames to skip between performing scene detection. Not recommended.
#frame-skip = 0


#
# DETECTOR OPTIONS
#

[detect-content]
# Sensitivity threshold from 0 to 255. Lower values are more sensitive.
#threshold = 27

# Discard colour information and only use luminance (yes/no).
#luma-only = no

# Minimum length of a given scene (overrides [global] option).
#min-scene-len = 0.6s


[detect-threshold]
# Average pixel intensity from 0-255 at which a fade event is triggered.
#threshold = 12

# Percent from -100.0 to 100.0 of timecode skew for where cuts should be placed.
# -100 indicates start frame, +100 indicates end frame, and 0 is the center.
#fade-bias 0

# Generate a scene from the end of the last fade out to the end of the video.
#add-last-scene = yes

# Discard colour information and only use luminance (yes/no).
#luma-only = no

# Minimum length of a given scene (overrides [global] option).
#min-scene-len = 0.6s


[detect-adaptive]
# Frame score threshold, refers to the `adaptive_ratio` metric in stats file.
#threshold = 27

# Minimum threshold that `content_val` metric from detect-content must exceed.
#min-delta-hsv = 15

# Window size (number of frames) before and after each frame to average together.
#frame-window = 2

# Discard colour information and only use luminance (yes/no).
#luma-only = no

# Minimum length of a given scene (overrides [global] option).
#min-scene-len = 0.6s


#
# COMMAND OPTIONS
#

[split-video]
# Folder to output videos. Overrides [global] output option.
#output = /usr/tmp/encoded

# Filename template to use as output.
#filename = $VIDEO_NAME-Scene-$SCENE_NUMBER

# Suppress output from split tool.
#quiet = no

# Use higher bitrate for better output quality (y/n), equivalent to setting
# rate-factor = 17 and preset = slow.
#high-quality = no

# Use codec copying instead of encoding. Significantly faster, but can result
# in inaccurate splits due to keyframe positioning.
#copy = no

# Use mkvmerge for copying instead of encoding. Has the same drawbacks as copy = yes.
#mkvmerge = no

# x264 rate-factor, higher indicates lower quality / smaller filesize.
# 0 = lossless, 17 = visually identical, 22 = default.
#rate-factor = 22

# One of the ffmpeg x264 presets (e.g. veryfast, fast, medium, slow, slower).
#preset = veryfast

# Arguments to specify to ffmpeg for encoding. Quotes are not required.
#args = -c:v libx264 -preset veryfast -crf 22 -c:a aac


[save-images]
# Folder to output videos. Overrides [global] output option.
#output = /usr/tmp/images

# Filename format of created images. Can use $VIDEO_NAME, $SCENE_NUMBER,
# and $IMAGE_NUMBER in the name. Extension not required.
#filename = $VIDEO_NAME-Scene-$SCENE_NUMBER-$IMAGE_NUMBER

# Number of images to generate for each scene.
#num-images = 3

# Image format (jpeg, png, webp).
#format = jpeg

# Image quality (jpeg/webp). Default is 95 for jpeg, 100 for webp
#quality = 95

# Compression amount for png images (0 to 9). Does not affect quality.
#compression = 3

# Number of frames to skip at beginning/end of scene.
#frame-margin = 1

# Amount to scale images by (0.5 = half, 1.0 = same, 2.0 = double).
#scale = 1.0

# Override image height/width.
#height = 0
#width = 0


[export-html]
# Filename format of created HTML file. Can use $VIDEO_NAME in the name.
#filename = $VIDEO_NAME-Scenes.html

# Override <img> element width/height.
#image-height = 0
#image-width = 0

# Do not generate <img> elements in resulting table (yes/no).
#no-images = no


[list-scenes]
# Folder to output scene list. Overrides [global] output option.
#output = /usr/tmp/images

# Filename format of created scene list. Can use $VIDEO_NAME in the name.
#filename = $VIDEO_NAME-Scenes.csv

# Skip the cutting list as the first row in the CSV file (yes/no).
# Set this option if compliance with RFC 4810 is required.
#skip-cuts = no

# Output only to command-line, don't write file (yes/no).
#no-output-file = no

# Suppress printing of scene list.
#quiet = no


#
# BACKEND OPTIONS
#

[backend-opencv]
# Number of times to keep reading frames after one fails to decode.
# If set to 0, processing will stop on the first decode failure.
#max-decode-attempts = 5


[backend-pyav]
# Threading mode to use: [none, slice, frame, auto]. Slice mode is the
# PyAV default, and auto/frame are the fastest.
#threading-mode = auto

# Suppress ffmpeg log output. Default is `no`.
#
# WARNING: When threading-mode is set to auto/frame, setting
# `suppress-output = yes` can cause the the program to not exit properly
# on Linux/OSX (press Ctrl+C to quit if this occurs).
#suppress-output = no