🚧 Add maps to command
This commit is contained in:
parent
30c2ab4d3b
commit
90906a517d
2 changed files with 35 additions and 3 deletions
30
src/Map.php
30
src/Map.php
|
|
@ -6,6 +6,9 @@ class Map
|
|||
{
|
||||
protected MappableMedia $media;
|
||||
protected string $path;
|
||||
/** @var Stream[] */
|
||||
protected array $streams = [];
|
||||
protected array $metadata = [];
|
||||
|
||||
public function __construct(MappableMedia $media)
|
||||
{
|
||||
|
|
@ -25,4 +28,31 @@ class Map
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addMetadata(array|string $keyOrData, string $value = null): static
|
||||
{
|
||||
if (is_array($keyOrData)) {
|
||||
array_walk($keyOrData, fn($v, $k) => $this->addMetadata($k, $v));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
$this->metadata[$keyOrData] = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildCommand(): array
|
||||
{
|
||||
$commands = [];
|
||||
foreach ($this->streams as $idx => $stream) {
|
||||
array_push($commands, ...$stream->buildCommand($idx));
|
||||
}
|
||||
foreach ($this->metadata as $k => $v) {
|
||||
array_push($commands, '-metadata', "{$k}={$v}");
|
||||
}
|
||||
$commands[] = $this->path;
|
||||
|
||||
return $commands;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,9 +322,11 @@ class MappableMedia extends AbstractMediaType
|
|||
*/
|
||||
protected function buildMaps(array $maps): array
|
||||
{
|
||||
$out = [];
|
||||
// @todo
|
||||
$commands = [];
|
||||
foreach($maps as $map) {
|
||||
array_push($commands, ...$map->buildCommand());
|
||||
}
|
||||
|
||||
return $out;
|
||||
return $commands;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue