-
Notifications
You must be signed in to change notification settings - Fork 873
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #700 from CaliforniaMountainSnake/master
ComplexMedia, -filter_complex and -map features
- Loading branch information
Showing
20 changed files
with
1,875 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace FFMpeg\Filters\AdvancedMedia; | ||
|
||
use FFMpeg\Media\AdvancedMedia; | ||
|
||
/** | ||
* @see https://ffmpeg.org/ffmpeg-filters.html#anullsrc | ||
*/ | ||
class ANullSrcFilter extends AbstractComplexFilter | ||
{ | ||
/** | ||
* @var string|null | ||
*/ | ||
private $channelLayout; | ||
|
||
/** | ||
* @var int|null | ||
*/ | ||
private $sampleRate; | ||
|
||
/** | ||
* @var int|null | ||
*/ | ||
private $nbSamples; | ||
|
||
/** | ||
* ANullSrcComplexFilter constructor. | ||
* | ||
* @param string|null $channelLayout | ||
* @param int|null $sampleRate | ||
* @param int|null $nbSamples | ||
* @param int $priority | ||
*/ | ||
public function __construct( | ||
$channelLayout = null, | ||
$sampleRate = null, | ||
$nbSamples = null, | ||
$priority = 0 | ||
) { | ||
parent::__construct($priority); | ||
$this->channelLayout = $channelLayout; | ||
$this->sampleRate = $sampleRate; | ||
$this->nbSamples = $nbSamples; | ||
} | ||
|
||
/** | ||
* Get name of the filter. | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return 'anullsrc'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function applyComplex(AdvancedMedia $media) | ||
{ | ||
return array( | ||
'-filter_complex', | ||
$this->getName() . $this->buildFilterOptions(array( | ||
'channel_layout' => $this->channelLayout, | ||
'sample_rate' => $this->sampleRate, | ||
'nb_samples' => $this->nbSamples, | ||
)) | ||
); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/FFMpeg/Filters/AdvancedMedia/AbstractComplexFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace FFMpeg\Filters\AdvancedMedia; | ||
|
||
abstract class AbstractComplexFilter implements ComplexCompatibleFilter | ||
{ | ||
/** | ||
* @var int | ||
*/ | ||
protected $priority; | ||
|
||
/** | ||
* AbstractComplexFilter constructor. | ||
* | ||
* @param int $priority | ||
*/ | ||
public function __construct($priority = 0) | ||
{ | ||
$this->priority = $priority; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPriority() | ||
{ | ||
return $this->priority; | ||
} | ||
|
||
/** | ||
* Get minimal version of ffmpeg starting with which this filter is supported. | ||
* | ||
* @return string | ||
*/ | ||
public function getMinimalFFMpegVersion() | ||
{ | ||
return '0.3'; | ||
} | ||
|
||
/** | ||
* Generate the config of the filter. | ||
* | ||
* @param array $params Associative array of filter options. The options may be null. | ||
* | ||
* @return string The string of the form "=name1=value1:name2=value2" or empty string. | ||
*/ | ||
protected function buildFilterOptions(array $params) | ||
{ | ||
$config = array(); | ||
foreach ($params as $paramName => $paramValue) { | ||
if ($paramValue !== null) { | ||
$config[] = $paramName . '=' . $paramValue; | ||
} | ||
} | ||
|
||
if (!empty($config)) { | ||
return '=' . implode(':', $config); | ||
} | ||
|
||
return ''; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/FFMpeg/Filters/AdvancedMedia/ComplexCompatibleFilter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace FFMpeg\Filters\AdvancedMedia; | ||
|
||
use FFMpeg\Filters\FilterInterface; | ||
use FFMpeg\Media\AdvancedMedia; | ||
|
||
/** | ||
* A filter that can be used inside "-filter_complex" option. | ||
*/ | ||
interface ComplexCompatibleFilter extends FilterInterface | ||
{ | ||
/** | ||
* Get name of the filter. | ||
* | ||
* @return string | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* Get minimal version of ffmpeg starting with which this filter is supported. | ||
* | ||
* @return string | ||
*/ | ||
public function getMinimalFFMpegVersion(); | ||
|
||
/** | ||
* Apply the complex filter to the given media. | ||
* | ||
* @param AdvancedMedia $media | ||
* | ||
* @return string[] An array of arguments. | ||
*/ | ||
public function applyComplex(AdvancedMedia $media); | ||
} |
Oops, something went wrong.