mkv2cast.integrity
File integrity checking for mkv2cast.
Verifies source files before processing to avoid corrupted outputs. Includes: - File size stability check (for files being downloaded/copied) - Basic ffprobe validation - Optional deep decode verification
Functions
|
Perform deep decode verification by decoding the entire video stream. |
|
Check if file is valid using ffprobe. |
|
Check if file size is stable (not being written to). |
|
Get file size in bytes, returns 0 on error. |
|
Perform complete integrity check on a file. |
|
Run a command quietly, return True if successful. |
- mkv2cast.integrity.run_quiet(cmd: list, timeout: float = 10.0) bool[source]
Run a command quietly, return True if successful.
- mkv2cast.integrity.check_file_stable(path: Path, wait_seconds: int = 3) bool[source]
Check if file size is stable (not being written to).
- Parameters:
path – Path to the file.
wait_seconds – Number of seconds to wait between checks.
- Returns:
True if file size is stable, False otherwise.
- mkv2cast.integrity.check_ffprobe_valid(path: Path, timeout: float = 8.0) bool[source]
Check if file is valid using ffprobe.
- Parameters:
path – Path to the file.
timeout – Timeout in seconds.
- Returns:
True if ffprobe reports valid duration.
- mkv2cast.integrity.check_deep_decode(path: Path, log_path: Path | None = None, progress_callback: Callable[[int, str], None] | None = None, dur_ms: int = 0) bool[source]
Perform deep decode verification by decoding the entire video stream.
This is slow but catches files that are truncated or have decode errors.
- Parameters:
path – Path to the file.
log_path – Optional path to write logs.
progress_callback – Optional callback(pct, speed) for progress updates.
dur_ms – Duration in milliseconds for progress calculation.
- Returns:
True if decode succeeds, False otherwise.
- mkv2cast.integrity.integrity_check(path: Path, enabled: bool = True, stable_wait: int = 3, deep_check: bool = False, log_path: Path | None = None, progress_callback: Callable[[str, int, str], None] | None = None) Tuple[bool, float][source]
Perform complete integrity check on a file.
- Parameters:
path – Path to the file to check.
enabled – If False, skip all checks and return True.
stable_wait – Seconds to wait for file size stability.
deep_check – If True, perform full decode verification.
log_path – Optional path to write logs.
progress_callback – Optional callback(stage, pct, message) for UI updates.
- Returns:
Tuple of (success, elapsed_seconds).