Skip to content

Python API reference

The Python API is synchronous and currently marked beta. Prefer explicit keyword arguments and inspect nonzero results.

BatchEvent

One privacy-redacted JSON Lines event emitted by a batch run.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

BatchItemOutcome

Stable per-item result, including resumed and cancelled jobs.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

BatchJob

One stable job identity paired with an immutable typed plan.

BatchManifest

Strict versioned profile-job manifest compiled through the typed planner.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

BatchPolicy

Explicit concurrency, retry, input-size, and timeout limits.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

BatchRun

Versioned ordered outcome for one bounded batch execution.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

BatchRunner

Execute validated jobs concurrently with receipts, events, retry, and resume.

run(self, jobs: 'Iterable[BatchJob]', *, policy: 'BatchPolicy | None' = None, cancellation: 'threading.Event | None' = None, event_callback: 'Callable[[BatchEvent], None] | None' = None, state_path: 'str | Path | None' = None, resume: 'bool' = False, receipt_dir: 'str | Path | None' = None, hash_content: 'bool' = False) -> 'BatchRun'

Run jobs once, retry transient failures, and persist successful signatures atomically.

CapabilityUnavailableError

The installed FFmpeg build cannot satisfy the requested workflow.

CapabilityInventory

Versioned inventory of an installed FFmpeg executable.

missing(self, requirements: 'tuple[str, ...]') -> 'tuple[str, ...]'

No public docstring is available.

supports(self, requirement: 'str') -> 'bool'

Check a normalized kind:name requirement.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

CapturePolicy

Python 3.10-compatible string enumeration.

CompressOptions

CompressOptions(target_size_bytes: 'int | None' = None, crf: 'int' = 23, two_pass: 'bool' = True, video_codec: 'str' = 'libx264', audio_codec: 'str' = 'aac', video_bitrate: 'str | None' = None, audio_bitrate: 'str' = '128k', preset: 'str' = 'medium', pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None, container_overhead_percent: 'float' = 5.0, minimum_video_bitrate: 'int' = 102400)

ConvertOptions

ConvertOptions(video_codec: 'str | None' = None, audio_codec: 'str | None' = None, video_bitrate: 'str | None' = None, audio_bitrate: 'str | None' = None, pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None, audio_only: 'bool' = False, hardware_acceleration: 'str | None' = None, preserve_all_streams: 'bool' = False)

EnvironmentUnavailableError

A required executable or host resource is unavailable.

ExecutionPlan

Deterministic, non-shell execution plan for one media workflow.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

ExecutionPolicy

Explicit process, overwrite, capture, and cleanup behavior.

ExecutionStep

One named argument-vector step inside a multi-pass plan.

FFmpegRunner

Execute typed workflows or an explicit non-shell argument vector.

