Merge pull request #503 from lasselehtinen/master
Added required concat method for Audio files
This commit is contained in:
commit
fc8dbd6f02
6 changed files with 51 additions and 1 deletions
|
|
@ -647,3 +647,11 @@ $app->register(new FFMpeg\FFMpegServiceProvider(), array(
|
|||
## License
|
||||
|
||||
This project is licensed under the [MIT license](http://opensource.org/licenses/MIT).
|
||||
|
||||
Music: "Favorite Secrets" by Waylon Thornton
|
||||
From the Free Music Archive
|
||||
[CC BY NC SA](http://creativecommons.org/licenses/by-nc-sa/3.0/us/)
|
||||
|
||||
Music: "Siesta" by Jahzzar
|
||||
From the Free Music Archive
|
||||
[CC BY SA](https://creativecommons.org/licenses/by-sa/3.0/)
|
||||
|
|
|
|||
|
|
@ -139,4 +139,15 @@ class Audio extends AbstractStreamableMedia
|
|||
{
|
||||
return new Waveform($this, $this->driver, $this->ffprobe, $width, $height, $colors);
|
||||
}
|
||||
|
||||
/**
|
||||
* Concatenates a list of audio files into one unique audio file.
|
||||
*
|
||||
* @param array $sources
|
||||
* @return Concat
|
||||
*/
|
||||
public function concat($sources)
|
||||
{
|
||||
return new Concat($sources, $this->driver, $this->ffprobe);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class Concat extends AbstractMediaType
|
|||
* Saves the concatenated video in the given array, considering that the sources videos are all encoded with the same codec.
|
||||
*
|
||||
* @param string $outputPathfile
|
||||
* @param string $streamCopy
|
||||
* @param bool $streamCopy
|
||||
*
|
||||
* @return Concat
|
||||
*
|
||||
|
|
|
|||
31
tests/Functional/AudioConcatenationTest.php
Normal file
31
tests/Functional/AudioConcatenationTest.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\FFMpeg\Functional;
|
||||
|
||||
use FFMpeg\Format\Audio\Mp3;
|
||||
use FFMpeg\Media\Audio;
|
||||
|
||||
class AudioConcatenationTest extends FunctionalTestCase
|
||||
{
|
||||
public function testSimpleAudioFileConcatTest()
|
||||
{
|
||||
$ffmpeg = $this->getFFMpeg();
|
||||
|
||||
$files = [
|
||||
__DIR__ . '/../files/Jahzzar_-_05_-_Siesta.mp3',
|
||||
__DIR__ . '/../files/02_-_Favorite_Secrets.mp3',
|
||||
];
|
||||
|
||||
$audio = $ffmpeg->open(reset($files));
|
||||
|
||||
$this->assertInstanceOf('FFMpeg\Media\Audio', $audio);
|
||||
|
||||
clearstatcache();
|
||||
$filename = __DIR__ . '/output/concat-output.mp3';
|
||||
|
||||
$audio->concat($files)->saveFromSameCodecs($filename, TRUE);
|
||||
|
||||
$this->assertFileExists($filename);
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
BIN
tests/files/02_-_Favorite_Secrets.mp3
Normal file
BIN
tests/files/02_-_Favorite_Secrets.mp3
Normal file
Binary file not shown.
BIN
tests/files/Jahzzar_-_05_-_Siesta.mp3
Normal file
BIN
tests/files/Jahzzar_-_05_-_Siesta.mp3
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue