Skip to content

Ffmpeg Backend

FFmpeg backend for the deinterlace processor family.

Owns FFmpeg yadif helpers, tunable params, and FFmpegDeinterlaceProcessor.

FFmpegDeinterlaceConfig

Bases: DeinterlaceConfig

FFmpeg-specific stable config (inherits shared DeinterlaceConfig).

Attributes:

Name Type Description
yadif_mode int

Yadif mode (0=send_frame, 1=send_field, 2=send_frame_nospatial, 3=send_field_nospatial). Defaults to 0.

yadif_parity int

Field parity (-1=auto, 0=tff, 1=bff). Defaults to -1.

yadif_deint int

Deinterlace all frames (0) or only flagged (1). Defaults to 0.

video_codec str

Video encoder name. Defaults to libx264.

preset str

x264 preset. Defaults to ultrafast.

crf int

Constant rate factor (0–51). Defaults to 23.

filter_override str | None

Full -vf string; when set, yadif_* fields are ignored. Defaults to None.

validate_non_empty(value) classmethod

Reject blank codec/preset strings.

Parameters:

Name Type Description Default
value str

Candidate string.

required

Returns:

Name Type Description
str str

Validated string.

Raises:

Type Description
ValueError

If value is blank.

yadif_filter()

Build the -vf filter string.

Returns:

Name Type Description
str str

Filter graph for FFmpeg -vf.

FFmpegDeinterlaceProcessConfig

Bases: DeinterlaceProcessConfig

Per-invocation FFmpeg overrides (inherits shared DeinterlaceProcessConfig).

Any field left as None falls back to the stable constructor config.

FFmpegDeinterlaceProcessor(config=None)

Bases: BaseFFmpegProcessor, DeinterlaceProcessor

Deinterlace video with FFmpeg yadif.

Attributes:

Name Type Description
config FFmpegDeinterlaceConfig

Stable constructor configuration.

Initialize the FFmpeg deinterlace processor.

Parameters:

Name Type Description Default
config dict[str, Any] | DeinterlaceConfig | FFmpegDeinterlaceConfig | None

Shared DeinterlaceConfig, FFmpeg-specific config, or dict. Shared-only configs are promoted with FFmpeg defaults for engine fields. Defaults to None.

None

config_model() classmethod

Return the stable configuration model.

deinterlace_video(video_path, output_path=None, *, params=None)

Deinterlace a video path with FFmpeg yadif into a progressive file.

Parameters:

Name Type Description Default
video_path str

Source video path.

required
output_path str | None

Destination path. When None, a temporary .mp4 path is created. Defaults to None.

None
params FFmpegDeinterlaceConfig | None

Effective options for this call. Defaults to self.config.

None

Returns:

Name Type Description
str str

Path to the progressive output video.

Raises:

Type Description
FileNotFoundError

If ffmpeg is not on PATH.

RuntimeError

If FFmpeg deinterlace fails.

process(attachment, **kwargs) async

Deinterlace one video attachment.

Parameters:

Name Type Description Default
attachment Attachment

Input interlaced (or progressive) video.

required
**kwargs Any

May include process_config overrides.

{}

Returns:

Name Type Description
Attachment Attachment

Progressive video attachment.

process_config_model() classmethod

Return the per-invocation configuration model.