|
19 | 19 |
|
20 | 20 | """ |
21 | 21 |
|
22 | | -import logging, re, shlex |
| 22 | +import logging, re |
23 | 23 | from os import path, devnull |
24 | 24 | from threading import Thread |
25 | 25 | import subprocess as sp |
@@ -182,52 +182,6 @@ def iswritable(f): |
182 | 182 | return sp_run(args, stdin=inpipe, stdout=outpipe, stderr=errpipe, **sp_kwargs) |
183 | 183 |
|
184 | 184 |
|
185 | | -def _exec(args, **other_run_args): |
186 | | - '''just run ffmpeg without bells-n-whistles |
187 | | - |
188 | | - :param args: FFmpeg command arguments without `ffmpeg` |
189 | | - :type args: str or Sequence[str] |
190 | | - :param **other_run_args: subprocess.run() options |
191 | | - :type **other_run_args: dict |
192 | | - ''' |
193 | | - if isinstance(args, str): |
194 | | - args = shlex.split(args) |
195 | | - return sp.run((get_ffmpeg(), *args), **other_run_args) |
196 | | - |
197 | | - |
198 | | -def versions(): |
199 | | - """Get FFmpeg version and configuration information |
200 | | -
|
201 | | - :return: versions of ffmpeg and its av libraries as well as build configuration |
202 | | - :rtype: dict |
203 | | -
|
204 | | - ================== ==== ========================================= |
205 | | - key type description |
206 | | - ================== ==== ========================================= |
207 | | - 'version' str FFmpeg version |
208 | | - 'configuration' list list of build configuration options |
209 | | - 'library_versions' dict version numbers of dependent av libraries |
210 | | - ================== ==== ========================================= |
211 | | -
|
212 | | - """ |
213 | | - s = _exec( |
214 | | - ["-version"], stdout=PIPE, universal_newlines=True, encoding="utf-8" |
215 | | - ).stdout.splitlines() |
216 | | - v = dict(version=re.match(r"ffmpeg version (\S+)", s[0])[1]) |
217 | | - i = 2 if s[1].startswith("built with") else 1 |
218 | | - if s[i].startswith("configuration:"): |
219 | | - v["configuration"] = sorted([m[1] for m in re.finditer(r"\s--(\S+)", s[i])]) |
220 | | - i += 1 |
221 | | - lv = None |
222 | | - for l in s[i:]: |
223 | | - m = re.match(r"(\S+)\s+(.+?) /", l) |
224 | | - if m: |
225 | | - if lv is None: |
226 | | - lv = v["library_versions"] = {} |
227 | | - lv[m[1]] = m[2].replace(" ", "") |
228 | | - return v |
229 | | - |
230 | | - |
231 | 185 | def monitor_process(proc, on_exit=None): |
232 | 186 | """thread function to monitor subprocess termination |
233 | 187 |
|
|
0 commit comments