Total Complexity | 3 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
20 | class MediaInfo |
||
21 | { |
||
22 | /** |
||
23 | * @param string|null $binary |
||
24 | * @param string $path |
||
25 | * @return StreamCollection |
||
26 | * @throws \Streaming\Exception\Exception |
||
27 | */ |
||
28 | public static function initialize(string $path, string $binary = 'mediainfo'): StreamCollection |
||
29 | { |
||
30 | $media_info = json_decode(static::getJsonOutPut(new Process($binary), $path), true); |
||
31 | |||
32 | $streams = $media_info["media"]["track"]; |
||
33 | $stream_collection = []; |
||
34 | |||
35 | foreach ($streams as $stream){ |
||
36 | $stream_collection[] = new Stream($stream); |
||
37 | } |
||
38 | |||
39 | return new StreamCollection($stream_collection); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param Process $media_info |
||
44 | * @param string $path |
||
45 | * @return string |
||
46 | * @throws \Streaming\Exception\Exception |
||
47 | */ |
||
48 | private static function getJsonOutPut(Process $media_info, string $path): string |
||
51 | } |
||
52 | } |