✨ Listeners
This commit is contained in:
parent
aeb73dba94
commit
18c3cbb284
3 changed files with 47 additions and 60 deletions
19
src/Map.php
19
src/Map.php
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Danjones\FFMpeg;
|
||||
|
||||
use FFMpeg\Format\ProgressableInterface;
|
||||
use FFMpeg\Format\ProgressListener\AbstractProgressListener;
|
||||
|
||||
class Map
|
||||
{
|
||||
use Traits\HasMetadata;
|
||||
|
|
@ -10,6 +13,8 @@ class Map
|
|||
protected string $path;
|
||||
/** @var Stream[] */
|
||||
protected array $streams = [];
|
||||
/** @var AbstractProgressListener[] */
|
||||
protected array $listeners = [];
|
||||
|
||||
public function __construct(MappableMedia $media)
|
||||
{
|
||||
|
|
@ -46,10 +51,24 @@ class Map
|
|||
public function saveStream(Stream $stream): static
|
||||
{
|
||||
$this->streams[] = $stream;
|
||||
$format = $stream->getCodec();
|
||||
if ($format instanceof ProgressableInterface) {
|
||||
$listener = $format->createProgressListener(
|
||||
$this->media,
|
||||
$this->media->getFFProbe(),
|
||||
1, 1, 0
|
||||
);
|
||||
$this->listeners = array_merge($this->listeners, $listener);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getListeners(): array
|
||||
{
|
||||
return $this->listeners;
|
||||
}
|
||||
|
||||
public function buildCommand(): array
|
||||
{
|
||||
$commands = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue