Skip to content

Commit

Permalink
fixes #61
Browse files Browse the repository at this point in the history
  • Loading branch information
aminyazdanpanah committed Aug 1, 2020
1 parent d4f1a51 commit a4a9053
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
9 changes: 7 additions & 2 deletions src/CommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ class CommandBuilder
/** @var \FFMpeg\Driver\FFMpegDriver */
private $driver;

/** @var VideoInterface */
private $format;

/**
* CommandBuilder constructor.
* @param Media $media
* @param VideoInterface $format
*/
public function __construct(Media $media)
public function __construct(Media $media, VideoInterface $format)
{
$this->media = $media;
$this->filters = $this->media->getFiltersCollection();
$this->driver = $this->media->getFFMpegDriver();
$this->format = $format;
}

/**
Expand Down Expand Up @@ -68,6 +73,6 @@ private function getInputOptions(): array
$path = $this->media->getPathfile();
$input_options = Utiles::arrayToFFmpegOpt($this->media->getInputOptions());

return array_merge($input_options, ['-y', '-i', $path]);
return array_merge($input_options, $this->format->getInitialParameters() ?? [], ['-y', '-i', $path]);
}
}
2 changes: 1 addition & 1 deletion src/Filters/FormatFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function getFormatOptions(VideoInterface $format): array
]);

$options = Utiles::arrayToFFmpegOpt(
array_merge($format->getInitialParameters() ?? [], $format->getAdditionalParameters() ?? [])
array_merge($format->getAdditionalParameters() ?? [])
);

return array_merge($basic, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Format/HEVC.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $video_codec = 'libx265', string $audio_codec
* see https://ffmpeg.org/ffmpeg-codecs.html#Options-29 for more information about options
*/
if ($default_init_opts) {
$this->setInitialParameters([
$this->setAdditionalParameters([
'keyint_min' => 25,
'g' => 250,
'sc_threshold' => 40
Expand Down
2 changes: 1 addition & 1 deletion src/Format/X264.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct($video_codec = 'libx264', string $audio_codec = 'aac
* return array
*/
if ($default_init_opts) {
$this->setInitialParameters([
$this->setAdditionalParameters([
'bf' => 1,
'keyint_min' => 25,
'g' => 250,
Expand Down
2 changes: 1 addition & 1 deletion src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private function run(): void
{
$this->media->addFilter($this->getFilter());

$commands = (new CommandBuilder($this->media))->build($this->getFormat(), $this->getPath());
$commands = (new CommandBuilder($this->media, $this->getFormat()))->build($this->getFormat(), $this->getPath());
$pass = $this->format->getPasses();
$listeners = $this->format->createProgressListener($this->media->baseMedia(), $this->media->getFFProbe(), 1, $pass);

Expand Down

0 comments on commit a4a9053

Please sign in to comment.