adjust_speed(self, input_file: 'str', output_file: 'str', speed_factor: 'float' = 1.0, audio_pitch: 'bool' = True, *, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute typed video speed adjustment.

compress(self, input_file: 'str', output_file: 'str', *, target_size_kb: 'int | None' = None, crf: 'int' = 23, two_pass: 'bool' = True, video_codec: 'str' = 'libx264', audio_codec: 'str' = 'aac', video_bitrate: 'str | None' = None, audio_bitrate: 'str' = '128k', preset: 'str' = 'medium', pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None, container_overhead_percent: 'float' = 5.0, minimum_video_bitrate: 'int' = 102400, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute typed single- or two-pass compression.

convert(self, input_file: 'str', output_file: 'str', *, video_codec: 'str | None' = None, audio_codec: 'str | None' = None, video_bitrate: 'str | None' = None, audio_bitrate: 'str | None' = None, pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None, audio_only: 'bool' = False, hardware_acceleration: 'str | None' = None, preserve_all_streams: 'bool' = False, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute a typed conversion.

execute_plan(self, plan: 'ExecutionPlan', *, cancellation: 'threading.Event | None' = None, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Execute a typed plan and return a stable structured result.

extract_audio(self, input_file: 'str', output_file: 'str', *, audio_codec: 'str | None' = None, audio_bitrate: 'str' = '192k', sample_rate: 'int | None' = None, channels: 'int | None' = None, threads: 'int | None' = None, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute typed audio extraction.

extract_thumbnail(self, input_file: 'str', output_file: 'str', timestamp: 'str' = '00:00:01', width: 'int' = 320, height: 'int | None' = None, quality: 'int' = 2, *, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute typed thumbnail extraction.

generate_waveform(self, input_file: 'str', output_file: 'str', width: 'int' = 800, height: 'int' = 200, colors: 'str' = 'white', *, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute typed waveform rendering.

get_version(self) -> 'str'

Return the FFmpeg version banner line.

resize(self, input_file: 'str', output_file: 'str', width: 'int', height: 'int', *, video_codec: 'str | None' = None, audio_codec: 'str | None' = None, pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None, force: 'bool' = False, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'JobResult'

Plan, preflight, and execute a typed resize.

run(self, args: 'list[str]', progress_callback: 'Callable[[dict[str, object]], None] | None' = None, *, overwrite: 'OverwritePolicy' = <OverwritePolicy.REFUSE: 'refuse'>) -> 'subprocess.CompletedProcess[str]'

Run a raw argument vector without a shell and with explicit overwrite policy.

run_with_progress(self, args: 'list[str]', show_percentage: 'bool' = True, *, overwrite: 'OverwritePolicy' = <OverwritePolicy.REFUSE: 'refuse'>) -> 'subprocess.CompletedProcess[str]'

Run the low-level escape hatch and print its legacy progress stream.

FFprobeRunner

A runner for extracting metadata from media files using FFprobe.

get_bitrate(self, input_file: 'str') -> 'int | None'

Get the bitrate of a media file.

Args: input_file: Path to the media file

Returns: Bitrate in bits per second

get_duration(self, input_file: 'str') -> 'float'

Get the duration of a media file in seconds.

Args: input_file: Path to the media file

Returns: Duration in seconds

get_resolution(self, input_file: 'str') -> 'tuple | None'

Get the resolution of a video file.

Args: input_file: Path to the video file

Returns: Tuple of (width, height) or None if not a video

get_version(self) -> 'str'

Get the FFprobe version.

Returns: Version string

probe(self, input_file: 'str', *, raw: 'bool' = False) -> 'dict[str, Any]'

Extract simplified metadata from a media file.

Args: input_file: Path to the media file

Returns: Simplified metadata dictionary derived from FFprobe JSON

probe_media(self, input_file: 'str') -> 'MediaInfo'

Return typed metadata while retaining decision-relevant stream details.

probe_raw(self, input_file: 'str') -> 'dict[str, Any]'

Return the complete FFprobe JSON document without dropping fields.

JobCancelledError

A caller explicitly cancelled a running job.

JobExecutionError

FFmpeg or FFprobe started but the media job failed.

JobResult

Stable execution result with diagnostics and output evidence.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

JobStatus

Python 3.10-compatible string enumeration.

JobTimeoutError

A job exceeded its explicit timeout.

MediaInfo

Typed container, stream, and chapter information from FFprobe.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

OverwritePolicy

Python 3.10-compatible string enumeration.

PipelineCachePolicy

Optional output-validity cache; content hashing is explicit.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

PipelineCompiler

Resolve variables/dependencies and compile every step through the typed planner.

compile(self, spec: 'PipelineSpec', *, variables: 'dict[str, str] | None' = None, force: 'bool' = False, timeout_seconds: 'float | None' = None, cache_enabled: 'bool | None' = None) -> 'PipelinePlan'

No public docstring is available.

PipelineEvent

PipelineEvent(sequence: 'int', event: 'str', step_id: 'str', detail: 'str | None' = None, schema_version: 'str' = '1.0')

to_dict(self, secrets: 'tuple[str, ...]' = ()) -> 'dict[str, object]'

No public docstring is available.

PipelinePlan

Compiled DAG whose steps contain argument arrays, never shell strings.

graph(self, format: 'str' = 'text') -> 'str'

Render the dependency DAG as text, Mermaid, or Graphviz DOT.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

PipelinePreflightEngine

Preflight an entire DAG while explicitly deferring dependency outputs.

prepare(self, pipeline: 'PipelinePlan', *, allow_existing_outputs: 'bool' = False) -> 'PreparedPipeline'

No public docstring is available.

PipelineRun

PipelineRun(pipeline: 'PipelinePlan', items: 'tuple[PipelineStepOutcome, ...]', schema_version: 'str' = '1.0')

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

PipelineRunner

Execute a prepared DAG with dependency blocking, cancellation, resume, and caching.

run(self, pipeline: 'PipelinePlan', *, cancellation: 'threading.Event | None' = None, state_path: 'str | Path | None' = None, resume: 'bool' = False, receipt_dir: 'str | Path | None' = None, hash_content: 'bool' = False, event_callback: 'Any' = None) -> 'PipelineRun'

No public docstring is available.

PipelineSpec

Versioned pipeline source with strict variables, cache, and typed steps.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

PipelineStepOutcome

PipelineStepOutcome(step_id: 'str', status: 'str', cache_key: 'str', execution: 'WorkflowExecution | None' = None, receipt: 'str | None' = None, detail: 'str | None' = None)

to_dict(self, secrets: 'tuple[str, ...]' = ()) -> 'dict[str, object]'

No public docstring is available.

PipelineStepPlan

One topologically ordered typed plan and its dependencies.

PipelineStepSpec

One strict declarative step before variable and dependency resolution.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

Profile

A named, versioned set of choices for one supported workflow.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

ProfileRegistry

Resolve built-in profiles and strictly validate local profile files.

get(self, name: 'str') -> 'Profile'

No public docstring is available.

list(self) -> 'tuple[Profile, ...]'

No public docstring is available.

load_file(self, path: 'str | Path') -> 'Profile'

Load one strict versioned profile from JSON or TOML.

plan(self, name: 'str', planner: 'WorkflowPlanner', input_file: 'str', output_file: 'str', *, subtitle_file: 'str | None' = None, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

Compile a maintained built-in profile through the shared typed planner.

PreparedPipeline

Whole-pipeline structural, capability, and external-input preflight facts.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

PreparedWorkflow

An immutable plan paired with its non-mutating preflight facts.

PreflightCheck

One deterministic preflight fact.

PreflightEngine

Check a plan without creating directories, outputs, or temporary files.

check(self, plan: 'ExecutionPlan') -> 'PreflightReport'

No public docstring is available.

PreflightReport

Versioned preflight result shared by human and JSON presenters.

render(self) -> 'str'

No public docstring is available.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

ProgressCallback

A helper class for creating progress callbacks with context.

ProgressEvent

Versioned progress fact suitable for callbacks or JSON Lines output.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

ProgressTracker

Tracks FFmpeg progress by parsing progress output.

run(self, cmd: list) -> subprocess.CompletedProcess

Run a command and track progress.

Args: cmd: Command to run

Returns: CompletedProcess instance

simple_progress_callback(progress: dict[str, typing.Any])

A simple progress callback that prints progress to console.

Args: progress: Progress dictionary

PyFFmpegCoreError

Base error carrying a stable machine-readable category.

ReceiptBuilder

Build redacted receipts from the same prepared workflow and stable results.

build(self, batch: 'WorkflowBatch', *, hash_content: 'bool' = False) -> 'RunReceipt'

Create a private-by-default receipt; content hashes are explicit opt-in.

ResizeOptions

ResizeOptions(width: 'int', height: 'int', video_codec: 'str | None' = None, audio_codec: 'str | None' = None, pixel_format: 'str' = 'yuv420p', threads: 'int | None' = None)

RunReceipt

Validated schema 1.0 receipt suitable for storage or bug reports.

to_dict(self) -> 'dict[str, Any]'

No public docstring is available.

to_json(self) -> 'str'

No public docstring is available.

write(self, path: 'str | Path') -> 'Path'

No public docstring is available.

StreamInfo

Typed stream facts while preserving metadata needed for safe decisions.

TemporaryFilePolicy

Python 3.10-compatible string enumeration.

ValidationError

User input or policy is invalid before execution starts.

WorkflowPlanner

Build deterministic plans used by CLI, Python, examples, and pipelines.

compress(self, input_file: 'str', output_file: 'str', options: 'CompressOptions | None' = None, *, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

concat(self, input_files: 'list[str]', output_file: 'str', *, mode: 'str' = 'copy', video_codec: 'str' = 'libx264', audio_codec: 'str' = 'aac', force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

convert(self, input_file: 'str', output_file: 'str', options: 'ConvertOptions | None' = None, *, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

extract_audio(self, input_file: 'str', output_file: 'str', *, audio_codec: 'str | None' = None, audio_bitrate: 'str' = '192k', sample_rate: 'int | None' = None, channels: 'int | None' = None, threads: 'int | None' = None, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

image(self, input_file: 'str', output_file: 'str', *, quality: 'int' = 85, resize: 'tuple[int, int] | None' = None, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

Plan one still-image conversion without routing through a directory batch.

images(self, action: 'str', input_dir: 'str', output_dir: 'str', *, output_format: 'str' = 'jpg', quality: 'int' = 85, resize: 'tuple[int, int] | None' = None, max_width: 'int' = 1920, max_height: 'int' = 1080, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

mix_audio(self, action: 'str', input_files: 'list[str]', output_file: 'str', *, volumes: 'list[float] | None' = None, crossfade_duration: 'float' = 2.0, background_volume: 'float' = 0.3, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

normalize_audio(self, input_file: 'str', output_file: 'str', *, method: 'str' = 'loudnorm', target_i: 'float' = -16.0, target_tp: 'float' = -1.5, target_lra: 'float' = 11.0, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

resize(self, input_file: 'str', output_file: 'str', options: 'ResizeOptions', *, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

speed(self, kind: 'str', input_file: 'str', output_file: 'str', *, factor: 'float', preserve_pitch: 'bool' = True, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

subtitles(self, action: 'str', video_file: 'str', output_file: 'str', *, subtitle_file: 'str | None' = None, language: 'str' = 'eng', stream_index: 'int' = 0, font_size: 'int' = 24, font_color: 'str' = '&HFFFFFF', force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

thumbnail(self, input_file: 'str', output_file: 'str', *, timestamp: 'str' = '00:00:01', width: 'int' = 320, height: 'int | None' = None, quality: 'int' = 2, force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

waveform(self, input_file: 'str', output_file: 'str', *, width: 'int' = 800, height: 'int' = 200, colors: 'str' = 'white', force: 'bool' = False, timeout_seconds: 'float | None' = None) -> 'ExecutionPlan'

No public docstring is available.

WorkflowBatch

Versioned machine-readable outcome for a single or multi-item plan.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.

WorkflowEngine

Compile, preflight, and execute every supported workflow through one public layer.

prepare(self, plan: 'ExecutionPlan') -> 'PreparedWorkflow'

Preflight an already compiled plan without mutating media or output paths.

run(self, plan: 'ExecutionPlan | PreparedWorkflow', *, cancellation: 'threading.Event | None' = None, progress_callback: 'Callable[[ProgressEvent], None] | None' = None) -> 'WorkflowBatch'

Execute a single workflow or an item-aware image batch with stable results.

WorkflowExecution

Preflight and execution facts for one input/output item.

to_dict(self) -> 'dict[str, object]'

No public docstring is available.