Add Spectrum audio filter
This commit is contained in:
parent
7abb6d36cb
commit
bae154894e
3 changed files with 673 additions and 0 deletions
30
tests/Functional/AudioImagingTest.php
Normal file
30
tests/Functional/AudioImagingTest.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Functional;
|
||||
|
||||
use FFMpeg\FFMpeg;
|
||||
use FFMpeg\FFProbe;
|
||||
use FFMpeg\Media\Spectrum;
|
||||
|
||||
class AudioImagingTest extends FunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* Path prefix to avoid conflicts with another tests.
|
||||
*/
|
||||
const OUTPUT_PATH_PREFIX = 'output/audio_';
|
||||
|
||||
public function testgenerateSpectrumImage()
|
||||
{
|
||||
$ffmpeg = FFMpeg::create();
|
||||
$ffprobe = FFProbe::create();
|
||||
$audio = $ffmpeg->open(realpath(__DIR__ . '/../files/Audio.mp3'));
|
||||
$spectrum = new Spectrum($audio, $ffmpeg->getFFMpegDriver(), $ffprobe, 1024, 1024);
|
||||
$spectrum->setLegend(false)
|
||||
->setOrientation('horizontal')
|
||||
->setColor('fiery');
|
||||
$output = __DIR__ . '/' . self::OUTPUT_PATH_PREFIX . 'spectrum.png';
|
||||
$spectrum->save($output);
|
||||
$this->assertFileExists($output);
|
||||
unlink($output);
|
||||
}
|
||||
}
|
||||
42
tests/Unit/Media/SpectrumTest.php
Normal file
42
tests/Unit/Media/SpectrumTest.php
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Unit\Media;
|
||||
|
||||
use FFMpeg\Media\Spectrum;
|
||||
|
||||
class SpectrumTest extends AbstractMediaTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @dataProvider provideSaveOptions
|
||||
*/
|
||||
public function testSave($commands)
|
||||
{
|
||||
$driver = $this->getFFMpegDriverMock();
|
||||
$ffprobe = $this->getFFProbeMock();
|
||||
|
||||
$pathfile = '/tests/files/Audio.mp3';
|
||||
|
||||
array_push($commands, $pathfile);
|
||||
|
||||
$driver->expects($this->once())
|
||||
->method('command')
|
||||
->with($commands);
|
||||
|
||||
$spectrum = new Spectrum($this->getAudioMock(), $driver, $ffprobe, 640, 120);
|
||||
$this->assertSame($spectrum, $spectrum->save($pathfile));
|
||||
}
|
||||
|
||||
public function provideSaveOptions()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
array(
|
||||
'-y', '-i', NULL, '-filter_complex',
|
||||
'showspectrumpic=s=640x120',
|
||||
'-frames:v', '1',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue