scratch – Blame information for rev 120

Subversion Repositories:
Rev:
Rev Author Line No. Line
120 office 1 <?php
2  
3 /*
4 * This file is part of PHP-FFmpeg.
5 *
6 * (c) Strime <contact@strime.io>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11  
12 namespace FFMpeg\Filters\Waveform;
13  
14 use FFMpeg\Exception\RuntimeException;
15 use FFMpeg\Media\Waveform;
16  
17 class WaveformDownmixFilter implements WaveformFilterInterface
18 {
19  
20 /** @var boolean */
21 private $downmix;
22 /** @var integer */
23 private $priority;
24  
25 // By default, the downmix value is set to FALSE.
26 public function __construct($downmix = FALSE, $priority = 0)
27 {
28 $this->downmix = $downmix;
29 $this->priority = $priority;
30 }
31  
32 /**
33 * {@inheritdoc}
34 */
35 public function getDownmix()
36 {
37 return $this->downmix;
38 }
39  
40 /**
41 * {@inheritdoc}
42 */
43 public function getPriority()
44 {
45 return $this->priority;
46 }
47  
48 /**
49 * {@inheritdoc}
50 */
51 public function apply(Waveform $waveform)
52 {
53 $commands = array();
54  
55 foreach ($waveform->getAudio()->getStreams() as $stream) {
56 if ($stream->isAudio()) {
57 try {
58  
59 // If the downmix parameter is set to TRUE, we add an option to the FFMPEG command
60 if($this->downmix == TRUE) {
61 $commands[] = '"aformat=channel_layouts=mono"';
62 }
63  
64 break;
65  
66 } catch (RuntimeException $e) {
67  
68 }
69 }
70 }
71  
72 return $commands;
73 }
74 }