Added runtime check of the ffmpeg version before starting the command in the ComplexMedia. Added the FFMpegDriver::getVersion() method.

This commit is contained in:
CaliforniaMountainSnake 2020-02-26 12:33:45 +03:00
commit d6f95508a9
15 changed files with 212 additions and 25 deletions

View file

@ -44,6 +44,16 @@ class ANullSrcFilter extends AbstractComplexFilter
$this->nbSamples = $nbSamples;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'anullsrc';
}
/**
* {@inheritdoc}
*/
@ -51,7 +61,7 @@ class ANullSrcFilter extends AbstractComplexFilter
{
return array(
'-filter_complex',
'anullsrc' . $this->buildFilterOptions(array(
$this->getName() . $this->buildFilterOptions(array(
'channel_layout' => $this->channelLayout,
'sample_rate' => $this->sampleRate,
'nb_samples' => $this->nbSamples,

View file

@ -27,6 +27,16 @@ abstract class AbstractComplexFilter implements ComplexCompatibleFilter
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.
*

View file

@ -7,6 +7,20 @@ use FFMpeg\Media\ComplexMedia;
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.
*

View file

@ -70,6 +70,26 @@ class ComplexFilterContainer implements ComplexFilterInterface
return $this->outLabels;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return $this->baseFilter->getName();
}
/**
* Get minimal version of ffmpeg starting with which this filter is supported.
*
* @return string
*/
public function getMinimalFFMpegVersion()
{
return $this->baseFilter->getMinimalFFMpegVersion();
}
/**
* {@inheritdoc}
*/

View file

@ -23,6 +23,16 @@ class CustomComplexFilter extends AbstractComplexFilter
$this->filter = $filter;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'custom_filter';
}
/**
* {@inheritdoc}
*/

View file

@ -54,6 +54,26 @@ class SineFilter extends AbstractComplexFilter
$this->samples_per_frame = $samples_per_frame;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'sine';
}
/**
* Get minimal version of ffmpeg starting with which this filter is supported.
*
* @return string
*/
public function getMinimalFFMpegVersion()
{
return '2.0';
}
/**
* Apply the complex filter to the given media.
*
@ -65,7 +85,7 @@ class SineFilter extends AbstractComplexFilter
{
return array(
'-filter_complex',
'sine' . $this->buildFilterOptions(array(
$this->getName() . $this->buildFilterOptions(array(
'frequency' => $this->frequency,
'beep_factor' => $this->beep_factor,
'sample_rate' => $this->sample_rate,

View file

@ -189,6 +189,16 @@ class TestSrcFilter extends AbstractComplexFilter
$this->decimals = $decimals;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return $this->type;
}
/**
* {@inheritdoc}
*/

View file

@ -6,13 +6,14 @@ use FFMpeg\Media\ComplexMedia;
/**
* "xstack" filter.
* Warning: this filter is supported starting from 4.1 ffmpeg version.
* This filter helps you to create a collage from the given videos.
* This filter is supported starting from 4.1 ffmpeg version.
* (On early versions you can use combinations of hstack and vstack filters).
*
* @see https://ffmpeg.org/ffmpeg-filters.html#xstack
*/
class XStackFilter extends AbstractComplexFilter
{
const MINIMAL_FFMPEG_VERSION = '4.1';
const LAYOUT_2X2 = '0_0|0_h0|w0_0|w0_h0';
const LAYOUT_1X4 = '0_0|0_h0|0_h0+h1|0_h0+h1+h2';
const LAYOUT_3X3 = '0_0|0_h0|0_h0+h1|w0_0|w0_h0|w0_h0+h1|w0+w3_0|w0+w3_h0|w0+w3_h0+h1';
@ -56,6 +57,26 @@ class XStackFilter extends AbstractComplexFilter
return $result;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'xstack';
}
/**
* Get minimal version of ffmpeg starting with which this filter is supported.
*
* @return string
*/
public function getMinimalFFMpegVersion()
{
return '4.1';
}
/**
* {@inheritdoc}
*/
@ -63,7 +84,7 @@ class XStackFilter extends AbstractComplexFilter
{
return array(
'-filter_complex',
'xstack' . $this->buildFilterOptions(array(
$this->getName() . $this->buildFilterOptions(array(
'inputs' => $this->inputsCount,
'layout' => $this->layout
))

View file

@ -46,6 +46,26 @@ class PadFilter implements VideoFilterInterface, ComplexCompatibleFilter
return $this->dimension;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'pad';
}
/**
* Get minimal version of ffmpeg starting with which this filter is supported.
*
* @return string
*/
public function getMinimalFFMpegVersion()
{
return '0.4.9';
}
/**
* {@inheritdoc}
*/

View file

@ -45,6 +45,26 @@ class WatermarkFilter implements VideoFilterInterface, ComplexCompatibleFilter
return $this->priority;
}
/**
* Get name of the filter.
*
* @return string
*/
public function getName()
{
return 'watermark';
}
/**
* Get minimal version of ffmpeg starting with which this filter is supported.
*
* @return string
*/
public function getMinimalFFMpegVersion()
{
return '0.8';
}
/**
* {@inheritdoc}
*/