Set stream codecs properly

This commit is contained in:
Dan Jones 2022-08-29 10:02:04 -05:00
commit e869ff2a59
4 changed files with 149 additions and 11 deletions

View file

@ -43,7 +43,45 @@ class Stream
return $this;
}
// @todo add hlper methods for setting codec
public function video(string $codec, callable $callback = null): static
{
$this->setCodec(new Format\DefaultVideo($codec));
if ($callback) {
return $this->editCodec($callback);
}
return $this;
}
public function audio(string $codec, callable $callback = null): static
{
$this->setCodec(new Format\DefaultAudio($codec));
if ($callback) {
return $this->editCodec($callback);
}
return $this;
}
public function subtitle(string $codec, callable $callback = null): static
{
$this->setCodec(new Format\DefaultSubtitle($codec));
if ($callback) {
return $this->editCodec($callback);
}
return $this;
}
public function copy(): static
{
return $this->setCodec(new Format\Copy());
}
public function getCodec(): FormatInterface
{
@ -61,21 +99,15 @@ class Stream
{
if ($this->codec instanceof VideoInterface) {
$this->parseVideo();
}
if ($this->codec instanceof AudioInterface) {
} elseif ($this->codec instanceof AudioInterface) {
$this->parseAudio();
}
if ($this->codec instanceof Format\SubtitleInterface) {
} elseif ($this->codec instanceof Format\SubtitleInterface) {
$this->parseSubtitle();
}
if ($this->codec instanceof Format\Copy) {
} elseif ($this->codec instanceof Format\Copy) {
$this->addFlag('c', 'copy');
}
$this->parseExtras($this->codec->getExtraParameters());
$this->parseExtras($this->codec->getExtraParams());
return $this;
}