Merge branch 'master' into master
This commit is contained in:
commit
fab3638caf
4 changed files with 86 additions and 1 deletions
54
src/FFMpeg/Filters/Frame/CustomFrameFilter.php
Normal file
54
src/FFMpeg/Filters/Frame/CustomFrameFilter.php
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of PHP-FFmpeg.
|
||||||
|
*
|
||||||
|
* (c) Alchemy <dev.team@alchemy.fr>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace FFMpeg\Filters\Frame;
|
||||||
|
|
||||||
|
use FFMpeg\Exception\RuntimeException;
|
||||||
|
use FFMpeg\Media\Frame;
|
||||||
|
|
||||||
|
class CustomFrameFilter implements FrameFilterInterface
|
||||||
|
{
|
||||||
|
/** @var string */
|
||||||
|
private $filter;
|
||||||
|
/** @var integer */
|
||||||
|
private $priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A custom filter, useful if you want to build complex filters
|
||||||
|
*
|
||||||
|
* @param string $filter
|
||||||
|
* @param int $priority
|
||||||
|
*/
|
||||||
|
public function __construct($filter, $priority = 0)
|
||||||
|
{
|
||||||
|
$this->filter = $filter;
|
||||||
|
$this->priority = $priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function getPriority()
|
||||||
|
{
|
||||||
|
return $this->priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function apply(Frame $frame)
|
||||||
|
{
|
||||||
|
$commands = array('-vf', $this->filter);
|
||||||
|
|
||||||
|
return $commands;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -36,4 +36,18 @@ class FrameFilters
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a custom filter: -vf foo bar
|
||||||
|
*
|
||||||
|
* @param string $parameters
|
||||||
|
*
|
||||||
|
* @return FrameFilters
|
||||||
|
*/
|
||||||
|
public function custom($parameters)
|
||||||
|
{
|
||||||
|
$this->frame->addFilter(new CustomFrameFilter($parameters));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ abstract class AbstractVideo extends Audio
|
||||||
$videoFilterVars = $videoFilterProcesses = array();
|
$videoFilterVars = $videoFilterProcesses = array();
|
||||||
for ($i = 0; $i < count($commands); $i++) {
|
for ($i = 0; $i < count($commands); $i++) {
|
||||||
$command = $commands[$i];
|
$command = $commands[$i];
|
||||||
if ($command == '-vf') {
|
if ($command === '-vf') {
|
||||||
$commandSplits = explode(";", $commands[$i + 1]);
|
$commandSplits = explode(";", $commands[$i + 1]);
|
||||||
if (count($commandSplits) == 1) {
|
if (count($commandSplits) == 1) {
|
||||||
$commandSplit = $commandSplits[0];
|
$commandSplit = $commandSplits[0];
|
||||||
|
|
|
||||||
17
tests/Unit/Filters/Frame/CustomFrameFilterTest.php
Normal file
17
tests/Unit/Filters/Frame/CustomFrameFilterTest.php
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\FFMpeg\Unit\Filters\Frame;
|
||||||
|
|
||||||
|
use FFMpeg\Filters\Frame\CustomFrameFilter;
|
||||||
|
use Tests\FFMpeg\Unit\TestCase;
|
||||||
|
|
||||||
|
class CustomFrameFilterTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testApplyCustomFrameFilter()
|
||||||
|
{
|
||||||
|
$frame = $this->getFrameMock();
|
||||||
|
|
||||||
|
$filter = new CustomFrameFilter('whatever i put would end up as a filter');
|
||||||
|
$this->assertEquals(array('-vf', 'whatever i put would end up as a filter'), $filter->apply($frame));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue