Updating multiple metadata in mp3

Archived from the Transloadit support forum. Originally posted on May 12, 2011; details may be outdated, see our docs for current behavior. Original thread

Im trying to update the metadata in a mp3 file that im uploading through the PHP SDK. in this discussion: https://community.transloadit.com/t/external_id/tender-problems-52
Felix recommend sending this json object step:

"mp3_320": {
  "use": ":original",
  "robot": "/audio/encode",
  "ffmpeg": [
    {
      "f": "mp3",
       "acodec": "libmp3lame",
       "ab": "320k",
    },
    { "metadata": "artist=\"The Artist\"" },
    { "metadata": "title=\"Track Title\"" },
    { "metadata": "album=\"The Album\"" }
  ]
}

when i convert this json to php code to send it throught the options params in createAssembly() i’m getting an error from Transloadit:

'error' => string 'AUDIO_ENCODE_VALIDATION' (length=23)
'message' => string 'Invalid ffmpeg parameter, needs to be object.' (length=45)

My $options array is like this:

$options = array(
    'files' => array($path),
    'params' => array(
        'steps' => array(
            "mp3_192" => array(
                "robot" => "/audio/encode",
                "ffmpeg" => array(
                    array(
                        "f" => "mp3",
                        "acodec" => "libmp3lame",
                        "ab" => "192k",
                    ),
                    array("metadata" => "artist=\"The Artist\""),
                    array("metadata" => "title=\"The title\""),
                )
            ),
            'export' => array(
                "robot" => "/s3/store",
                "key" => "xxxxxxxxx",
                "secret" => "xxxxxxxxxxxxxx",
                "bucket" => "xxxxxxx",
                "path" => 'tests/${unique_prefix}/${file.url_name}'
            )
        )
    )
);

if i try uploading it with the normal format everything works ok

$options = array(
    'files' => array($path),
    'params' => array(
        'steps' => array(
            "mp3_192" => array(
                "robot" => "/audio/encode",
                "ffmpeg" => array(
                    "f" => "mp3",
                    "acodec" => "libmp3lame",
                    "ab" => "192k",
                    "metadata" => "artist=\"The Artist\""
                )
            ),
            'export' => array(
                "robot" => "/s3/store",
                "key" => "xxxxxxxxx",
                "secret" => "xxxxxxxxxx",
                "bucket" => "xxxxxxx",
                "path" => 'tests/${unique_prefix}/${file.url_name}'
            )
        )
    )
);

but as you can see, only one metadata convention can be sent. I try to put an array inside the “metadata” key, but it didnt work neither.

Do you know if there it is a way to do this?
thanks in advance!
gonzalo

We made this even simpler, use an object for you ffmpeg options, and do:

"metadata": ["artist=\"The Artist\"", "title=\"Track Title\"", "album=\"The Album\""] }

That should work.

Excellent! Thats works like a charm!

Thank you!
gonzalo

Sweet, glad it’s working!