#compdef ab-av1

autoload -U is-at-least

_ab-av1() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
":: :_ab-av1_commands" \
"*::: :->ab-av1" \
&& ret=0
    case $state in
    (ab-av1)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ab-av1-command-$line[1]:"
        case $line[1] in
            (sample-encode)
_arguments "${_arguments_options[@]}" \
'-e+[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'--encoder=[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'-i+[Input video file]:INPUT:_files' \
'--input=[Input video file]:INPUT:_files' \
'--vfilter=[Ffmpeg video filter applied to the input before av1 encoding. E.g. --vfilter "scale=1280:-1,fps=24"]:VFILTER: ' \
'--pix-format=[Pixel format. svt-av1 default yuv420p10le]:PIX_FORMAT:(yuv420p10le yuv420p yuv444p10le)' \
'--preset=[Encoder preset (0-13). Higher presets means faster encodes, but with a quality tradeoff]:PRESET: ' \
'--keyint=[Interval between keyframes. Can be specified as a number of frames, or a duration. E.g. "300" or "10s". Defaults to 10s if the input duration is over 3m]:KEYINT: ' \
'--scd=[Svt-av1 scene change detection, inserts keyframes at scene changes. Defaults on if using default keyint & the input duration is over 3m. Otherwise off]:SCD:(true false)' \
'*--svt=[Additional svt-av1 arg(s). E.g. --svt mbr=2000 --svt film-grain=30]:SVT_ARGS: ' \
'*--enc=[Additional ffmpeg encoder arg(s). E.g. `--enc x265-params=lossless=1` These are added as ffmpeg output file options]:ENC_ARGS: ' \
'*--enc-input=[Additional ffmpeg input encoder arg(s). E.g. `--enc-input r=1` These are added as ffmpeg input file options]:ENC_INPUT_ARGS: ' \
'--crf=[Encoder constant rate factor (1-63). Lower means better quality]:CRF: ' \
'--samples=[Number of 20s samples to use across the input video. Overrides --sample-every. More samples take longer but may provide a more accurate result]:SAMPLES: ' \
'--sample-every=[Calculate number of samples by dividing the input duration by this value. So "12m" would mean with an input 25-36 minutes long, 3 samples would be used. More samples take longer but may provide a more accurate result]:SAMPLE_EVERY: ' \
'--temp-dir=[Directory to store temporary sample data in. Defaults to using the input'\''s directory]:TEMP_DIR:_files' \
'--stdout-format=[Stdout message format `human` or `json`]:STDOUT_FORMAT:(human json)' \
'*--vmaf=[Additional vmaf arg(s). E.g. --vmaf n_threads=8 --vmaf n_subsample=4]:VMAF_ARGS: ' \
'--vmaf-scale=[Video resolution scale to use in VMAF analysis. If set, video streams will be bicupic scaled to this width during VMAF analysis. `auto` (default) automatically sets based on the model and input video resolution. `none` disables any scaling. `WxH` format may be used to specify custom scaling, e.g. `1920x1080`]:VMAF_SCALE: ' \
'--keep[Keep temporary files after exiting]' \
'-h[Print help information (use `--help` for more detail)]' \
'--help[Print help information (use `--help` for more detail)]' \
&& ret=0
;;
(vmaf)
_arguments "${_arguments_options[@]}" \
'--reference=[Reference video file]:REFERENCE:_files' \
'--reference-vfilter=[Ffmpeg video filter applied to the reference before analysis. E.g. --vfilter "scale=1280:-1,fps=24"]:REFERENCE_VFILTER: ' \
'--distorted=[Re-encoded/distorted video file]:DISTORTED:_files' \
'*--vmaf=[Additional vmaf arg(s). E.g. --vmaf n_threads=8 --vmaf n_subsample=4]:VMAF_ARGS: ' \
'--vmaf-scale=[Video resolution scale to use in VMAF analysis. If set, video streams will be bicupic scaled to this width during VMAF analysis. `auto` (default) automatically sets based on the model and input video resolution. `none` disables any scaling. `WxH` format may be used to specify custom scaling, e.g. `1920x1080`]:VMAF_SCALE: ' \
'-h[Print help information (use `--help` for more detail)]' \
'--help[Print help information (use `--help` for more detail)]' \
&& ret=0
;;
(encode)
_arguments "${_arguments_options[@]}" \
'-e+[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'--encoder=[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'-i+[Input video file]:INPUT:_files' \
'--input=[Input video file]:INPUT:_files' \
'--vfilter=[Ffmpeg video filter applied to the input before av1 encoding. E.g. --vfilter "scale=1280:-1,fps=24"]:VFILTER: ' \
'--pix-format=[Pixel format. svt-av1 default yuv420p10le]:PIX_FORMAT:(yuv420p10le yuv420p yuv444p10le)' \
'--preset=[Encoder preset (0-13). Higher presets means faster encodes, but with a quality tradeoff]:PRESET: ' \
'--keyint=[Interval between keyframes. Can be specified as a number of frames, or a duration. E.g. "300" or "10s". Defaults to 10s if the input duration is over 3m]:KEYINT: ' \
'--scd=[Svt-av1 scene change detection, inserts keyframes at scene changes. Defaults on if using default keyint & the input duration is over 3m. Otherwise off]:SCD:(true false)' \
'*--svt=[Additional svt-av1 arg(s). E.g. --svt mbr=2000 --svt film-grain=30]:SVT_ARGS: ' \
'*--enc=[Additional ffmpeg encoder arg(s). E.g. `--enc x265-params=lossless=1` These are added as ffmpeg output file options]:ENC_ARGS: ' \
'*--enc-input=[Additional ffmpeg input encoder arg(s). E.g. `--enc-input r=1` These are added as ffmpeg input file options]:ENC_INPUT_ARGS: ' \
'--crf=[Encoder constant rate factor (1-63). Lower means better quality]:CRF: ' \
'-o+[Output file, by default the same as input with `.av1` before the extension]:OUTPUT:_files' \
'--output=[Output file, by default the same as input with `.av1` before the extension]:OUTPUT:_files' \
'--acodec=[Set the output ffmpeg audio codec. By default when the input & output file extension match '\''copy'\'' is used, otherwise '\''libopus'\'']:AUDIO_CODEC: ' \
'--downmix-to-stereo[Downmix input audio streams to stereo if input streams use greater than 3 channels]' \
'-h[Print help information (use `--help` for more detail)]' \
'--help[Print help information (use `--help` for more detail)]' \
&& ret=0
;;
(crf-search)
_arguments "${_arguments_options[@]}" \
'-e+[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'--encoder=[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'-i+[Input video file]:INPUT:_files' \
'--input=[Input video file]:INPUT:_files' \
'--vfilter=[Ffmpeg video filter applied to the input before av1 encoding. E.g. --vfilter "scale=1280:-1,fps=24"]:VFILTER: ' \
'--pix-format=[Pixel format. svt-av1 default yuv420p10le]:PIX_FORMAT:(yuv420p10le yuv420p yuv444p10le)' \
'--preset=[Encoder preset (0-13). Higher presets means faster encodes, but with a quality tradeoff]:PRESET: ' \
'--keyint=[Interval between keyframes. Can be specified as a number of frames, or a duration. E.g. "300" or "10s". Defaults to 10s if the input duration is over 3m]:KEYINT: ' \
'--scd=[Svt-av1 scene change detection, inserts keyframes at scene changes. Defaults on if using default keyint & the input duration is over 3m. Otherwise off]:SCD:(true false)' \
'*--svt=[Additional svt-av1 arg(s). E.g. --svt mbr=2000 --svt film-grain=30]:SVT_ARGS: ' \
'*--enc=[Additional ffmpeg encoder arg(s). E.g. `--enc x265-params=lossless=1` These are added as ffmpeg output file options]:ENC_ARGS: ' \
'*--enc-input=[Additional ffmpeg input encoder arg(s). E.g. `--enc-input r=1` These are added as ffmpeg input file options]:ENC_INPUT_ARGS: ' \
'--min-vmaf=[Desired min VMAF score to deliver]:MIN_VMAF: ' \
'--max-encoded-percent=[Maximum desired encoded size percentage of the input size]:MAX_ENCODED_PERCENT: ' \
'--min-crf=[Minimum (highest quality) crf value to try]:MIN_CRF: ' \
'--max-crf=[Maximum (lowest quality) crf value to try]:MAX_CRF: ' \
'--samples=[Number of 20s samples to use across the input video. Overrides --sample-every. More samples take longer but may provide a more accurate result]:SAMPLES: ' \
'--sample-every=[Calculate number of samples by dividing the input duration by this value. So "12m" would mean with an input 25-36 minutes long, 3 samples would be used. More samples take longer but may provide a more accurate result]:SAMPLE_EVERY: ' \
'--temp-dir=[Directory to store temporary sample data in. Defaults to using the input'\''s directory]:TEMP_DIR:_files' \
'*--vmaf=[Additional vmaf arg(s). E.g. --vmaf n_threads=8 --vmaf n_subsample=4]:VMAF_ARGS: ' \
'--vmaf-scale=[Video resolution scale to use in VMAF analysis. If set, video streams will be bicupic scaled to this width during VMAF analysis. `auto` (default) automatically sets based on the model and input video resolution. `none` disables any scaling. `WxH` format may be used to specify custom scaling, e.g. `1920x1080`]:VMAF_SCALE: ' \
'-h[Print help information (use `--help` for more detail)]' \
'--help[Print help information (use `--help` for more detail)]' \
&& ret=0
;;
(auto-encode)
_arguments "${_arguments_options[@]}" \
'-e+[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'--encoder=[Encoder override. See https://ffmpeg.org/ffmpeg-all.html#toc-Video-Encoders]:ENCODER: ' \
'-i+[Input video file]:INPUT:_files' \
'--input=[Input video file]:INPUT:_files' \
'--vfilter=[Ffmpeg video filter applied to the input before av1 encoding. E.g. --vfilter "scale=1280:-1,fps=24"]:VFILTER: ' \
'--pix-format=[Pixel format. svt-av1 default yuv420p10le]:PIX_FORMAT:(yuv420p10le yuv420p yuv444p10le)' \
'--preset=[Encoder preset (0-13). Higher presets means faster encodes, but with a quality tradeoff]:PRESET: ' \
'--keyint=[Interval between keyframes. Can be specified as a number of frames, or a duration. E.g. "300" or "10s". Defaults to 10s if the input duration is over 3m]:KEYINT: ' \
'--scd=[Svt-av1 scene change detection, inserts keyframes at scene changes. Defaults on if using default keyint & the input duration is over 3m. Otherwise off]:SCD:(true false)' \
'*--svt=[Additional svt-av1 arg(s). E.g. --svt mbr=2000 --svt film-grain=30]:SVT_ARGS: ' \
'*--enc=[Additional ffmpeg encoder arg(s). E.g. `--enc x265-params=lossless=1` These are added as ffmpeg output file options]:ENC_ARGS: ' \
'*--enc-input=[Additional ffmpeg input encoder arg(s). E.g. `--enc-input r=1` These are added as ffmpeg input file options]:ENC_INPUT_ARGS: ' \
'--min-vmaf=[Desired min VMAF score to deliver]:MIN_VMAF: ' \
'--max-encoded-percent=[Maximum desired encoded size percentage of the input size]:MAX_ENCODED_PERCENT: ' \
'--min-crf=[Minimum (highest quality) crf value to try]:MIN_CRF: ' \
'--max-crf=[Maximum (lowest quality) crf value to try]:MAX_CRF: ' \
'--samples=[Number of 20s samples to use across the input video. Overrides --sample-every. More samples take longer but may provide a more accurate result]:SAMPLES: ' \
'--sample-every=[Calculate number of samples by dividing the input duration by this value. So "12m" would mean with an input 25-36 minutes long, 3 samples would be used. More samples take longer but may provide a more accurate result]:SAMPLE_EVERY: ' \
'--temp-dir=[Directory to store temporary sample data in. Defaults to using the input'\''s directory]:TEMP_DIR:_files' \
'*--vmaf=[Additional vmaf arg(s). E.g. --vmaf n_threads=8 --vmaf n_subsample=4]:VMAF_ARGS: ' \
'--vmaf-scale=[Video resolution scale to use in VMAF analysis. If set, video streams will be bicupic scaled to this width during VMAF analysis. `auto` (default) automatically sets based on the model and input video resolution. `none` disables any scaling. `WxH` format may be used to specify custom scaling, e.g. `1920x1080`]:VMAF_SCALE: ' \
'-o+[Output file, by default the same as input with `.av1` before the extension]:OUTPUT:_files' \
'--output=[Output file, by default the same as input with `.av1` before the extension]:OUTPUT:_files' \
'--acodec=[Set the output ffmpeg audio codec. By default when the input & output file extension match '\''copy'\'' is used, otherwise '\''libopus'\'']:AUDIO_CODEC: ' \
'--downmix-to-stereo[Downmix input audio streams to stereo if input streams use greater than 3 channels]' \
'-h[Print help information (use `--help` for more detail)]' \
'--help[Print help information (use `--help` for more detail)]' \
&& ret=0
;;
(print-completions)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::shell -- Shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
":: :_ab-av1__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:ab-av1-help-command-$line[1]:"
        case $line[1] in
            (sample-encode)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(vmaf)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(encode)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(crf-search)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(auto-encode)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(print-completions)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_ab-av1_commands] )) ||
