Merge pull request #503 from lasselehtinen/master

Added required concat method for Audio files
This commit is contained in:
Jens Hausdorf 2018-09-20 12:54:23 +02:00 committed by GitHub
commit fc8dbd6f02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 1 deletions

View file

@ -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/)

View file

@ -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);
}
}

View file

@ -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
*

View 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);
}
}

Binary file not shown.

Binary file not shown.