ComplexMedia has been renamed to the AdvancedMedia.
This commit is contained in:
parent
4469847d46
commit
0d3bed21a7
19 changed files with 150 additions and 144 deletions
30
README.md
30
README.md
|
|
@ -520,22 +520,22 @@ $video
|
||||||
|
|
||||||
More details about concatenation in FFMPEG can be found [here](https://trac.ffmpeg.org/wiki/Concatenate), [here](https://ffmpeg.org/ffmpeg-formats.html#concat-1) and [here](https://ffmpeg.org/ffmpeg.html#Stream-copy).
|
More details about concatenation in FFMPEG can be found [here](https://trac.ffmpeg.org/wiki/Concatenate), [here](https://ffmpeg.org/ffmpeg-formats.html#concat-1) and [here](https://ffmpeg.org/ffmpeg.html#Stream-copy).
|
||||||
|
|
||||||
### ComplexMedia
|
### AdvancedMedia
|
||||||
ComplexMedia may have multiple inputs and multiple outputs.
|
AdvancedMedia may have multiple inputs and multiple outputs.
|
||||||
|
|
||||||
This class has been developed primarily to use with `-filter_complex`.
|
This class has been developed primarily to use with `-filter_complex`.
|
||||||
|
|
||||||
So, its `filters()` method accepts only filters that can be used inside `-filter_complex` command.
|
So, its `filters()` method accepts only filters that can be used inside `-filter_complex` command.
|
||||||
ComplexMedia already contains some built-in filters.
|
AdvancedMedia already contains some built-in filters.
|
||||||
|
|
||||||
#### Base usage
|
#### Base usage
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$complexMedia = $ffmpeg->openComplex(array('video_1.mp4', 'video_2.mp4'));
|
$advancedMedia = $ffmpeg->openAdvanced(array('video_1.mp4', 'video_2.mp4'));
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->custom('[0:v][1:v]', 'hstack', '[v]');
|
->custom('[0:v][1:v]', 'hstack', '[v]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a', '[v]'), new X264('aac', 'libx264'), 'output.mp4')
|
->map(array('0:a', '[v]'), new X264('aac', 'libx264'), 'output.mp4')
|
||||||
->save();
|
->save();
|
||||||
```
|
```
|
||||||
|
|
@ -545,7 +545,7 @@ This code takes 2 input videos, stacks they horizontally in 1 output video and a
|
||||||
|
|
||||||
|
|
||||||
#### Complicated example
|
#### Complicated example
|
||||||
A more difficult example of possibilities of the ComplexMedia. Consider all input videos already have the same resolution and duration. ("xstack" filter has been added in the 4.1 version of the ffmpeg).
|
A more difficult example of possibilities of the AdvancedMedia. Consider all input videos already have the same resolution and duration. ("xstack" filter has been added in the 4.1 version of the ffmpeg).
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$inputs = array(
|
$inputs = array(
|
||||||
|
|
@ -555,14 +555,14 @@ $inputs = array(
|
||||||
'video_4.mp4',
|
'video_4.mp4',
|
||||||
);
|
);
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->custom('[0:v]', 'negate', '[v0negate]')
|
->custom('[0:v]', 'negate', '[v0negate]')
|
||||||
->custom('[1:v]', 'edgedetect', '[v1edgedetect]')
|
->custom('[1:v]', 'edgedetect', '[v1edgedetect]')
|
||||||
->custom('[2:v]', 'hflip', '[v2hflip]')
|
->custom('[2:v]', 'hflip', '[v2hflip]')
|
||||||
->custom('[3:v]', 'vflip', '[v3vflip]')
|
->custom('[3:v]', 'vflip', '[v3vflip]')
|
||||||
->xStack('[v0negate][v1edgedetect][v2hflip][v3vflip]', XStackFilter::LAYOUT_2X2, 4, '[resultv]');
|
->xStack('[v0negate][v1edgedetect][v2hflip][v3vflip]', XStackFilter::LAYOUT_2X2, 4, '[resultv]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a'), new Mp3(), 'video_1.mp3')
|
->map(array('0:a'), new Mp3(), 'video_1.mp3')
|
||||||
->map(array('1:a'), new Flac(), 'video_2.flac')
|
->map(array('1:a'), new Flac(), 'video_2.flac')
|
||||||
->map(array('2:a'), new Wav(), 'video_3.wav')
|
->map(array('2:a'), new Wav(), 'video_3.wav')
|
||||||
|
|
@ -580,18 +580,18 @@ As you can see, you can take multiple input sources, perform the complicated pro
|
||||||
You do not have to use `-filter_complex`. You can use only `-map` options. For example, just extract the audio from the video:
|
You do not have to use `-filter_complex`. You can use only `-map` options. For example, just extract the audio from the video:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$complexMedia = $ffmpeg->openComplex(array('video.mp4'));
|
$advancedMedia = $ffmpeg->openAdvanced(array('video.mp4'));
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a'), new Mp3(), 'output.mp3')
|
->map(array('0:a'), new Mp3(), 'output.mp3')
|
||||||
->save();
|
->save();
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Customisation
|
#### Customisation
|
||||||
If you need you can extra customize the result ffmpeg command of the ComplexMedia:
|
If you need you can extra customize the result ffmpeg command of the AdvancedMedia:
|
||||||
|
|
||||||
```php
|
```php
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->setInitialParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'before', '-i', 'part', 'of', 'the', 'command'))
|
->setInitialParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'before', '-i', 'part', 'of', 'the', 'command'))
|
||||||
->setAdditionalParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'at', 'the', 'end', 'of', 'the', 'command'));
|
->setAdditionalParameters(array('the', 'params', 'that', 'will', 'be', 'added', 'at', 'the', 'end', 'of', 'the', 'command'));
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use FFMpeg\Driver\FFMpegDriver;
|
||||||
use FFMpeg\Exception\InvalidArgumentException;
|
use FFMpeg\Exception\InvalidArgumentException;
|
||||||
use FFMpeg\Exception\RuntimeException;
|
use FFMpeg\Exception\RuntimeException;
|
||||||
use FFMpeg\Media\Audio;
|
use FFMpeg\Media\Audio;
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
use FFMpeg\Media\Video;
|
use FFMpeg\Media\Video;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
|
|
||||||
|
|
@ -110,11 +110,11 @@ class FFMpeg
|
||||||
*
|
*
|
||||||
* @param string[] $inputs Array of files to be opened.
|
* @param string[] $inputs Array of files to be opened.
|
||||||
*
|
*
|
||||||
* @return ComplexMedia
|
* @return AdvancedMedia
|
||||||
*/
|
*/
|
||||||
public function openComplex($inputs)
|
public function openAdvanced($inputs)
|
||||||
{
|
{
|
||||||
return new ComplexMedia($inputs, $this->driver, $this->ffprobe);
|
return new AdvancedMedia($inputs, $this->driver, $this->ffprobe);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://ffmpeg.org/ffmpeg-filters.html#anullsrc
|
* @see https://ffmpeg.org/ffmpeg-filters.html#anullsrc
|
||||||
|
|
@ -57,7 +57,7 @@ class ANullSrcFilter extends AbstractComplexFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
abstract class AbstractComplexFilter implements ComplexCompatibleFilter
|
abstract class AbstractComplexFilter implements ComplexCompatibleFilter
|
||||||
{
|
{
|
||||||
|
|
@ -1,10 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Filters\FilterInterface;
|
use FFMpeg\Filters\FilterInterface;
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A filter that can be used inside "-filter_complex" option.
|
||||||
|
*/
|
||||||
interface ComplexCompatibleFilter extends FilterInterface
|
interface ComplexCompatibleFilter extends FilterInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -24,9 +27,9 @@ interface ComplexCompatibleFilter extends FilterInterface
|
||||||
/**
|
/**
|
||||||
* Apply the complex filter to the given media.
|
* Apply the complex filter to the given media.
|
||||||
*
|
*
|
||||||
* @param ComplexMedia $media
|
* @param AdvancedMedia $media
|
||||||
*
|
*
|
||||||
* @return string[] An array of arguments.
|
* @return string[] An array of arguments.
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media);
|
public function applyComplex(AdvancedMedia $media);
|
||||||
}
|
}
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for the complex filter.
|
* Container for the complex compatible filter.
|
||||||
*/
|
*/
|
||||||
class ComplexFilterContainer implements ComplexFilterInterface
|
class ComplexFilterContainer implements ComplexFilterInterface
|
||||||
{
|
{
|
||||||
|
|
@ -93,7 +93,7 @@ class ComplexFilterContainer implements ComplexFilterInterface
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return $this->baseFilter->applyComplex($media);
|
return $this->baseFilter->applyComplex($media);
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A filter that is completely ready to use inside "-filter_complex" option.
|
||||||
|
*/
|
||||||
interface ComplexFilterInterface extends ComplexCompatibleFilter
|
interface ComplexFilterInterface extends ComplexCompatibleFilter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Coordinate\Dimension;
|
use FFMpeg\Coordinate\Dimension;
|
||||||
use FFMpeg\Filters\Video\PadFilter;
|
use FFMpeg\Filters\Video\PadFilter;
|
||||||
use FFMpeg\Filters\Video\WatermarkFilter;
|
use FFMpeg\Filters\Video\WatermarkFilter;
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
class ComplexFilters
|
class ComplexFilters
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var ComplexMedia
|
* @var AdvancedMedia
|
||||||
*/
|
*/
|
||||||
protected $media;
|
protected $media;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ComplexFilters constructor.
|
* ComplexFilters constructor.
|
||||||
*
|
*
|
||||||
* @param ComplexMedia $media
|
* @param AdvancedMedia $media
|
||||||
*/
|
*/
|
||||||
public function __construct(ComplexMedia $media)
|
public function __construct(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
$this->media = $media;
|
$this->media = $media;
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
class CustomComplexFilter extends AbstractComplexFilter
|
class CustomComplexFilter extends AbstractComplexFilter
|
||||||
{
|
{
|
||||||
|
|
@ -36,7 +36,7 @@ class CustomComplexFilter extends AbstractComplexFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return array('-filter_complex', $this->filter);
|
return array('-filter_complex', $this->filter);
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see https://ffmpeg.org/ffmpeg-filters.html#sine
|
* @see https://ffmpeg.org/ffmpeg-filters.html#sine
|
||||||
|
|
@ -77,11 +77,11 @@ class SineFilter extends AbstractComplexFilter
|
||||||
/**
|
/**
|
||||||
* Apply the complex filter to the given media.
|
* Apply the complex filter to the given media.
|
||||||
*
|
*
|
||||||
* @param ComplexMedia $media
|
* @param AdvancedMedia $media
|
||||||
*
|
*
|
||||||
* @return string[] An array of arguments.
|
* @return string[] An array of arguments.
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This filter builds various types of computed inputs.
|
* This filter builds various types of computed inputs.
|
||||||
|
|
@ -227,7 +227,7 @@ class TestSrcFilter extends AbstractComplexFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace FFMpeg\Filters\ComplexMedia;
|
namespace FFMpeg\Filters\AdvancedMedia;
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* "xstack" filter.
|
* "xstack" filter.
|
||||||
|
|
@ -80,7 +80,7 @@ class XStackFilter extends AbstractComplexFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'-filter_complex',
|
'-filter_complex',
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
namespace FFMpeg\Filters\Video;
|
namespace FFMpeg\Filters\Video;
|
||||||
|
|
||||||
use FFMpeg\Coordinate\Dimension;
|
use FFMpeg\Coordinate\Dimension;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexCompatibleFilter;
|
use FFMpeg\Filters\AdvancedMedia\ComplexCompatibleFilter;
|
||||||
use FFMpeg\Format\VideoInterface;
|
use FFMpeg\Format\VideoInterface;
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
use FFMpeg\Media\Video;
|
use FFMpeg\Media\Video;
|
||||||
|
|
||||||
class PadFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
class PadFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
||||||
|
|
@ -77,7 +77,7 @@ class PadFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return $this->getCommands();
|
return $this->getCommands();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@
|
||||||
namespace FFMpeg\Filters\Video;
|
namespace FFMpeg\Filters\Video;
|
||||||
|
|
||||||
use FFMpeg\Exception\InvalidArgumentException;
|
use FFMpeg\Exception\InvalidArgumentException;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexCompatibleFilter;
|
use FFMpeg\Filters\AdvancedMedia\ComplexCompatibleFilter;
|
||||||
use FFMpeg\Format\VideoInterface;
|
use FFMpeg\Format\VideoInterface;
|
||||||
use FFMpeg\Media\ComplexMedia;
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
use FFMpeg\Media\Video;
|
use FFMpeg\Media\Video;
|
||||||
|
|
||||||
class WatermarkFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
class WatermarkFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
||||||
|
|
@ -76,7 +76,7 @@ class WatermarkFilter implements VideoFilterInterface, ComplexCompatibleFilter
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function applyComplex(ComplexMedia $media)
|
public function applyComplex(AdvancedMedia $media)
|
||||||
{
|
{
|
||||||
return $this->getCommands();
|
return $this->getCommands();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ use Alchemy\BinaryDriver\Exception\ExecutionFailureException;
|
||||||
use FFMpeg\Driver\FFMpegDriver;
|
use FFMpeg\Driver\FFMpegDriver;
|
||||||
use FFMpeg\Exception\RuntimeException;
|
use FFMpeg\Exception\RuntimeException;
|
||||||
use FFMpeg\FFProbe;
|
use FFMpeg\FFProbe;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexCompatibleFilter;
|
use FFMpeg\Filters\AdvancedMedia\ComplexCompatibleFilter;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexFilterContainer;
|
use FFMpeg\Filters\AdvancedMedia\ComplexFilterContainer;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexFilterInterface;
|
use FFMpeg\Filters\AdvancedMedia\ComplexFilterInterface;
|
||||||
use FFMpeg\Filters\ComplexMedia\ComplexFilters;
|
use FFMpeg\Filters\AdvancedMedia\ComplexFilters;
|
||||||
use FFMpeg\Filters\FiltersCollection;
|
use FFMpeg\Filters\FiltersCollection;
|
||||||
use FFMpeg\Format\AudioInterface;
|
use FFMpeg\Format\AudioInterface;
|
||||||
use FFMpeg\Format\FormatInterface;
|
use FFMpeg\Format\FormatInterface;
|
||||||
|
|
@ -18,13 +18,13 @@ use FFMpeg\Format\ProgressListener\AbstractProgressListener;
|
||||||
use FFMpeg\Format\VideoInterface;
|
use FFMpeg\Format\VideoInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complex media may have multiple inputs and multiple outputs.
|
* AdvancedMedia may have multiple inputs and multiple outputs.
|
||||||
* This class accepts only filters for -filter_complex option.
|
* This class accepts only filters for -filter_complex option.
|
||||||
* But you can set initial and additional parameters of the ffmpeg command.
|
* But you can set initial and additional parameters of the ffmpeg command.
|
||||||
*
|
*
|
||||||
* @see http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs
|
* @see http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs
|
||||||
*/
|
*/
|
||||||
class ComplexMedia extends AbstractMediaType
|
class AdvancedMedia extends AbstractMediaType
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @var string[]
|
||||||
|
|
@ -52,7 +52,7 @@ class ComplexMedia extends AbstractMediaType
|
||||||
private $listeners;
|
private $listeners;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ComplexMedia constructor.
|
* AdvancedMedia constructor.
|
||||||
*
|
*
|
||||||
* @param string[] $inputs Array of files to be opened.
|
* @param string[] $inputs Array of files to be opened.
|
||||||
* @param FFMpegDriver $driver
|
* @param FFMpegDriver $driver
|
||||||
|
|
@ -110,7 +110,7 @@ class ComplexMedia extends AbstractMediaType
|
||||||
{
|
{
|
||||||
foreach ($filters as $filter) {
|
foreach ($filters as $filter) {
|
||||||
if (!($filter instanceof ComplexFilterInterface)) {
|
if (!($filter instanceof ComplexFilterInterface)) {
|
||||||
throw new RuntimeException ('For ComplexMedia you can set filters collection'
|
throw new RuntimeException ('For AdvancedMedia you can set filters collection'
|
||||||
. ' contains only objects that implement ComplexFilterInterface!');
|
. ' contains only objects that implement ComplexFilterInterface!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ class ComplexMedia extends AbstractMediaType
|
||||||
/**
|
/**
|
||||||
* @param string[] $initialParameters
|
* @param string[] $initialParameters
|
||||||
*
|
*
|
||||||
* @return ComplexMedia
|
* @return AdvancedMedia
|
||||||
*/
|
*/
|
||||||
public function setInitialParameters(array $initialParameters)
|
public function setInitialParameters(array $initialParameters)
|
||||||
{
|
{
|
||||||
|
|
@ -148,7 +148,7 @@ class ComplexMedia extends AbstractMediaType
|
||||||
/**
|
/**
|
||||||
* @param string[] $additionalParameters
|
* @param string[] $additionalParameters
|
||||||
*
|
*
|
||||||
* @return ComplexMedia
|
* @return AdvancedMedia
|
||||||
*/
|
*/
|
||||||
public function setAdditionalParameters(array $additionalParameters)
|
public function setAdditionalParameters(array $additionalParameters)
|
||||||
{
|
{
|
||||||
|
|
@ -3,17 +3,17 @@
|
||||||
namespace Tests\FFMpeg\Functional;
|
namespace Tests\FFMpeg\Functional;
|
||||||
|
|
||||||
use FFMpeg\Coordinate\Dimension;
|
use FFMpeg\Coordinate\Dimension;
|
||||||
use FFMpeg\Filters\ComplexMedia\TestSrcFilter;
|
use FFMpeg\Filters\AdvancedMedia\TestSrcFilter;
|
||||||
use FFMpeg\Filters\ComplexMedia\XStackFilter;
|
use FFMpeg\Filters\AdvancedMedia\XStackFilter;
|
||||||
use FFMpeg\Format\Audio\Mp3;
|
use FFMpeg\Format\Audio\Mp3;
|
||||||
use FFMpeg\Format\Video\X264;
|
use FFMpeg\Format\Video\X264;
|
||||||
|
|
||||||
class ComplexMediaTest extends FunctionalTestCase
|
class AdvancedMediaTest extends FunctionalTestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Path prefix to avoid conflicts with another tests.
|
* Path prefix to avoid conflicts with another tests.
|
||||||
*/
|
*/
|
||||||
const OUTPUT_PATH_PREFIX = 'output/complex_media_';
|
const OUTPUT_PATH_PREFIX = 'output/advanced_media_';
|
||||||
|
|
||||||
public function testRunWithoutComplexFilterTestExtractAudio()
|
public function testRunWithoutComplexFilterTestExtractAudio()
|
||||||
{
|
{
|
||||||
|
|
@ -23,8 +23,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'extracted_with_map.mp3';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'extracted_with_map.mp3';
|
||||||
|
|
||||||
// You can run it without -filter_complex, just using -map.
|
// You can run it without -filter_complex, just using -map.
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a'), $format, $output)
|
->map(array('0:a'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -42,8 +42,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$format->setAudioKiloBitrate(30);
|
$format->setAudioKiloBitrate(30);
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'audio_test.mp3';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'audio_test.mp3';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a'), $format, $output)
|
->map(array('0:a'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -63,10 +63,10 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$format = new X264('aac', 'libx264');
|
$format = new X264('aac', 'libx264');
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'multiple_inputs_test.mp4';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'multiple_inputs_test.mp4';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->custom('[0:v][1:v]', 'hstack', '[v]');
|
->custom('[0:v][1:v]', 'hstack', '[v]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a', '[v]'), $format, $output)
|
->map(array('0:a', '[v]'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FFMpeg\Media\ComplexMedia::map
|
* @covers \FFMpeg\Media\AdvancedMedia::map
|
||||||
*/
|
*/
|
||||||
public function testMultipleOutputsTestAbsenceOfInputs()
|
public function testMultipleOutputsTestAbsenceOfInputs()
|
||||||
{
|
{
|
||||||
|
|
@ -92,14 +92,14 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$outputVideo1 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v1.mp4';
|
$outputVideo1 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v1.mp4';
|
||||||
$outputVideo2 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v2.mp4';
|
$outputVideo2 = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_multiple_outputs_v2.mp4';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->sine('[a]', 5)
|
->sine('[a]', 5)
|
||||||
->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5)
|
->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||||
->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5)
|
->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||||
->custom('[v1]', 'negate', '[v1negate]')
|
->custom('[v1]', 'negate', '[v1negate]')
|
||||||
->custom('[v2]', 'edgedetect', '[v2edgedetect]');
|
->custom('[v2]', 'edgedetect', '[v2edgedetect]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('[a]'), $formatMp3, $outputMp3)
|
->map(array('[a]'), $formatMp3, $outputMp3)
|
||||||
->map(array('[v1negate]'), $formatX264, $outputVideo1)
|
->map(array('[v1negate]'), $formatX264, $outputVideo1)
|
||||||
->map(array('[v2edgedetect]'), $formatX264, $outputVideo2)
|
->map(array('[v2edgedetect]'), $formatX264, $outputVideo2)
|
||||||
|
|
@ -123,8 +123,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \FFMpeg\Filters\ComplexMedia\TestSrcFilter
|
* @covers \FFMpeg\Filters\AdvancedMedia\TestSrcFilter
|
||||||
* @covers \FFMpeg\Filters\ComplexMedia\SineFilter
|
* @covers \FFMpeg\Filters\AdvancedMedia\SineFilter
|
||||||
*/
|
*/
|
||||||
public function testTestSrcFilterTestSineFilter()
|
public function testTestSrcFilterTestSineFilter()
|
||||||
{
|
{
|
||||||
|
|
@ -133,11 +133,11 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$format = new X264('aac', 'libx264');
|
$format = new X264('aac', 'libx264');
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'testsrc.mp4';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'testsrc.mp4';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->sine('[a]', 10)
|
->sine('[a]', 10)
|
||||||
->testSrc('[v]', TestSrcFilter::TESTSRC, '160x120', 10);
|
->testSrc('[v]', TestSrcFilter::TESTSRC, '160x120', 10);
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('[a]', '[v]'), $format, $output)
|
->map(array('[a]', '[v]'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -150,8 +150,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
/**
|
/**
|
||||||
* XStack filter is supported starting from 4.1 ffmpeg version.
|
* XStack filter is supported starting from 4.1 ffmpeg version.
|
||||||
*
|
*
|
||||||
* @covers \FFMpeg\Filters\ComplexMedia\XStackFilter
|
* @covers \FFMpeg\Filters\AdvancedMedia\XStackFilter
|
||||||
* @covers \FFMpeg\Filters\ComplexMedia\SineFilter
|
* @covers \FFMpeg\Filters\AdvancedMedia\SineFilter
|
||||||
*/
|
*/
|
||||||
public function testXStackFilter()
|
public function testXStackFilter()
|
||||||
{
|
{
|
||||||
|
|
@ -169,8 +169,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$format = new X264('aac', 'libx264');
|
$format = new X264('aac', 'libx264');
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'xstack_test.mp4';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'xstack_test.mp4';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
->sine('[a]', 5)
|
->sine('[a]', 5)
|
||||||
->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5)
|
->testSrc('[v1]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||||
->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5)
|
->testSrc('[v2]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||||
|
|
@ -178,7 +178,7 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
->testSrc('[v4]', TestSrcFilter::TESTSRC, '160x120', 5)
|
->testSrc('[v4]', TestSrcFilter::TESTSRC, '160x120', 5)
|
||||||
->xStack('[v1][v2][v3][v4]',
|
->xStack('[v1][v2][v3][v4]',
|
||||||
XStackFilter::LAYOUT_2X2, 4, '[v]');
|
XStackFilter::LAYOUT_2X2, 4, '[v]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('[a]', '[v]'), $format, $output)
|
->map(array('[a]', '[v]'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -196,8 +196,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$format = new X264('aac', 'libx264');
|
$format = new X264('aac', 'libx264');
|
||||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_of_compatibility_with_existed_filters.mp4';
|
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'test_of_compatibility_with_existed_filters.mp4';
|
||||||
|
|
||||||
$complexMedia = $ffmpeg->openComplex($inputs);
|
$advancedMedia = $ffmpeg->openAdvanced($inputs);
|
||||||
$complexMedia->filters()
|
$advancedMedia->filters()
|
||||||
// For unknown reasons WatermarkFilter produce an error on Windows,
|
// For unknown reasons WatermarkFilter produce an error on Windows,
|
||||||
// because the path to the watermark becomes corrupted.
|
// because the path to the watermark becomes corrupted.
|
||||||
// This behaviour related with Alchemy\BinaryDriver\AbstractBinary::command().
|
// This behaviour related with Alchemy\BinaryDriver\AbstractBinary::command().
|
||||||
|
|
@ -206,7 +206,7 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
// But on Linux systems filter works as expected.
|
// But on Linux systems filter works as expected.
|
||||||
//->watermark('[0:v]', $watermark, '[v]')
|
//->watermark('[0:v]', $watermark, '[v]')
|
||||||
->pad('[0:v]', new Dimension(300, 100), '[v]');
|
->pad('[0:v]', new Dimension(300, 100), '[v]');
|
||||||
$complexMedia
|
$advancedMedia
|
||||||
->map(array('0:a', '[v]'), $format, $output)
|
->map(array('0:a', '[v]'), $format, $output)
|
||||||
->save();
|
->save();
|
||||||
|
|
||||||
|
|
@ -221,15 +221,15 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$ffmpeg = $this->getFFMpeg();
|
$ffmpeg = $this->getFFMpeg();
|
||||||
$format = new X264();
|
$format = new X264();
|
||||||
|
|
||||||
$complexMedia1 = $ffmpeg->openComplex(array(__FILE__));
|
$advancedMedia1 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||||
$complexMedia1
|
$advancedMedia1
|
||||||
->map(array('test'), $format, 'outputFile.mp4', false);
|
->map(array('test'), $format, 'outputFile.mp4', false);
|
||||||
$this->assertStringContainsString('acodec', $complexMedia1->getFinalCommand());
|
$this->assertStringContainsString('acodec', $advancedMedia1->getFinalCommand());
|
||||||
|
|
||||||
$complexMedia2 = $ffmpeg->openComplex(array(__FILE__));
|
$advancedMedia2 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||||
$complexMedia2
|
$advancedMedia2
|
||||||
->map(array('test'), $format, 'outputFile.mp4', true);
|
->map(array('test'), $format, 'outputFile.mp4', true);
|
||||||
$this->assertStringNotContainsString('acodec', $complexMedia2->getFinalCommand());
|
$this->assertStringNotContainsString('acodec', $advancedMedia2->getFinalCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testForceDisableVideo()
|
public function testForceDisableVideo()
|
||||||
|
|
@ -237,15 +237,15 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
$ffmpeg = $this->getFFMpeg();
|
$ffmpeg = $this->getFFMpeg();
|
||||||
$format = new X264();
|
$format = new X264();
|
||||||
|
|
||||||
$complexMedia1 = $ffmpeg->openComplex(array(__FILE__));
|
$advancedMedia1 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||||
$complexMedia1->map(array('test'), $format,
|
$advancedMedia1->map(array('test'), $format,
|
||||||
'outputFile.mp4', false, false);
|
'outputFile.mp4', false, false);
|
||||||
$this->assertStringContainsString('vcodec', $complexMedia1->getFinalCommand());
|
$this->assertStringContainsString('vcodec', $advancedMedia1->getFinalCommand());
|
||||||
|
|
||||||
$complexMedia2 = $ffmpeg->openComplex(array(__FILE__));
|
$advancedMedia2 = $ffmpeg->openAdvanced(array(__FILE__));
|
||||||
$complexMedia2->map(array('test'), $format,
|
$advancedMedia2->map(array('test'), $format,
|
||||||
'outputFile.mp4', false, true);
|
'outputFile.mp4', false, true);
|
||||||
$this->assertStringNotContainsString('vcodec', $complexMedia2->getFinalCommand());
|
$this->assertStringNotContainsString('vcodec', $advancedMedia2->getFinalCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGlobalOptions()
|
public function testGlobalOptions()
|
||||||
|
|
@ -257,8 +257,8 @@ class ComplexMediaTest extends FunctionalTestCase
|
||||||
);
|
);
|
||||||
|
|
||||||
$ffmpeg = $this->getFFMpeg($configuration);
|
$ffmpeg = $this->getFFMpeg($configuration);
|
||||||
$complexMedia = $ffmpeg->openComplex(array(__FILE__));
|
$advancedMedia = $ffmpeg->openAdvanced(array(__FILE__));
|
||||||
$command = $complexMedia->getFinalCommand();
|
$command = $advancedMedia->getFinalCommand();
|
||||||
|
|
||||||
foreach ($configuration as $optionName => $optionValue) {
|
foreach ($configuration as $optionName => $optionValue) {
|
||||||
$optionName = str_replace('ffmpeg.', '', $optionName);
|
$optionName = str_replace('ffmpeg.', '', $optionName);
|
||||||
35
tests/Unit/Media/AdvancedMediaTest.php
Normal file
35
tests/Unit/Media/AdvancedMediaTest.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\FFMpeg\Unit\Media;
|
||||||
|
|
||||||
|
use FFMpeg\Media\AdvancedMedia;
|
||||||
|
|
||||||
|
class AdvancedMediaTest extends AbstractMediaTestCase
|
||||||
|
{
|
||||||
|
public function testGetInputs()
|
||||||
|
{
|
||||||
|
$driver = $this->getFFMpegDriverMock();
|
||||||
|
$ffprobe = $this->getFFProbeMock();
|
||||||
|
|
||||||
|
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||||
|
$this->assertSame(array(__FILE__, __FILE__), $advancedMedia->getInputs());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetInputsCount()
|
||||||
|
{
|
||||||
|
$driver = $this->getFFMpegDriverMock();
|
||||||
|
$ffprobe = $this->getFFProbeMock();
|
||||||
|
|
||||||
|
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||||
|
$this->assertEquals(2, $advancedMedia->getInputsCount());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFiltersReturnFilters()
|
||||||
|
{
|
||||||
|
$driver = $this->getFFMpegDriverMock();
|
||||||
|
$ffprobe = $this->getFFProbeMock();
|
||||||
|
|
||||||
|
$advancedMedia = new AdvancedMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
||||||
|
$this->assertInstanceOf('FFMpeg\Filters\AdvancedMedia\ComplexFilters', $advancedMedia->filters());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\FFMpeg\Unit\Media;
|
|
||||||
|
|
||||||
use FFMpeg\Media\ComplexMedia;
|
|
||||||
|
|
||||||
class ComplexMediaTest extends AbstractMediaTestCase
|
|
||||||
{
|
|
||||||
public function testGetInputs()
|
|
||||||
{
|
|
||||||
$driver = $this->getFFMpegDriverMock();
|
|
||||||
$ffprobe = $this->getFFProbeMock();
|
|
||||||
|
|
||||||
$complexMedia = new ComplexMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
|
||||||
$this->assertSame(array(__FILE__, __FILE__), $complexMedia->getInputs());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetInputsCount()
|
|
||||||
{
|
|
||||||
$driver = $this->getFFMpegDriverMock();
|
|
||||||
$ffprobe = $this->getFFProbeMock();
|
|
||||||
|
|
||||||
$complexMedia = new ComplexMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
|
||||||
$this->assertEquals(2, $complexMedia->getInputsCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFiltersReturnFilters()
|
|
||||||
{
|
|
||||||
$driver = $this->getFFMpegDriverMock();
|
|
||||||
$ffprobe = $this->getFFProbeMock();
|
|
||||||
|
|
||||||
$complexMedia = new ComplexMedia(array(__FILE__, __FILE__), $driver, $ffprobe);
|
|
||||||
$this->assertInstanceOf('FFMpeg\Filters\ComplexMedia\ComplexFilters', $complexMedia->filters());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue