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
|
|
@ -8,7 +8,7 @@
|
|||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
|
||||
namespace FFMpeg\Filters\Audio;
|
||||
|
||||
use FFMpeg\Filters\Audio\AudioFilterInterface;
|
||||
|
|
@ -16,7 +16,7 @@ use FFMpeg\Format\AudioInterface;
|
|||
use FFMpeg\Media\Audio;
|
||||
|
||||
class AddMetadataFilter implements AudioFilterInterface
|
||||
{
|
||||
{
|
||||
/** @var Array */
|
||||
private $metaArr;
|
||||
/** @var Integer */
|
||||
|
|
@ -36,17 +36,20 @@ class AddMetadataFilter implements AudioFilterInterface
|
|||
|
||||
public function apply(Audio $audio, AudioInterface $format)
|
||||
{
|
||||
if (is_null($this->metaArr))
|
||||
$meta = $this->metaArr;
|
||||
|
||||
if (is_null($meta)) {
|
||||
return ['-map_metadata', '-1', '-vn'];
|
||||
}
|
||||
|
||||
$metadata = [];
|
||||
|
||||
if (array_key_exists("artwork", $this->metaArr)) {
|
||||
array_push($metadata, "-i", $this->metaArr['artwork'], "-map", "0", "-map", "1");
|
||||
unset($this->metaArr['artwork']);
|
||||
if (array_key_exists("artwork", $meta)) {
|
||||
array_push($metadata, "-i", $meta['artwork'], "-map", "0", "-map", "1");
|
||||
unset($meta['artwork']);
|
||||
}
|
||||
|
||||
foreach ($this->metaArr as $k => $v) {
|
||||
foreach ($meta as $k => $v) {
|
||||
array_push($metadata, "-metadata", "$k=$v");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue