# NOTE: this file is auto-generated, do not modify
"""
FFmpeg codec options.
"""



from typing import Literal


from ..types import Binary, Boolean, Color, Dictionary, Double, Duration, Flags, Float, Func, Image_size, Int, Int64, Pix_fmt, Rational, Sample_fmt, String, Time, Video_rate

from ..utils.frozendict import FrozenDict, merge
from ..utils.typing import override
from ..schema import Default, StreamType, Auto, FFMpegOptionGroup
from ..common.schema import FFMpegFilterDef
from .framesync import FFMpegFrameSyncOption
from .timeline import FFMpegTimelineOption



from ..streams.channel_layout import CHANNEL_LAYOUT
from ..codecs.schema import FFMpegEncoderOption, FFMpegDecoderOption
from ..formats.schema import FFMpegMuxerOption, FFMpegDemuxerOption






class FFMpegAVCodecContextEncoderOption(FFMpegOptionGroup):
    """AVCodecContext Encoder options."""

class FFMpegAVCodecContextDecoderOption(FFMpegOptionGroup):
    """AVCodecContext Decoder options."""

def encoder_codec_context(
*,
b: int | None = None,
ab: int | None = None,
bt: int | None = None,
flags: str | None = None,
export_side_data: str | None = None,
g: int | None = None,
ar: int | None = None,
ac: int | None = None,
cutoff: int | None = None,
frame_size: int | None = None,
qcomp: float | None = None,
qblur: float | None = None,
qmin: int | None = None,
qmax: int | None = None,
qdiff: int | None = None,
bf: int | None = None,
b_qfactor: float | None = None,
strict: int | None| Literal["very", "strict", "normal", "unofficial", "experimental"] = None,
b_qoffset: float | None = None,
err_detect: str | None = None,
maxrate: int | None = None,
minrate: int | None = None,
bufsize: int | None = None,
i_qfactor: float | None = None,
i_qoffset: float | None = None,
dct: int | None| Literal["auto", "fastint", "int", "mmx", "altivec", "faan"] = None,
lumi_mask: float | None = None,
tcplx_mask: float | None = None,
scplx_mask: float | None = None,
p_mask: float | None = None,
dark_mask: float | None = None,
idct: int | None| Literal["auto", "int", "simple", "simplemmx", "arm", "altivec", "simplearm", "simplearmv5te", "simplearmv6", "simpleneon", "xvid", "xvidmmx", "faani", "simpleauto"] = None,
aspect: str | None = None,
debug: str | None = None,
dia_size: int | None = None,
last_pred: int | None = None,
pre_dia_size: int | None = None,
subq: int | None = None,
me_range: int | None = None,
global_quality: int | None = None,
mbd: int | None| Literal["simple", "bits", "rd"] = None,
rc_init_occupancy: int | None = None,
threads: int | None| Literal["auto"] = None,
dc: int | None = None,
nssew: int | None = None,
profile: int | None| Literal["unknown", "main10"] = None,
cmp: int | None| Literal["sad", "sse", "satd", "dct", "psnr", "bit", "rd", "zero", "vsad", "vsse", "nsse", "w53", "w97", "dctmax", "chroma", "msad"] = None,
subcmp: int | None| Literal["sad", "sse", "satd", "dct", "psnr", "bit", "rd", "zero", "vsad", "vsse", "nsse", "w53", "w97", "dctmax", "chroma", "msad"] = None,
mbcmp: int | None| Literal["sad", "sse", "satd", "dct", "psnr", "bit", "rd", "zero", "vsad", "vsse", "nsse", "w53", "w97", "dctmax", "chroma", "msad"] = None,
ildctcmp: int | None| Literal["sad", "sse", "satd", "dct", "psnr", "bit", "rd", "zero", "vsad", "vsse", "nsse", "w53", "w97", "dctmax", "chroma", "msad"] = None,
precmp: int | None| Literal["sad", "sse", "satd", "dct", "psnr", "bit", "rd", "zero", "vsad", "vsse", "nsse", "w53", "w97", "dctmax", "chroma", "msad"] = None,
mblmin: int | None = None,
mblmax: int | None = None,
bidir_refine: int | None = None,
keyint_min: int | None = None,
refs: int | None = None,
trellis: int | None = None,
mv0_threshold: int | None = None,
compression_level: int | None = None,
ch_layout: str | None = None,
channel_layout: str | None = None,
rc_max_vbv_use: float | None = None,
rc_min_vbv_use: float | None = None,
ticks_per_frame: int | None = None,
color_primaries: int | None| Literal["bt709", "unknown", "bt470m", "bt470bg", "smpte170m", "smpte240m", "film", "bt2020", "smpte428", "smpte428_1", "smpte431", "smpte432", "jedec-p22", "ebu3213", "unspecified"] = None,
color_trc: int | None| Literal["bt709", "unknown", "gamma22", "gamma28", "smpte170m", "smpte240m", "linear", "log100", "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12", "smpte2084", "smpte428", "arib-std-b67", "unspecified", "log", "log_sqrt", "iec61966_2_4", "bt1361", "iec61966_2_1", "bt2020_10bit", "bt2020_12bit", "smpte428_1"] = None,
colorspace: int | None| Literal["rgb", "bt709", "unknown", "fcc", "bt470bg", "smpte170m", "smpte240m", "ycgco", "bt2020nc", "bt2020c", "smpte2085", "chroma-derived-nc", "chroma-derived-c", "ictcp", "unspecified", "ycocg", "bt2020_ncl", "bt2020_cl"] = None,
color_range: int | None| Literal["unknown", "tv", "pc", "unspecified", "mpeg", "jpeg"] = None,
chroma_sample_location: int | None| Literal["unknown", "left", "center", "topleft", "top", "bottomleft", "bottom", "unspecified"] = None,
slices: int | None = None,
thread_type: str | None = None,
audio_service_type: int | None| Literal["ma", "ef", "vi", "hi", "di", "co", "em", "vo", "ka"] = None,
field_order: int | None| Literal["progressive", "tt", "bb", "tb", "bt"] = None,
dump_separator: str | None = None,
max_pixels: int | None = None,
max_samples: int | None = None,
) -> FFMpegAVCodecContextEncoderOption:
    """
        Encoder codec context options.

        Args:
            b: set bitrate (in bits/s) (from 0 to I64_MAX) (default 200000),
            ab: set bitrate (in bits/s) (from 0 to INT_MAX) (default 128000),
            bt: Set video bitrate tolerance (in bits/s). In 1-pass mode, bitrate tolerance specifies how far ratecontrol is willing to deviate from the target average bitrate value. This is not related to minimum/maximum bitrate. Lowering tolerance too much has an adverse effect on quality. (from 1 to INT_MAX) (default 4000000),
            flags: (default 0),
            export_side_data: Export metadata as side data (default 0),
            g: set the group of picture (GOP) size (from INT_MIN to INT_MAX) (default 12),
            ar: set audio sampling rate (in Hz) (from 0 to INT_MAX) (default 0),
            ac: set number of audio channels (from 0 to INT_MAX) (default 0),
            cutoff: set cutoff bandwidth (from INT_MIN to INT_MAX) (default 0),
            frame_size: (from 0 to INT_MAX) (default 0),
            qcomp: video quantizer scale compression (VBR). Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0 (from -FLT_MAX to FLT_MAX) (default 0.5),
            qblur: video quantizer scale blur (VBR) (from -1 to FLT_MAX) (default 0.5),
            qmin: minimum video quantizer scale (VBR) (from -1 to 69) (default 2),
            qmax: maximum video quantizer scale (VBR) (from -1 to 1024) (default 31),
            qdiff: maximum difference between the quantizer scales (VBR) (from INT_MIN to INT_MAX) (default 3),
            bf: set maximum number of B-frames between non-B-frames (from -1 to INT_MAX) (default 0),
            b_qfactor: QP factor between P- and B-frames (from -FLT_MAX to FLT_MAX) (default 1.25),
            strict: how strictly to follow the standards (from INT_MIN to INT_MAX) (default normal),
            b_qoffset: QP offset between P- and B-frames (from -FLT_MAX to FLT_MAX) (default 1.25),
            err_detect: set error detection flags (default 0),
            maxrate: maximum bitrate (in bits/s). Used for VBV together with bufsize. (from 0 to INT_MAX) (default 0),
            minrate: minimum bitrate (in bits/s). Most useful in setting up a CBR encode. It is of little use otherwise. (from INT_MIN to INT_MAX) (default 0),
            bufsize: set ratecontrol buffer size (in bits) (from INT_MIN to INT_MAX) (default 0),
            i_qfactor: QP factor between P- and I-frames (from -FLT_MAX to FLT_MAX) (default -0.8),
            i_qoffset: QP offset between P- and I-frames (from -FLT_MAX to FLT_MAX) (default 0),
            dct: DCT algorithm (from 0 to INT_MAX) (default auto),
            lumi_mask: compresses bright areas stronger than medium ones (from -FLT_MAX to FLT_MAX) (default 0),
            tcplx_mask: temporal complexity masking (from -FLT_MAX to FLT_MAX) (default 0),
            scplx_mask: spatial complexity masking (from -FLT_MAX to FLT_MAX) (default 0),
            p_mask: inter masking (from -FLT_MAX to FLT_MAX) (default 0),
            dark_mask: compresses dark areas stronger than medium ones (from -FLT_MAX to FLT_MAX) (default 0),
            idct: select IDCT implementation (from 0 to INT_MAX) (default auto),
            aspect: sample aspect ratio (from 0 to 10) (default 0/1),
            debug: print specific debug info (default 0),
            dia_size: diamond type & size for motion estimation (from INT_MIN to INT_MAX) (default 0),
            last_pred: amount of motion predictors from the previous frame (from INT_MIN to INT_MAX) (default 0),
            pre_dia_size: diamond type & size for motion estimation pre-pass (from INT_MIN to INT_MAX) (default 0),
            subq: sub-pel motion estimation quality (from INT_MIN to INT_MAX) (default 8),
            me_range: limit motion vectors range (1023 for DivX player) (from INT_MIN to INT_MAX) (default 0),
            global_quality: (from INT_MIN to INT_MAX) (default 0),
            mbd: macroblock decision algorithm (high quality mode) (from 0 to 2) (default simple),
            rc_init_occupancy: number of bits which should be loaded into the rc buffer before decoding starts (from INT_MIN to INT_MAX) (default 0),
            threads: set the number of threads (from 0 to INT_MAX) (default 1),
            dc: intra_dc_precision (from -8 to 16) (default 0),
            nssew: nsse weight (from INT_MIN to INT_MAX) (default 8),
            profile: (from INT_MIN to INT_MAX) (default unknown),
            cmp: full-pel ME compare function (from INT_MIN to INT_MAX) (default sad),
            subcmp: sub-pel ME compare function (from INT_MIN to INT_MAX) (default sad),
            mbcmp: macroblock compare function (from INT_MIN to INT_MAX) (default sad),
            ildctcmp: interlaced DCT compare function (from INT_MIN to INT_MAX) (default vsad),
            precmp: pre motion estimation compare function (from INT_MIN to INT_MAX) (default sad),
            mblmin: minimum macroblock Lagrange factor (VBR) (from 1 to 32767) (default 236),
            mblmax: maximum macroblock Lagrange factor (VBR) (from 1 to 32767) (default 3658),
            bidir_refine: refine the two motion vectors used in bidirectional macroblocks (from 0 to 4) (default 1),
            keyint_min: minimum interval between IDR-frames (from INT_MIN to INT_MAX) (default 25),
            refs: reference frames to consider for motion compensation (from INT_MIN to INT_MAX) (default 1),
            trellis: rate-distortion optimal quantization (from INT_MIN to INT_MAX) (default 0),
            mv0_threshold: (from 0 to INT_MAX) (default 256),
            compression_level: (from INT_MIN to INT_MAX) (default -1),
            ch_layout: ,
            channel_layout: (default 0x0),
            rc_max_vbv_use: (from 0 to FLT_MAX) (default 0),
            rc_min_vbv_use: (from 0 to FLT_MAX) (default 3),
            ticks_per_frame: (from 1 to INT_MAX) (default 1),
            color_primaries: color primaries (from 1 to INT_MAX) (default unknown),
            color_trc: color transfer characteristics (from 1 to INT_MAX) (default unknown),
            colorspace: color space (from 0 to INT_MAX) (default unknown),
            color_range: color range (from 0 to INT_MAX) (default unknown),
            chroma_sample_location: chroma sample location (from 0 to INT_MAX) (default unknown),
            slices: set the number of slices, used in parallelized encoding (from 0 to INT_MAX) (default 0),
            thread_type: select multithreading type (default slice+frame),
            audio_service_type: audio service type (from 0 to 8) (default ma),
            field_order: Field order (from 0 to 5) (default 0),
            dump_separator: set information dump field separator,
            max_pixels: Maximum number of pixels (from 0 to INT_MAX) (default INT_MAX),
            max_samples: Maximum number of samples (from 0 to INT_MAX) (default INT_MAX),

        Returns:
            FFMpegAVCodecContextEncoderOption

    """

    return FFMpegAVCodecContextEncoderOption(merge({
        "b": b,
        "ab": ab,
        "bt": bt,
        "flags": flags,
        "export_side_data": export_side_data,
        "g": g,
        "ar": ar,
        "ac": ac,
        "cutoff": cutoff,
        "frame_size": frame_size,
        "qcomp": qcomp,
        "qblur": qblur,
        "qmin": qmin,
        "qmax": qmax,
        "qdiff": qdiff,
        "bf": bf,
        "b_qfactor": b_qfactor,
        "strict": strict,
        "b_qoffset": b_qoffset,
        "err_detect": err_detect,
        "maxrate": maxrate,
        "minrate": minrate,
        "bufsize": bufsize,
        "i_qfactor": i_qfactor,
        "i_qoffset": i_qoffset,
        "dct": dct,
        "lumi_mask": lumi_mask,
        "tcplx_mask": tcplx_mask,
        "scplx_mask": scplx_mask,
        "p_mask": p_mask,
        "dark_mask": dark_mask,
        "idct": idct,
        "aspect": aspect,
        "debug": debug,
        "dia_size": dia_size,
        "last_pred": last_pred,
        "pre_dia_size": pre_dia_size,
        "subq": subq,
        "me_range": me_range,
        "global_quality": global_quality,
        "mbd": mbd,
        "rc_init_occupancy": rc_init_occupancy,
        "threads": threads,
        "dc": dc,
        "nssew": nssew,
        "profile": profile,
        "cmp": cmp,
        "subcmp": subcmp,
        "mbcmp": mbcmp,
        "ildctcmp": ildctcmp,
        "precmp": precmp,
        "mblmin": mblmin,
        "mblmax": mblmax,
        "bidir_refine": bidir_refine,
        "keyint_min": keyint_min,
        "refs": refs,
        "trellis": trellis,
        "mv0_threshold": mv0_threshold,
        "compression_level": compression_level,
        "ch_layout": ch_layout,
        "channel_layout": channel_layout,
        "rc_max_vbv_use": rc_max_vbv_use,
        "rc_min_vbv_use": rc_min_vbv_use,
        "ticks_per_frame": ticks_per_frame,
        "color_primaries": color_primaries,
        "color_trc": color_trc,
        "colorspace": colorspace,
        "color_range": color_range,
        "chroma_sample_location": chroma_sample_location,
        "slices": slices,
        "thread_type": thread_type,
        "audio_service_type": audio_service_type,
        "field_order": field_order,
        "dump_separator": dump_separator,
        "max_pixels": max_pixels,
        "max_samples": max_samples,
    }))