_ab-av1_commands() {
    local commands; commands=(
'sample-encode:Encode & analyse input samples to predict how a full encode would go.
This is much quicker than a full encode/vmaf run.' \
'vmaf:Simple full calculation of VMAF score distorted file vs original file' \
'encode:Simple invocation of ffmpeg & SvtAv1EncApp to encode a video or image' \
'crf-search:Interpolated binary search using sample-encode to find the best crf
value delivering min-vmaf & max-encoded-percent.' \
'auto-encode:Automatically determine the best crf to deliver the min-vmaf and use it to encode a video or image.' \
'print-completions:Print shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ab-av1 commands' commands "$@"
}
(( $+functions[_ab-av1__auto-encode_commands] )) ||
_ab-av1__auto-encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 auto-encode commands' commands "$@"
}
(( $+functions[_ab-av1__help__auto-encode_commands] )) ||
_ab-av1__help__auto-encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help auto-encode commands' commands "$@"
}
(( $+functions[_ab-av1__crf-search_commands] )) ||
_ab-av1__crf-search_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 crf-search commands' commands "$@"
}
(( $+functions[_ab-av1__help__crf-search_commands] )) ||
_ab-av1__help__crf-search_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help crf-search commands' commands "$@"
}
(( $+functions[_ab-av1__encode_commands] )) ||
_ab-av1__encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 encode commands' commands "$@"
}
(( $+functions[_ab-av1__help__encode_commands] )) ||
_ab-av1__help__encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help encode commands' commands "$@"
}
(( $+functions[_ab-av1__help_commands] )) ||
_ab-av1__help_commands() {
    local commands; commands=(
'sample-encode:Encode & analyse input samples to predict how a full encode would go.
This is much quicker than a full encode/vmaf run.' \
'vmaf:Simple full calculation of VMAF score distorted file vs original file' \
'encode:Simple invocation of ffmpeg & SvtAv1EncApp to encode a video or image' \
'crf-search:Interpolated binary search using sample-encode to find the best crf
value delivering min-vmaf & max-encoded-percent.' \
'auto-encode:Automatically determine the best crf to deliver the min-vmaf and use it to encode a video or image.' \
'print-completions:Print shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'ab-av1 help commands' commands "$@"
}
(( $+functions[_ab-av1__help__help_commands] )) ||
_ab-av1__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help help commands' commands "$@"
}
(( $+functions[_ab-av1__help__print-completions_commands] )) ||
_ab-av1__help__print-completions_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help print-completions commands' commands "$@"
}
(( $+functions[_ab-av1__print-completions_commands] )) ||
_ab-av1__print-completions_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 print-completions commands' commands "$@"
}
(( $+functions[_ab-av1__help__sample-encode_commands] )) ||
_ab-av1__help__sample-encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help sample-encode commands' commands "$@"
}
(( $+functions[_ab-av1__sample-encode_commands] )) ||
_ab-av1__sample-encode_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 sample-encode commands' commands "$@"
}
(( $+functions[_ab-av1__help__vmaf_commands] )) ||
_ab-av1__help__vmaf_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 help vmaf commands' commands "$@"
}
(( $+functions[_ab-av1__vmaf_commands] )) ||
_ab-av1__vmaf_commands() {
    local commands; commands=()
    _describe -t commands 'ab-av1 vmaf commands' commands "$@"
}

_ab-av1 "$@"
