1 | <?php namespace Folour\Flavy; |
||
18 | class Flavy extends Base |
||
19 | { |
||
20 | /** |
||
21 | * Flavy version |
||
22 | */ |
||
23 | const VERSION = '1.0.2'; |
||
24 | |||
25 | /** |
||
26 | * |
||
27 | * Array of command parameters from builder |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $parameters = []; |
||
32 | |||
33 | /** |
||
34 | * |
||
35 | * Output file path |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $outputPath; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * Log path |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $logPath; |
||
48 | |||
49 | /** |
||
50 | * |
||
51 | * Array of possible methods for execute |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | private $nextContext = 'input'; |
||
56 | |||
57 | /** |
||
58 | * |
||
59 | * Flavy constructor. |
||
60 | * |
||
61 | * @param array $config |
||
62 | */ |
||
63 | public function __construct(array $config) |
||
67 | |||
68 | /** |
||
69 | * |
||
70 | * Returns array (for json format) or string (for other formats) with file information |
||
71 | * |
||
72 | * @param string $file File path |
||
73 | * @param string $format output format, supported json, xml and csv |
||
74 | * @param bool $decode decode json to array |
||
75 | * |
||
76 | * |
||
77 | * @return array|string |
||
78 | * @throws FileNotFoundException |
||
79 | */ |
||
80 | public function info($file, $format = 'json', $decode = true) |
||
96 | |||
97 | /** |
||
98 | * |
||
99 | * Create thumbnails from video |
||
100 | * |
||
101 | * @param string $file input file |
||
102 | * @param string $outputPath output file path template |
||
103 | * @param int $count thumbnails count |
||
104 | * @param int|null $interval frames interval in seconds |
||
105 | * |
||
106 | * @return bool|string |
||
107 | * @throws FileNotFoundException |
||
108 | * @throws NotWritableException |
||
109 | */ |
||
110 | public function thumbnail($file, $outputPath, $count = 1, $interval = null) |
||
134 | |||
135 | /** |
||
136 | * |
||
137 | * Set input file |
||
138 | * |
||
139 | * @param $file |
||
140 | * @return $this |
||
141 | * @throws FileNotFoundException |
||
142 | */ |
||
143 | public function from($file) |
||
155 | |||
156 | /** |
||
157 | * |
||
158 | * Set output file |
||
159 | * |
||
160 | * @param string $outputPath |
||
161 | * |
||
162 | * @return $this |
||
163 | * @throws NotWritableException |
||
164 | */ |
||
165 | public function to($outputPath) |
||
177 | |||
178 | /** |
||
179 | * |
||
180 | * Set audio codec |
||
181 | * |
||
182 | * @param string $codec |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function aCodec($codec) |
||
192 | |||
193 | /** |
||
194 | * |
||
195 | * Set video codec |
||
196 | * |
||
197 | * @param string $codec |
||
198 | * @return $this |
||
199 | */ |
||
200 | public function vCodec($codec) |
||
208 | |||
209 | /** |
||
210 | * |
||
211 | * Set audio bitrate |
||
212 | * |
||
213 | * @param int $bitrate |
||
214 | * @return $this |
||
215 | */ |
||
216 | public function aBitrate($bitrate) |
||
223 | |||
224 | /** |
||
225 | * |
||
226 | * Set video bitrate |
||
227 | * |
||
228 | * @param int $bitrate |
||
229 | * @return $this |
||
230 | */ |
||
231 | public function vBitrate($bitrate) |
||
238 | |||
239 | /** |
||
240 | * |
||
241 | * Set audio channels |
||
242 | * |
||
243 | * @param int $channels |
||
244 | * @return $this |
||
245 | */ |
||
246 | public function channels($channels) |
||
253 | |||
254 | /** |
||
255 | * |
||
256 | * Set audio sample rate |
||
257 | * |
||
258 | * @param int $rate |
||
259 | * @return $this |
||
260 | */ |
||
261 | public function sampleRate($rate) |
||
268 | |||
269 | /** |
||
270 | * |
||
271 | * Set video frame rate |
||
272 | * |
||
273 | * @param int $rate |
||
274 | * @return $this |
||
275 | */ |
||
276 | public function frameRate($rate) |
||
283 | |||
284 | /** |
||
285 | * |
||
286 | * Overwrite output file |
||
287 | * |
||
288 | * @return $this |
||
289 | */ |
||
290 | public function overwrite() |
||
297 | |||
298 | public function logTo($logPath) |
||
305 | |||
306 | /** |
||
307 | * |
||
308 | * Run a conversion process |
||
309 | * |
||
310 | * @throws Exceptions\CmdException |
||
311 | */ |
||
312 | public function run() |
||
327 | |||
328 | /** |
||
329 | * @param string $context context name |
||
330 | * |
||
331 | * @return bool |
||
332 | * @throws \BadMethodCallException |
||
333 | */ |
||
334 | private function isPossible($context) |
||
342 | } |
||
343 |