Platform & Logging

scenedetect.platform Module

This moduke contains all platform/library specific compatibility fixes, as well as some utility functions to handle logging and invoking external commands.


scenedetect.platform.get_and_create_path(file_path, output_directory=None)

Get & Create Path: Gets and returns the full/absolute path to file_path in the specified output_directory if set, creating any required directories along the way.

If file_path is already an absolute path, then output_directory is ignored.

  • file_path (AnyStr) – File name to get path for. If file_path is an absolute path (e.g. starts at a drive/root), no modification of the path is performed, only ensuring that all output directories are created.

  • output_dir – An optional output directory to override the directory of file_path if it is relative to the working directory.

  • output_directory (AnyStr | None) –


Full path to output file suitable for writing.

Return type:


scenedetect.platform.get_file_name(file_path, include_extension=True)

Return the file name that file_path refers to, optionally removing the extension.

If include_extension is False, the result will always be a str.

E.g. /tmp/ -> foo


file_path (AnyStr) –

Return type:


scenedetect.platform.init_logger(log_level=20, show_stdout=False, log_file=None)

Initializes logging for PySceneDetect. The logger instance used is named ‘pyscenedetect’. By default the logger has no handlers to suppress output. All existing log handlers are replaced every time this function is invoked.

  • log_level (int) – Verbosity of log messages. Should be one of [logging.INFO, logging.DEBUG, logging.WARNING, logging.ERROR, logging.CRITICAL].

  • show_stdout (bool) – If True, add handler to show log messages on stdout (default: False).

  • log_file (str | None) – If set, add handler to dump log messages to given file path.


Same as calling Python’s method, but explicitly raises a different exception when the command length is too long.

See for details.


args (List[str]) – List of strings to pass to


Return code of command.


CommandTooLongargs exceeds built in command line length limit on Windows.

Return type:



exception scenedetect.platform.CommandTooLong

Raised if the length of a command line argument exceeds the limit allowed on Windows.