scratch – Blame information for rev 115

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of PHP-FFmpeg.
5 *
6 * (c) Alchemy <info@alchemy.fr>
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\Audio;
13  
14 use FFMpeg\Filters\Audio\AudioFilterInterface;
15 use FFMpeg\Format\AudioInterface;
16 use FFMpeg\Media\Audio;
17  
18 class AddMetadataFilter implements AudioFilterInterface
19 {
20 /** @var Array */
21 private $metaArr;
22 /** @var Integer */
23 private $priority;
24  
25 function __construct($metaArr = null, $priority = 9)
26 {
27 $this->metaArr = $metaArr;
28 $this->priority = $priority;
29 }
30  
31 public function getPriority()
32 {
33 //must be of high priority in case theres a second input stream (artwork) to register with audio
34 return $this->priority;
35 }
36  
37 public function apply(Audio $audio, AudioInterface $format)
38 {
39 $meta = $this->metaArr;
40  
41 if (is_null($meta)) {
42 return ['-map_metadata', '-1', '-vn'];
43 }
44  
45 $metadata = [];
46  
47 if (array_key_exists("artwork", $meta)) {
48 array_push($metadata, "-i", $meta['artwork'], "-map", "0", "-map", "1");
49 unset($meta['artwork']);
50 }
51  
52 foreach ($meta as $k => $v) {
53 array_push($metadata, "-metadata", "$k=$v");
54 }
55  
56 return $metadata;
57 }
58 }