Platform & Logging¶
scenedetect.platform
Module
This module contains all platform/library specific compatibility fixes, as well as some utility functions to handle logging and invoking external commands.
- exception scenedetect.platform.CommandTooLong¶
Raised if the length of a command line argument exceeds the limit allowed on Windows.
- class scenedetect.platform.FakeTqdmLoggingRedirect(**kawrgs)¶
Provides a no-op tqdm context manager for redirecting log messages.
No-op.
- class scenedetect.platform.FakeTqdmObject(**kawrgs)¶
Provides a no-op tqdm-like object.
No-op.
- close()¶
No-op.
- set_description(desc=None, refresh=True)¶
No-op.
- update(n=1)¶
No-op.
- class scenedetect.platform.Template(template)¶
Template matcher used to replace instances of $TEMPLATES in filenames.
- 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_cv2_imwrite_params()¶
Get OpenCV imwrite Params: Returns a dict of supported image formats and their associated quality/compression parameter index, or None if that format is not supported.
- Returns:
Dictionary of supported image formats/extensions (‘jpg’, ‘png’, etc…) mapped to the respective OpenCV quality or compression parameter as {‘jpg’: cv2.IMWRITE_JPEG_QUALITY, ‘png’: cv2.IMWRITE_PNG_COMPRESSION, …}. Parameter will be None if not found on the current system library (e.g. {‘jpg’: None}).
- Return type:
Dict[str, int | None]
- scenedetect.platform.get_ffmpeg_path()¶
Get path to ffmpeg if available on the current system. First looks at PATH, then checks if one is available from the imageio_ffmpeg package. Returns None if ffmpeg couldn’t be found.
- Return type:
str | None
- scenedetect.platform.get_ffmpeg_version()¶
Get ffmpeg version identifier, or None if ffmpeg is not found. Uses get_ffmpeg_path().
- Return type:
str | None
- 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.get_mkvmerge_version()¶
Get mkvmerge version identifier, or None if mkvmerge is not found in PATH.
- Return type:
str | None
- scenedetect.platform.get_system_version_info()¶
Get the system’s operating system, Python, packages, and external tool versions. Useful for debugging or filing bug reports.
Used for the scenedetect version -a command.
- Return type:
str
- 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 debug 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