def decoder_codec_context(
*,
flags: str | None = None,
export_side_data: str | None = None,
ar: int | None = None,
ac: int | None = None,
bug: str | None = None,
strict: int | None| Literal["very", "strict", "normal", "unofficial", "experimental"] = None,
err_detect: str | None = None,
idct: int | None| Literal["auto", "int", "simple", "simplemmx", "arm", "altivec", "simplearm", "simplearmv5te", "simplearmv6", "simpleneon", "xvid", "xvidmmx", "faani", "simpleauto"] = None,
ec: str | None = None,
debug: str | None = None,
threads: int | None| Literal["auto"] = None,
skip_top: int | None = None,
skip_bottom: int | None = None,
lowres: int | None = None,
skip_loop_filter: int | None| Literal["none", "default", "noref", "bidir", "nokey", "nointra", "all"] = None,
skip_idct: int | None| Literal["none", "default", "noref", "bidir", "nokey", "nointra", "all"] = None,
skip_frame: int | None| Literal["none", "default", "noref", "bidir", "nokey", "nointra", "all"] = None,
ch_layout: str | None = None,
channel_layout: str | None = None,
request_channel_layout: str | None = None,
ticks_per_frame: int | None = None,
color_primaries: int | None| Literal["bt709", "unknown", "bt470m", "bt470bg", "smpte170m", "smpte240m", "film", "bt2020", "smpte428", "smpte428_1", "smpte431", "smpte432", "jedec-p22", "ebu3213", "unspecified"] = None,
color_trc: int | None| Literal["bt709", "unknown", "gamma22", "gamma28", "smpte170m", "smpte240m", "linear", "log100", "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1", "bt2020-10", "bt2020-12", "smpte2084", "smpte428", "arib-std-b67", "unspecified", "log", "log_sqrt", "iec61966_2_4", "bt1361", "iec61966_2_1", "bt2020_10bit", "bt2020_12bit", "smpte428_1"] = None,
colorspace: int | None| Literal["rgb", "bt709", "unknown", "fcc", "bt470bg", "smpte170m", "smpte240m", "ycgco", "bt2020nc", "bt2020c", "smpte2085", "chroma-derived-nc", "chroma-derived-c", "ictcp", "unspecified", "ycocg", "bt2020_ncl", "bt2020_cl"] = None,
color_range: int | None| Literal["unknown", "tv", "pc", "unspecified", "mpeg", "jpeg"] = None,
chroma_sample_location: int | None| Literal["unknown", "left", "center", "topleft", "top", "bottomleft", "bottom", "unspecified"] = None,
thread_type: str | None = None,
request_sample_fmt: str | None = None,
sub_charenc: str | None = None,
sub_charenc_mode: str | None = None,
sub_text_format: int | None| Literal["ass"] = None,
apply_cropping: bool | None = None,
skip_alpha: bool | None = None,
field_order: int | None| Literal["progressive", "tt", "bb", "tb", "bt"] = None,
dump_separator: str | None = None,
codec_whitelist: str | None = None,
max_pixels: int | None = None,
max_samples: int | None = None,
hwaccel_flags: str | None = None,
extra_hw_frames: int | None = None,
discard_damaged_percentage: int | None = None,
) -> FFMpegAVCodecContextDecoderOption:
    """
        Decoder codec context options.

        Args:
            flags: (default 0),
            export_side_data: Export metadata as side data (default 0),
            ar: set audio sampling rate (in Hz) (from 0 to INT_MAX) (default 0),
            ac: set number of audio channels (from 0 to INT_MAX) (default 0),
            bug: work around not autodetected encoder bugs (default autodetect),
            strict: how strictly to follow the standards (from INT_MIN to INT_MAX) (default normal),
            err_detect: set error detection flags (default 0),
            idct: select IDCT implementation (from 0 to INT_MAX) (default auto),
            ec: set error concealment strategy (default guess_mvs+deblock),
            debug: print specific debug info (default 0),
            threads: set the number of threads (from 0 to INT_MAX) (default 1),
            skip_top: number of macroblock rows at the top which are skipped (from INT_MIN to INT_MAX) (default 0),
            skip_bottom: number of macroblock rows at the bottom which are skipped (from INT_MIN to INT_MAX) (default 0),
            lowres: decode at 1= 1/2, 2=1/4, 3=1/8 resolutions (from 0 to INT_MAX) (default 0),
            skip_loop_filter: skip loop filtering process for the selected frames (from INT_MIN to INT_MAX) (default default),
            skip_idct: skip IDCT/dequantization for the selected frames (from INT_MIN to INT_MAX) (default default),
            skip_frame: skip decoding for the selected frames (from INT_MIN to INT_MAX) (default default),
            ch_layout: ,
            channel_layout: (default 0x0),
            request_channel_layout: (default 0x0),
            ticks_per_frame: (from 1 to INT_MAX) (default 1),
            color_primaries: color primaries (from 1 to INT_MAX) (default unknown),
            color_trc: color transfer characteristics (from 1 to INT_MAX) (default unknown),
            colorspace: color space (from 0 to INT_MAX) (default unknown),
            color_range: color range (from 0 to INT_MAX) (default unknown),
            chroma_sample_location: chroma sample location (from 0 to INT_MAX) (default unknown),
            thread_type: select multithreading type (default slice+frame),
            request_sample_fmt: sample format audio decoders should prefer (default none),
            sub_charenc: set input text subtitles character encoding,
            sub_charenc_mode: set input text subtitles character encoding mode (default 0),
            sub_text_format: Deprecated, does nothing (from 0 to 1) (default ass),
            apply_cropping: (default true),
            skip_alpha: Skip processing alpha (default false),
            field_order: Field order (from 0 to 5) (default 0),
            dump_separator: set information dump field separator,
            codec_whitelist: List of decoders that are allowed to be used,
            max_pixels: Maximum number of pixels (from 0 to INT_MAX) (default INT_MAX),
            max_samples: Maximum number of samples (from 0 to INT_MAX) (default INT_MAX),
            hwaccel_flags: (default ignore_level),
            extra_hw_frames: Number of extra hardware frames to allocate for the user (from -1 to INT_MAX) (default -1),
            discard_damaged_percentage: Percentage of damaged samples to discard a frame (from 0 to 100) (default 95),

        Returns:
            FFMpegAVCodecContextDecoderOption

    """

    return FFMpegAVCodecContextDecoderOption(merge({
        "flags": flags,
        "export_side_data": export_side_data,
        "ar": ar,
        "ac": ac,
        "bug": bug,
        "strict": strict,
        "err_detect": err_detect,
        "idct": idct,
        "ec": ec,
        "debug": debug,
        "threads": threads,
        "skip_top": skip_top,
        "skip_bottom": skip_bottom,
        "lowres": lowres,
        "skip_loop_filter": skip_loop_filter,
        "skip_idct": skip_idct,
        "skip_frame": skip_frame,
        "ch_layout": ch_layout,
        "channel_layout": channel_layout,
        "request_channel_layout": request_channel_layout,
        "ticks_per_frame": ticks_per_frame,
        "color_primaries": color_primaries,
        "color_trc": color_trc,
        "colorspace": colorspace,
        "color_range": color_range,
        "chroma_sample_location": chroma_sample_location,
        "thread_type": thread_type,
        "request_sample_fmt": request_sample_fmt,
        "sub_charenc": sub_charenc,
        "sub_charenc_mode": sub_charenc_mode,
        "sub_text_format": sub_text_format,
        "apply_cropping": apply_cropping,
        "skip_alpha": skip_alpha,
        "field_order": field_order,
        "dump_separator": dump_separator,
        "codec_whitelist": codec_whitelist,
        "max_pixels": max_pixels,
        "max_samples": max_samples,
        "hwaccel_flags": hwaccel_flags,
        "extra_hw_frames": extra_hw_frames,
        "discard_damaged_percentage": discard_damaged_percentage,
    }))
