Fix missing audio artwork metadata on multiple exports (#340)
When the metadata filter is applied on an `Audio` media, the `artwork` parameter was being unset from the metadata array. Saving the same `Audio` instance into multiple formats generated the correct commands for the first export, but the subsequent commands were missing the `artwork` parameter. This commit fixes this issue by copying (by value) the `metaArr` property to a local variable each time the filter is applied.
This commit is contained in:
parent
eebdbea1f7
commit
e8b247891b
2 changed files with 11 additions and 7 deletions
|
|
@ -36,17 +36,20 @@ class AddMetadataFilter implements AudioFilterInterface
|
||||||
|
|
||||||
public function apply(Audio $audio, AudioInterface $format)
|
public function apply(Audio $audio, AudioInterface $format)
|
||||||
{
|
{
|
||||||
if (is_null($this->metaArr))
|
$meta = $this->metaArr;
|
||||||
|
|
||||||
|
if (is_null($meta)) {
|
||||||
return ['-map_metadata', '-1', '-vn'];
|
return ['-map_metadata', '-1', '-vn'];
|
||||||
|
}
|
||||||
|
|
||||||
$metadata = [];
|
$metadata = [];
|
||||||
|
|
||||||
if (array_key_exists("artwork", $this->metaArr)) {
|
if (array_key_exists("artwork", $meta)) {
|
||||||
array_push($metadata, "-i", $this->metaArr['artwork'], "-map", "0", "-map", "1");
|
array_push($metadata, "-i", $meta['artwork'], "-map", "0", "-map", "1");
|
||||||
unset($this->metaArr['artwork']);
|
unset($meta['artwork']);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->metaArr as $k => $v) {
|
foreach ($meta as $k => $v) {
|
||||||
array_push($metadata, "-metadata", "$k=$v");
|
array_push($metadata, "-metadata", "$k=$v");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@ class AudioMetadataTest extends TestCase
|
||||||
$filters = new AudioFilters($audio);
|
$filters = new AudioFilters($audio);
|
||||||
$filters->addMetadata(array('genre' => 'Some Genre', 'artwork' => "/path/to/file.jpg"));
|
$filters->addMetadata(array('genre' => 'Some Genre', 'artwork' => "/path/to/file.jpg"));
|
||||||
$this->assertEquals(array(0 => "-i", 1 => "/path/to/file.jpg", 2 => "-map", 3 => "0", 4 => "-map", 5 => "1", 6 => "-metadata", 7 => "genre=Some Genre"), $capturedFilter->apply($audio, $format));
|
$this->assertEquals(array(0 => "-i", 1 => "/path/to/file.jpg", 2 => "-map", 3 => "0", 4 => "-map", 5 => "1", 6 => "-metadata", 7 => "genre=Some Genre"), $capturedFilter->apply($audio, $format));
|
||||||
|
$this->assertEquals(array(0 => "-i", 1 => "/path/to/file.jpg", 2 => "-map", 3 => "0", 4 => "-map", 5 => "1", 6 => "-metadata", 7 => "genre=Some Genre"), $capturedFilter->apply($audio, $format));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemoveMetadata()
|
public function testRemoveMetadata()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue