diff options
| author | Dennis Fink | 2026-05-09 21:30:38 +0200 |
|---|---|---|
| committer | Dennis Fink | 2026-05-09 21:30:38 +0200 |
| commit | 46e56972f2b4d16ca6b3fd04611f86cf8580ea10 (patch) | |
| tree | add502327a7f85c9b9b7af60abea617c5f246085 /transcode.sh.bash-completion | |
| parent | cfeb338478bb67defce2fb48222a6be3cffc4263 (diff) | |
| download | transcode.sh-46e56972f2b4d16ca6b3fd04611f86cf8580ea10.tar.gz transcode.sh-46e56972f2b4d16ca6b3fd04611f86cf8580ea10.zip | |
feat(core,cli): add hardware acceleration support via --hwaccel
Add --hwaccel [METHOD] / --no-hwaccel flags to control whether -hwaccel
is passed to ffmpeg before the input file. The METHOD argument is
optional and defaults to "auto", letting ffmpeg select the best
available hardware decoder with automatic software fallback.
Hardware acceleration is enabled by default (method: auto). Users on
hosts where hwaccel causes compatibility or stability issues can opt out
with --no-hwaccel or config.toml [encoding] hwaccel = false.
The config key accepts false (disable), true (auto), or a method string
such as "vaapi" or "cuda". CLI flags take precedence as usual.
Bash completion is extended with a hwaccel_methods word list (auto,
cuda, vaapi, dxva2, d3d11va, videotoolbox, qsv) for both the space form
(--hwaccel <TAB>) and the equals form (--hwaccel=<TAB>).
The completion script is also reformatted from 4-space to 2-space
indentation for consistency with transcode.sh itself.
Diffstat (limited to 'transcode.sh.bash-completion')
| -rw-r--r-- | transcode.sh.bash-completion | 297 |
1 files changed, 155 insertions, 142 deletions
diff --git a/transcode.sh.bash-completion b/transcode.sh.bash-completion index 9fc4701..1cae90e 100644 --- a/transcode.sh.bash-completion +++ b/transcode.sh.bash-completion @@ -14,155 +14,168 @@ # long equals --encode-file=list.txt _transcode_sh() { - local cur prev words cword - _init_completion || return + local cur prev words cword + _init_completion || return - local -r preset_dir="${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/presets" + local -r preset_dir="${XDG_CONFIG_HOME:-$HOME/.config}/transcode.sh/presets" - # --------------------------------------------------------------------------- - # Helper: collect preset names from the preset directory - # --------------------------------------------------------------------------- - _transcode_presets() { - local presets=() - if [[ -d "$preset_dir" ]]; then - local f - while IFS= read -r f; do - f="${f##*/}" # basename - f="${f%.sh}" # strip .sh extension - presets+=("$f") - done < <(find "$preset_dir" -maxdepth 1 -name '*.sh' -type f 2>/dev/null) - fi - printf '%s\n' "${presets[@]}" - } + # --------------------------------------------------------------------------- + # Helper: collect preset names from the preset directory + # --------------------------------------------------------------------------- + _transcode_presets() { + local presets=() + if [[ -d "$preset_dir" ]]; then + local f + while IFS= read -r f; do + f="${f##*/}" # basename + f="${f%.sh}" # strip .sh extension + presets+=("$f") + done < <(find "$preset_dir" -maxdepth 1 -name '*.sh' -type f 2>/dev/null) + fi + printf '%s\n' "${presets[@]}" + } - local codecs='h264 hevc av1 vp8 vp9 mpeg2video mpeg4 mjpeg theora' - local nice_vals='0 5 10 15 19' + local codecs='h264 hevc av1 vp8 vp9 mpeg2video mpeg4 mjpeg theora' + local nice_vals='0 5 10 15 19' + local hwaccel_methods='auto cuda vaapi dxva2 d3d11va videotoolbox qsv' - # --------------------------------------------------------------------------- - # Handle --option=VALUE: cur contains the entire "--opt=val" token. - # Strip the "opt=" prefix and delegate to the appropriate completer. - # This must be checked before the $prev dispatch below. - # --------------------------------------------------------------------------- - case "$cur" in - --config-file=*) - cur="${cur#*=}" - _filedir - return - ;; - --encode-file=*) - cur="${cur#*=}" - _filedir - return - ;; - --saving-file=*) - cur="${cur#*=}" - _filedir - return - ;; - --nice=*) - cur="${cur#*=}" - COMPREPLY=( $(compgen -W "$nice_vals" -- "$cur") ) - return - ;; - --skip-codec=*) - cur="${cur#*=}" - COMPREPLY=( $(compgen -W "$codecs" -- "$cur") ) - return - ;; - --preset=*) - cur="${cur#*=}" - COMPREPLY=( $(compgen -W "$(_transcode_presets)" -- "$cur") ) - return - ;; - esac + # --------------------------------------------------------------------------- + # Handle --option=VALUE: cur contains the entire "--opt=val" token. + # Strip the "opt=" prefix and delegate to the appropriate completer. + # This must be checked before the $prev dispatch below. + # --------------------------------------------------------------------------- + case "$cur" in + --config-file=*) + cur="${cur#*=}" + _filedir + return + ;; + --encode-file=*) + cur="${cur#*=}" + _filedir + return + ;; + --saving-file=*) + cur="${cur#*=}" + _filedir + return + ;; + --nice=*) + cur="${cur#*=}" + COMPREPLY=($(compgen -W "$nice_vals" -- "$cur")) + return + ;; + --skip-codec=*) + cur="${cur#*=}" + COMPREPLY=($(compgen -W "$codecs" -- "$cur")) + return + ;; + --preset=*) + cur="${cur#*=}" + COMPREPLY=($(compgen -W "$(_transcode_presets)" -- "$cur")) + return + ;; + --hwaccel=*) + cur="${cur#*=}" + COMPREPLY=($(compgen -W "$hwaccel_methods" -- "$cur")) + return + ;; + esac - # --------------------------------------------------------------------------- - # Handle VALUE after short form (-f, -N, -S, -p) and - # long space form (--encode-file, --nice, --saving-file, --skip-codec, --preset). - # $prev is the option word, $cur is the value being typed. - # --------------------------------------------------------------------------- - case "$prev" in - --config-file) - _filedir - return - ;; - -f|--encode-file) - _filedir - return - ;; - -N|--nice) - COMPREPLY=( $(compgen -W "$nice_vals" -- "$cur") ) - return - ;; - --saving-file) - _filedir - return - ;; - -S|--skip-codec) - COMPREPLY=( $(compgen -W "$codecs" -- "$cur") ) - return - ;; - -p|--preset) - COMPREPLY=( $(compgen -W "$(_transcode_presets)" -- "$cur") ) - return - ;; - esac + # --------------------------------------------------------------------------- + # Handle VALUE after short form (-f, -N, -S, -p) and + # long space form (--encode-file, --nice, --saving-file, --skip-codec, --preset). + # $prev is the option word, $cur is the value being typed. + # --------------------------------------------------------------------------- + case "$prev" in + --config-file) + _filedir + return + ;; + -f | --encode-file) + _filedir + return + ;; + -N | --nice) + COMPREPLY=($(compgen -W "$nice_vals" -- "$cur")) + return + ;; + --saving-file) + _filedir + return + ;; + -S | --skip-codec) + COMPREPLY=($(compgen -W "$codecs" -- "$cur")) + return + ;; + -p | --preset) + COMPREPLY=($(compgen -W "$(_transcode_presets)" -- "$cur")) + return + ;; + --hwaccel) + COMPREPLY=($(compgen -W "$hwaccel_methods" -- "$cur")) + return + ;; + esac - # --------------------------------------------------------------------------- - # Complete option names themselves. - # For options that accept an argument we list both the bare long form - # (--nice) and the equals form (--nice=) so the user can choose their - # preferred style. compopt -o nospace is applied when the sole match - # ends with '=' to avoid an unwanted trailing space in that case. - # --------------------------------------------------------------------------- - case "$cur" in - --*) - local longopts=' - --continue - --no-continue - --verify-output - --no-verify-output - --config-file - --config-file= - --encode-file - --encode-file= - --dry-run - --nice - --nice= - --saving - --no-saving - --saving-file - --saving-file= - --skip-codec - --skip-codec= - --only-if-smaller - --no-only-if-smaller - --preset - --preset= - --help - --quiet - --verbose - --version - --color - --no-color - ' - COMPREPLY=( $(compgen -W "$longopts" -- "$cur") ) - # Suppress the trailing space when the only completion ends with '=' - [[ ${#COMPREPLY[@]} -eq 1 && "${COMPREPLY[0]}" == *= ]] \ - && compopt -o nospace - return - ;; - -*) - local shortopts='-c -f -n -N -s -S -l -p -h -? -q -v --' - COMPREPLY=( $(compgen -W "$shortopts" -- "$cur") ) - return - ;; - esac + # --------------------------------------------------------------------------- + # Complete option names themselves. + # For options that accept an argument we list both the bare long form + # (--nice) and the equals form (--nice=) so the user can choose their + # preferred style. compopt -o nospace is applied when the sole match + # ends with '=' to avoid an unwanted trailing space in that case. + # --------------------------------------------------------------------------- + case "$cur" in + --*) + local longopts=' + --color + --config-file + --config-file= + --continue + --dry-run + --encode-file + --encode-file= + --help + --hwaccel + --hwaccel= + --nice + --nice= + --no-color + --no-continue + --no-hwaccel + --no-only-if-smaller + --no-saving + --no-verify-output + --only-if-smaller + --preset + --preset= + --quiet + --saving + --saving-file + --saving-file= + --skip-codec + --skip-codec= + --verbose + --verify-output + --version + ' + COMPREPLY=($(compgen -W "$longopts" -- "$cur")) + # Suppress the trailing space when the only completion ends with '=' + [[ ${#COMPREPLY[@]} -eq 1 && "${COMPREPLY[0]}" == *= ]] && + compopt -o nospace + return + ;; + -*) + local shortopts='-c -f -n -N -s -S -l -p -h -? -q -v --' + COMPREPLY=($(compgen -W "$shortopts" -- "$cur")) + return + ;; + esac - # --------------------------------------------------------------------------- - # Default: complete positional FILE arguments with common media extensions - # --------------------------------------------------------------------------- - _filedir '@(mkv|mp4|mov|avi|webm|flv|wmv|m4v|ts|mts|m2ts|mpg|mpeg|ogv|3gp|rm|rmvb)' + # --------------------------------------------------------------------------- + # Default: complete positional FILE arguments with common media extensions + # --------------------------------------------------------------------------- + _filedir '@(mkv|mp4|mov|avi|webm|flv|wmv|m4v|ts|mts|m2ts|mpg|mpeg|ogv|3gp|rm|rmvb)' } complete -F _transcode_sh transcode.sh |
