Add copy format

This commit is contained in:
Dan Jones 2022-08-26 17:00:48 -05:00
commit 9abcb9ec1b
3 changed files with 25 additions and 10 deletions

18
src/Format/Copy.php Normal file
View file

@ -0,0 +1,18 @@
<?php
namespace Danjones\FFMpeg\Format;
use FFMpeg\Format\FormatInterface;
class Copy implements FormatInterface
{
public function getPasses()
{
return 1;
}
public function getExtraParams()
{
return [];
}
}

View file

@ -2,9 +2,7 @@
namespace Danjones\FFMpeg\Format;
use FFMpeg\Format\AudioInterface;
use FFMpeg\Format\FormatInterface;
use FFMpeg\Format\ProgressListener\AbstractProgressListener;
interface SubtitleInterface extends FormatInterface
{

View file

@ -60,18 +60,21 @@ class Stream
protected function parseCodec(): static
{
if ($this->codec instanceof VideoInterface) {
return $this->parseVideo();
$this->parseVideo();
}
if ($this->codec instanceof AudioInterface) {
return $this->parseAudio();
$this->parseAudio();
}
if ($this->codec instanceof Format\SubtitleInterface) {
return $this->parseSubtitle();
$this->parseSubtitle();
}
if ($this->codec instanceof Format\Copy) {
$this->addFlag('c', 'copy');
}
$this->addFlag('c', 'copy');
$this->parseExtras($this->codec->getExtraParameters());
return $this;
@ -82,7 +85,6 @@ class Stream
if (null !== ($codec = $this->codec->getSubtitleCodec())) {
$this->addFlag('c', $codec);
}
$this->parseExtras($this->codec->getExtraParameters());
return $this;
}
@ -100,7 +102,6 @@ class Stream
if (null !== ($channels = $this->codec->getAudioChannels())) {
$this->addFlag('ac', $channels);
}
$this->parseExtras($this->codec->getExtraParameters());
return $this;
}
@ -115,9 +116,7 @@ class Stream
$this->addFlag('b', "{$kb}k");
}
// If the user passed some additional format parameters.
$this->parseExtras($this->codec->getAdditionalParameters());
$this->parseExtras($this->codec->getExtraParameters());
return $this;
}