|
@@ 377-400 (lines=24) @@
|
| 374 |
|
* ffmpeg -y -i in-1.wav -i in-2.wav -i in-3.wav |
| 375 |
|
* -filter_complex '[0:0][1:0][2:0]concat=n=3:v=0:a=1[out]' -map '[out]' out.wav |
| 376 |
|
*/ |
| 377 |
|
public function concatenateSounds($sounds = array(), $target) |
| 378 |
|
{ |
| 379 |
|
if (!is_array($sounds)) { |
| 380 |
|
$sounds = array($sounds); |
| 381 |
|
} |
| 382 |
|
|
| 383 |
|
$this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); |
| 384 |
|
$ffmpeg = $this->serviceLocator->get('playgroundcore_phpvideotoolkit') |
| 385 |
|
->addPreInputCommand('-y'); |
| 386 |
|
|
| 387 |
|
$concat = ''; |
| 388 |
|
foreach ($sounds as $k => $s) { |
| 389 |
|
$ffmpeg->addCommand('-i', $s, true); |
| 390 |
|
$concat .= '['.$k.':0]'; |
| 391 |
|
} |
| 392 |
|
$concat .= 'concat=n='. count($sounds) .':v=0:a=1[out]'; |
| 393 |
|
|
| 394 |
|
$ffmpeg->addCommand('-filter_complex', $concat) |
| 395 |
|
->addCommand('-map', '[out]') |
| 396 |
|
->setOutputPath($target) |
| 397 |
|
->execute(); |
| 398 |
|
|
| 399 |
|
return $target; |
| 400 |
|
} |
| 401 |
|
|
| 402 |
|
/** |
| 403 |
|
* This method merge an array of sounds |
|
@@ 407-431 (lines=25) @@
|
| 404 |
|
* ffmpeg -i in-1.wav -i in-2.wav -i in-3.wav |
| 405 |
|
* -filter_complex "[0:a][1:a][2:a]amerge=inputs=3[aout]" -map "[aout]" -ac 2 out.wav |
| 406 |
|
*/ |
| 407 |
|
public function mergeSounds($sounds = array(), $target) |
| 408 |
|
{ |
| 409 |
|
if (!is_array($sounds)) { |
| 410 |
|
$sounds = array($sounds); |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
$this->serviceLocator->setShared('playgroundcore_phpvideotoolkit', false); |
| 414 |
|
$ffmpeg = $this->serviceLocator->get('playgroundcore_phpvideotoolkit') |
| 415 |
|
->addPreInputCommand('-y'); |
| 416 |
|
|
| 417 |
|
$merge = ''; |
| 418 |
|
foreach ($sounds as $k => $s) { |
| 419 |
|
$ffmpeg->addCommand('-i', $s, true); |
| 420 |
|
$merge .= '['.$k.':a]'; |
| 421 |
|
} |
| 422 |
|
$merge .= 'amerge=inputs='. count($sounds) .'[aout]'; |
| 423 |
|
|
| 424 |
|
$ffmpeg->addCommand('-filter_complex', $merge) |
| 425 |
|
->addCommand('-map', '[aout]') |
| 426 |
|
->addCommand('-ac', '2') |
| 427 |
|
->setOutputPath($target) |
| 428 |
|
->execute(); |
| 429 |
|
|
| 430 |
|
return $target; |
| 431 |
|
} |
| 432 |
|
|
| 433 |
|
/* |
| 434 |
|
* this method takes an image (with alpha) or a mov video (the format to keep alpha channel) and overlay this layer |