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.
Functions¶
- 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.
- Parameters:
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) –
- Returns:
Full path to output file suitable for writing.
- Return type:
AnyStr
- 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.bar -> foo
- Parameters:
file_path (AnyStr) –
- Return type:
AnyStr
- 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.
- Parameters:
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.
- scenedetect.platform.invoke_command(args)¶
Same as calling Python’s subprocess.call() method, but explicitly raises a different exception when the command length is too long.
See https://github.com/Breakthrough/PySceneDetect/issues/164 for details.
- Parameters:
args (List[str]) – List of strings to pass to subprocess.call().
- Returns:
Return code of command.
- Raises:
CommandTooLong – args exceeds built in command line length limit on Windows.
- Return type:
int
Exceptions¶
- exception scenedetect.platform.CommandTooLong¶
Raised if the length of a command line argument exceeds the limit allowed on Windows.