mkv2cast.pipeline

Pipeline orchestrator for parallel processing in mkv2cast.

Manages multiple integrity check and encode workers processing files in parallel.

Functions

auto_detect_workers()

Auto-detect optimal number of workers based on system resources.

integrity_check_with_progress(path, ui, ...)

Perform integrity check with Rich UI progress updates.

register_process(proc)

Register a process for tracking.

run_ffmpeg_with_progress(cmd, ui, worker_id, ...)

Run ffmpeg command while updating Rich UI progress.

terminate_all_processes()

Terminate all active processes.

unregister_process(proc)

Unregister a process from tracking.

Classes

EncodeJob(inp, decision, log_path, final, ...)

Job data passed from integrity worker to encode worker.

PipelineOrchestrator(targets, backend, ui, ...)

Orchestrates parallel integrity check and encoding with multiple workers.

class mkv2cast.pipeline.EncodeJob(inp: Path, decision: Decision, log_path: Path, final: Path, tmp: Path, dur_ms: int, stage: str, integrity_time: float)[source]

Bases: object

Job data passed from integrity worker to encode worker.

inp: Path
decision: Decision
log_path: Path
final: Path
tmp: Path
dur_ms: int
stage: str
integrity_time: float
mkv2cast.pipeline.register_process(proc: Popen) None[source]

Register a process for tracking.

mkv2cast.pipeline.unregister_process(proc: Popen) None[source]

Unregister a process from tracking.

mkv2cast.pipeline.terminate_all_processes() None[source]

Terminate all active processes.

mkv2cast.pipeline.integrity_check_with_progress(path: Path, ui: RichProgressUI, worker_id: int, filename: str, log_path: Path | None = None, stop_event: Event | None = None, cfg: Config | None = None) Tuple[bool, float][source]

Perform integrity check with Rich UI progress updates.

Returns (success, elapsed_seconds).

mkv2cast.pipeline.run_ffmpeg_with_progress(cmd: List[str], ui: RichProgressUI, worker_id: int, stage: str, filename: str, dur_ms: int, log_path: Path | None, inp: Path, stop_event: Event | None = None) int[source]

Run ffmpeg command while updating Rich UI progress.

Returns the process return code.

class mkv2cast.pipeline.PipelineOrchestrator(targets: List[Path], backend: str, ui: RichProgressUI, cfg: Config, encode_workers: int, integrity_workers: int, get_log_path: Callable[[Path], Path], get_tmp_path: Callable[[Path, int, str], Path], output_exists_fn: Callable[[Path, Config], bool], history: HistoryRecorder | None = None)[source]

Bases: object

Orchestrates parallel integrity check and encoding with multiple workers.

integrity_queue: Queue[Path | None]
encode_queue: Queue[EncodeJob | None]
integrity_worker(worker_id: int)[source]

Worker that performs integrity checks and prepares encode jobs.

encode_worker(worker_id: int)[source]

Worker that performs encoding.

run() Tuple[int, int, int, bool][source]

Run the pipeline. Returns (ok, skipped, failed, interrupted).

mkv2cast.pipeline.auto_detect_workers() Tuple[int, int][source]

Auto-detect optimal number of workers based on system resources.