1 | <?php namespace Folour\Flavy\Extensions; |
||
13 | abstract class Commands |
||
14 | { |
||
15 | /** |
||
16 | * |
||
17 | * Commands for get needed information from stdout |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | |||
22 | protected $_cmd = [ |
||
23 | 'get_formats' => [ |
||
24 | 'regex' => '/(?P<mux>(D\s|\sE|DE))\s(?P<format>\S{3,11})\s/', |
||
25 | 'cmd' => '%s -formats', |
||
26 | 'returns' => ['format', 'mux'] |
||
27 | ], |
||
28 | |||
29 | 'get_encoders' => [ |
||
30 | 'regex' => '/(?P<type>(A|V)).....\s(?P<format>\S{3,20})\s/', |
||
31 | 'cmd' => '%s -encoders', |
||
32 | 'returns' => ['type', 'format'] |
||
33 | ], |
||
34 | |||
35 | 'get_decoders' => [ |
||
36 | 'regex' => '/(?P<type>(A|V)).....\s(?P<format>\S{3,20})\s/', |
||
37 | 'cmd' => '%s -decoders', |
||
38 | 'returns' => ['type', 'format'] |
||
39 | ], |
||
40 | |||
41 | 'get_file_info' => [ |
||
42 | 'cmd' => '%s -v quiet -print_format %s -show_format -show_streams -pretty -i "%s" 2>&1' |
||
43 | ], |
||
44 | |||
45 | 'get_thumbnails' => [ |
||
46 | 'cmd' => '%s -i "%s" -vf fps=1/%d -vframes %d "%s"' |
||
47 | ] |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * |
||
52 | * Run command and return output |
||
53 | * |
||
54 | * @param string $cmd shell command or key of pre-defined commands |
||
55 | * @param array $args Command arguments |
||
56 | * |
||
57 | * @return string|bool Command output |
||
58 | * @throws CmdException |
||
59 | */ |
||
60 | protected function runCmd($cmd, $args = []) |
||
82 | } |