1 | <?php namespace Folour\Flavy\Extensions; |
||
11 | class Base extends Commands |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * |
||
16 | * Flavy config |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $config = [ |
||
21 | 'ffmpeg_path' => 'ffmpeg', |
||
22 | 'ffprobe_path' => 'ffprobe' |
||
23 | ]; |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | * FFmpeg information |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | private $_info = [ |
||
32 | 'formats' => [], |
||
33 | |||
34 | 'encoders' => [ |
||
35 | 'audio' => [], |
||
36 | 'video' => [] |
||
37 | ], |
||
38 | |||
39 | 'decoders' => [ |
||
40 | 'audio' => [], |
||
41 | 'video' => [] |
||
42 | ] |
||
43 | ]; |
||
44 | |||
45 | /** |
||
46 | * Base constructor. |
||
47 | * |
||
48 | * @param array $config |
||
49 | */ |
||
50 | 12 | public function __construct(array $config) |
|
54 | |||
55 | /** |
||
56 | * |
||
57 | * Returns array of supported formats |
||
58 | * |
||
59 | * @throws CmdException |
||
60 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
61 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
62 | * @return array |
||
63 | */ |
||
64 | 1 | public function formats() |
|
75 | |||
76 | /** |
||
77 | * |
||
78 | * Returns array of audio and video encoders |
||
79 | * [ |
||
80 | * 'audio' => [], |
||
81 | * 'video' => [] |
||
82 | * ] |
||
83 | * |
||
84 | * @throws CmdException |
||
85 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
86 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
87 | * @return array |
||
88 | */ |
||
89 | 1 | public function encoders() |
|
93 | |||
94 | /** |
||
95 | * @param bool $encoders |
||
96 | * @return array |
||
97 | * @throws CmdException |
||
98 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
99 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
100 | */ |
||
101 | 1 | private function infoPrepare($encoders = false) |
|
111 | |||
112 | /** |
||
113 | * |
||
114 | * Returns array of audio and video decoders |
||
115 | * [ |
||
116 | * 'audio' => [], |
||
117 | * 'video' => [] |
||
118 | * ] |
||
119 | * |
||
120 | * @throws CmdException |
||
121 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
122 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
123 | * @return array |
||
124 | */ |
||
125 | 1 | public function decoders() |
|
129 | |||
130 | /** |
||
131 | * @param string $format |
||
132 | * @return bool |
||
133 | * @throws CmdException |
||
134 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
135 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
136 | */ |
||
137 | 1 | public function canEncode($format = 'encoder') |
|
141 | |||
142 | /** |
||
143 | * @param string $format |
||
144 | * @return bool |
||
145 | * @throws CmdException |
||
146 | * @throws \Symfony\Component\Process\Exception\RuntimeException |
||
147 | * @throws \Symfony\Component\Process\Exception\LogicException |
||
148 | */ |
||
149 | 1 | public function canDecode($format = 'decoder') |
|
153 | |||
154 | //Helpers |
||
155 | |||
156 | /** |
||
157 | * @param int|string $time timestamp for conversion |
||
158 | * @param bool $isDate mode flag, if true - $time converts from hh::mm:ss string to seconds, else conversely |
||
159 | * @return string |
||
160 | */ |
||
161 | 1 | protected function timestamp($time, $isDate = true) |
|
171 | } |
||
172 |