|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Soluble\MediaTools\Video\Info; |
|
6
|
|
|
|
|
7
|
|
|
use Psr\Log\LoggerInterface; |
|
8
|
|
|
use Soluble\MediaTools\Video\Info\Util\MetadataTypeSafeReader; |
|
9
|
|
|
|
|
10
|
|
|
class SubtitleStream implements SubtitleStreamInterface |
|
11
|
|
|
{ |
|
12
|
|
|
/** @var array<string, mixed> */ |
|
13
|
|
|
private $streamMetadata; |
|
14
|
|
|
|
|
15
|
|
|
/** @var MetadataTypeSafeReader */ |
|
16
|
|
|
private $tsReader; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @param array<string, mixed> $streamMetadata |
|
20
|
|
|
*/ |
|
21
|
4 |
|
public function __construct(array $streamMetadata, ?LoggerInterface $logger = null) |
|
22
|
|
|
{ |
|
23
|
4 |
|
$this->streamMetadata = $streamMetadata; |
|
24
|
4 |
|
$this->tsReader = new MetadataTypeSafeReader($streamMetadata, $logger); |
|
25
|
4 |
|
} |
|
26
|
|
|
|
|
27
|
2 |
|
public function getIndex(): int |
|
28
|
|
|
{ |
|
29
|
2 |
|
return $this->tsReader->getKeyIntValue('index'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
2 |
|
public function getCodecType(): string |
|
33
|
|
|
{ |
|
34
|
2 |
|
return $this->tsReader->getKeyStringValue('codec_type'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
2 |
|
public function getCodecName(): string |
|
38
|
|
|
{ |
|
39
|
2 |
|
return $this->tsReader->getKeyStringValue('codec_name'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
1 |
|
public function getCodecLongName(): ?string |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->tsReader->getKeyStringOrNullValue('codec_long_name'); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
1 |
|
public function getCodecTimeBase(): ?string |
|
48
|
|
|
{ |
|
49
|
1 |
|
return $this->tsReader->getKeyStringOrNullValue('codec_time_base'); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
1 |
|
public function getCodecTagString(): ?string |
|
53
|
|
|
{ |
|
54
|
1 |
|
return $this->tsReader->getKeyStringOrNullValue('codec_tag_string'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
public function getStartTime(): ?float |
|
58
|
|
|
{ |
|
59
|
1 |
|
return $this->tsReader->getKeyFloatOrNullValue('start_time'); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function getTimeBase(): ?string |
|
63
|
|
|
{ |
|
64
|
1 |
|
return $this->tsReader->getKeyStringOrNullValue('time_base'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Return underlying ffprobe json metadata. |
|
69
|
|
|
* |
|
70
|
|
|
* @return array<string, mixed> |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function getStreamMetadata(): array |
|
73
|
|
|
{ |
|
74
|
1 |
|
return $this->streamMetadata; |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|