🚧 Add maps to command

This commit is contained in:
Dan Jones 2022-08-21 22:42:02 -05:00
commit 90906a517d
2 changed files with 35 additions and 3 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}