blob: 1329939cd8b70bdd18e7600abebae60351ecc2b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
#compdef ffmpeg
local curcontext="$curcontext" state line expl
typeset -A opt_args
(( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() {
local presets
presets=(~/.ffmpeg/*.ffpreset(:t:r) "$FFMPEG_DATADIR"/*.ffpreset(:t:r))
_wanted ffmpeg-presets expl 'preset' compadd -a presets
}
(( $+functions[_ffmpeg_acodecs] )) || _ffmpeg_acodecs() {
local acodecs
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]})
_wanted ffmpeg-audio-codecs expl 'force audio codec (''copy'' to copy stream)' compadd -a acodecs
}
(( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() {
local vcodecs
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]})
_wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs
}
(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() {
local scodecs
scodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
_wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a scodecs
}
(( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() {
local formats
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]}}}})
_wanted ffmpeg-formats expl 'force format' compadd -a formats
}
(( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() {
local pix_fmts
_wanted ffmpeg-pix-fmts expl 'pixel format' compadd "$@" - \
${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
}
(( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() {
local bsfs
bsfs=(${${(f)"$(_call_program bsfs $words[1] -bsfs 2>/dev/null)"}:#*:})
_wanted ffmpeg-bsfs expl 'set bitstream filter' compadd -a bsfs
}
typeset -A _ffmpeg_flags
(( $+functions[_ffmpeg_flag_options] )) || _ffmpeg_flag_options() {
local expl
_wanted options expl 'flag' compadd -S '' -- {-,+}${^flag_options}
}
(( $+functions[_ffmpeg_more_flag_options] )) || _ffmpeg_more_flag_options() {
compset -p $1 && _ffmpeg_flag_options
}
(( $+functions[_ffmpeg_new_flag_options] )) || _ffmpeg_new_flag_options() {
compset -P '*' && _ffmpeg_flag_options
}
(( $+functions[_ffmpeg_flags] )) || _ffmpeg_flags() {
local -a flag_options
eval "flag_options=(\${=_ffmpeg_flags[$1]})"
local match mbegin mend
integer ret=1
if [[ $PREFIX = (#b)(*)[-+]([^-+]#) ]]; then
if [[ -n ${flag_options[(R)$match[2]]} ]]; then
_ffmpeg_new_flag_options && ret=0
fi
if [[ -n ${flag_options[(R)$match[2]?*]} ]]; then
_ffmpeg_more_flag_options ${#match[1]} && ret=0
fi
else
_ffmpeg_flag_options && ret=0
fi
return ret
}
(( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() {
if (( lastopt_takesargs )); then
lastopt+=":$lastopt_description:"
if (( $#lastopt_values )); then
if [[ $lastopt_type == flags ]]; then
lastopt="*$lastopt"
flagtype=${${lastopt%%:*}#-}
lastopt+="->$flagtype"
_ffmpeg_flags[$flagtype]="${lastopt_values[*]}"
else
lastopt+="(${lastopt_values[*]})"
fi
fi
fi
_ffmpeg_argspecs+=$lastopt
}
local -a _ffmpeg_argspecs
{
local lastopt REPLY
local lastopt_description
local lastopt_takesargs
local lastopt_type
local -a lastopt_values
_call_program options $words[1] -h 2>/dev/null | while IFS=$'\n' read -r; do
if [[ $REPLY == -* ]]; then
[[ -n $lastopt ]] && _ffmpeg_register_lastopt_values
lastopt=${REPLY%%[[:space:]]*}
lastopt_description=${REPLY##-[^[:space:]]##[[:space:]]##}
if [[ $lastopt_description == (#b)'<'(?##)'>'* ]]; then
lastopt_type=$match[1]
lastopt_description=${lastopt_description##<[^[:space:]]##>[[:space:]]##[^[:space:]]##[[:space:]]#}
if [[ -z $lastopt_description ]]; then
lastopt_description=$lastopt
fi
lastopt_description=${lastopt_description//:/\\:}
elif [[ $lastopt_description == [^[:space:]]##[[:space:]][[:space:]]* ]]; then
local example=${lastopt_description%% *}
example=${example//:/\\:}
lastopt_description=${lastopt_description##[^[:space:]]##[[:space:]]##}
lastopt_description=${lastopt_description//:/\\:}
if [[ $example == filename ]]; then
lastopt_takesargs=0
lastopt+=":$lastopt_description:_files"
elif [[ $lastopt == -[asv]pre ]]; then
lastopt_takesargs=0
lastopt="*$lastopt"
lastopt+=": :_ffmpeg_presets"
elif [[ $lastopt == -acodec ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_acodecs"
elif [[ $lastopt == -vcodec ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_vcodecs"
elif [[ $lastopt == -scodec ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_scodecs"
elif [[ $lastopt == -f ]]; then
lastopt_takesargs=0
lastopt="*$lastopt"
lastopt+=": :_ffmpeg_formats"
elif [[ $lastopt == -pix_fmt ]]; then
lastopt_takesargs=0
lastopt="*$lastopt"
lastopt+=":set pixel format:_ffmpeg_pix_fmts"
elif [[ $example == bitstream_filter ]]; then
lastopt_takesargs=0
lastopt+=": :_ffmpeg_bsfs"
else
lastopt_takesargs=1
lastopt_description+=" ($example)"
fi
else
lastopt_takesargs=0
if [[ $lastopt == -vfilters ]]; then
lastopt+=": :->vfilters"
fi
fi
lastopt_values=()
elif [[ $REPLY == ' '* ]]; then
REPLY=${REPLY##[[:space:]]##}
REPLY=${REPLY%%[[:space:]]##*}
lastopt_takesargs=1
lastopt_values+=$REPLY
fi
done
[[ -n $lastopt ]] && _ffmpeg_register_lastopt_values
}
_arguments -C -S \
"${_ffmpeg_argspecs[@]}" \
'*:output file:_files' \
&& return
[[ "$state" == "vfilters" ]] &&
_values -s , -S = 'video filter' \
'aspect:set aspect ratio (rational number X\:Y or decimal number):' \
'crop:crop input video (x\:y\:width\:height):' \
'format: :_sequence -s : _ffmpeg_pix_fmts' \
'noformat: :_sequence -s : _ffmpeg_pix_fmts' \
'null' \
'pad:add pads to the input image (width\:height\:x\:y\:color_string):' \
'pixelaspect:set pixel aspect ratio (rational number X\:Y or decimal number):' \
'scale:scale input video (width\:height):' \
'slicify:output slice height ("random" or a number of pixels):' \
'unsharp:luma_x\:luma_y\:luma_amount\:chroma_x\:chroma_y\:chroma_amount:' \
'vflip' \
'buffer' \
'nullsrc' \
'nullsink' \
&& return
[[ -n $state && -n $_ffmpeg_flags[$state] ]] &&
_ffmpeg_flags $state && return
return 1
|