summaryrefslogtreecommitdiffstats
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_ffmpeg219
1 files changed, 110 insertions, 109 deletions
diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg
index 1c57e3b9c..dbef81f22 100644
--- a/Completion/Unix/Command/_ffmpeg
+++ b/Completion/Unix/Command/_ffmpeg
@@ -3,133 +3,134 @@
local context state line
typeset -A opt_args
+local -a _ffmpeg_argspecs
+
local BOLD=$'\e[1m'
local NORM=$'\e[m'
-_ffmpeg_compadd() {
+(( $+functions[_ffmpeg_compadd] )) || _ffmpeg_compadd() {
compadd -X "${BOLD}$1${NORM}" -q -S "$3" -a $2
}
-_ffmpeg_presets() {
+(( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() {
local presets
presets=(~/.ffmpeg/*.ffpreset(:t:r) "$FFMPEG_DATADIR"/*.ffpreset(:t:r))
_ffmpeg_compadd 'select preset' presets ''
}
-_ffmpeg_acodecs() {
+(( $+functions[_ffmpeg_acodecs] )) || _ffmpeg_acodecs() {
local acodecs
- acodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
+ acodecs=(copy ${${(M)${(f)"$(_call_program audio-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
_ffmpeg_compadd 'force audio codec (''copy'' to copy stream)' acodecs ''
}
-_ffmpeg_vcodecs() {
+(( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() {
local vcodecs
- vcodecs=(${${(M)${(f)"$(ffmpeg -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
+ vcodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
_ffmpeg_compadd 'force video codec (''copy'' to copy stream)' vcodecs ''
}
-_ffmpeg_formats() {
+(( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() {
local formats
- formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(ffmpeg -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
+ formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
_ffmpeg_compadd 'force format' formats ''
}
-_ffmpeg_list_pix_fmts() {
- print -l ${${(M)${(f)"$(ffmpeg -pix_fmts 2>/dev/null)"}:#[I.]*}//(#b)??????([^[:space:]]##)*/$match[1]}
+(( $+functions[_ffmpeg_list_pix_fmts] )) || _ffmpeg_list_pix_fmts() {
+ print -l ${${(M)${(f)"$(_call_program pix-fmts $words[1] -pix_fmts 2>/dev/null)"}:#[I.]*}//(#b)??????([^[:space:]]##)*/$match[1]}
}
-_ffmpeg_pix_fmts() {
+(( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() {
local pix_fmts
pix_fmts=($(_ffmpeg_list_pix_fmts))
_ffmpeg_compadd 'set pixel format' pix_fmts ''
}
-_ffmpeg_bsfs() {
+(( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() {
local bsfs
- bsfs=(${${(f)"$(ffmpeg -bsfs 2>/dev/null)"}:#*:})
+ bsfs=(${${(f)"$(_call_program bsfs $words[1] -bsfs 2>/dev/null)"}:#*:})
_ffmpeg_compadd 'set bitstream filter' bsfs ''
}
-_ffmpeg_argspecs="$(ffmpeg -h 2>/dev/null | perl -e '
-my $lastopt;
-my $lastopt_description;
-my $lastopt_takesargs;
-my @lastopt_values;
-while (<>) {
- if (/^(-\S+)\s+(\S.+)$/) {
- print_opt();
- $lastopt = $1;
- $lastopt_description = $2;
- if ($lastopt_description =~ /<\w+>/) {
- $lastopt_description =~ s/<.*?>\s+//;
- $lastopt_description =~ s/\S{5} ?//;
- $lastopt_description = $lastopt if not $lastopt_description;
- escape_str($lastopt_description);
- } elsif ($lastopt_description =~ /^(\S+)\s\s+/) {
- my $example = $1;
- $lastopt_description =~ s/^\S+\s\s+//;
- escape_str($example);
- escape_str($lastopt_description);
- if ($example eq q(filename)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(:$lastopt_description:_files);
- } elsif ($lastopt =~ /^-[asv]pre$/) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_presets);
- } elsif ($lastopt eq q(-acodec)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_acodecs);
- } elsif ($lastopt eq q(-vcodec)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_vcodecs);
- } elsif ($lastopt eq q(-f)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_formats);
- } elsif ($lastopt eq q(-pix_fmt)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_pix_fmts);
- } elsif ($example eq q(bitstream_filter)) {
- $lastopt_takesargs = 0;
- $lastopt .= qq(: :_ffmpeg_bsfs);
- } else {
- $lastopt_takesargs = 1;
- $lastopt_description .= qq{ ($example)};
- }
- } else {
- $lastopt_takesargs = 0;
- if ($lastopt eq q(-vfilters)) {
- $lastopt .= qq(: :->vfilters);
- }
- }
- @lastopt_values = ();
- } elsif (/^ (\S+)/) {
- $lastopt_takesargs = 1;
- push @lastopt_values, $1;
- }
-}
-print_opt();
-exit;
-
-sub escape_str {
- $_[0] =~ s/:/\\:/g;
-}
-
-sub print_opt {
- return if not $lastopt;
+{
+ local lastopt
+ local lastopt_description
+ local lastopt_takesargs
+ local -a lastopt_values
- print qq($lastopt);
- if (!$lastopt_takesargs) {