media = $media; } public function saveMap(): MappableMedia { $this->media->saveMap($this); return $this->media; } public function saveAs(string $path): static { $this->path = $path; 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; } }