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 stream(callable $callback = null): Stream|static { $stream = new Stream($this); if (!$callback) { return $stream; } $callback($stream); $this->saveStream($stream); return $this; } public function saveStream(Stream $stream): static { $this->streams[] = $stream; 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; } }