Transcodeit Add metadata to audio files

395 views Asked by At

I have found how to encode audio tracks to multiple formats, I am just struggling to try and find a way to attach specific metadata to the tracks when they are encoded. I would like to add, album artwork, artists name, track name, and genre etc.

I can see in the audio encoding parameters there are additional FFmpeg parameters you can set, however i am unsure what to use in order to set the metadata?

{
  "steps": {
  "imported": {
  "robot": "/s3/import",
  "result": true,
  "key": "AWS_KEY",
  "secret": "AWS_SECRET",
  "bucket": "BUCKET",
  "path": "CUSTOM-PATH"
},
"mp3": {
  "use": "imported",
  "robot": "/audio/encode",
  "result": true,
  "preset": "mp3",
  "ffmpeg": [],
  "ffmpeg_stack": "v2.2.3"
},
"wav": {
  "use": "imported",
  "robot": "/audio/encode",
  "result": true,
  "preset": "wav",
  "ffmpeg_stack": "v2.2.3"
},
"export": {
  "robot": "/s3/store",
  "use": [
    "mp3",
    "wav"
  ],
  "key": "AWS_KEY",
  "secret": "AWS_SECRET",
  "bucket": "BUCKET"
}
1

There are 1 answers

0
danr On

You can use the "/meta/write" robot as described here: 8.2 Metadata Writing

Here's an example from the official demos:

<html>
<head><title>Some demo title</title></head>
<body>
<form action="/uploads" enctype="multipart/form-data" method="POST">
  <input type="file" name="my_file" multiple="multiple" />
</form>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//assets.transloadit.com/js/jquery.transloadit2-v2-latest.js"></script>
<script type="text/javascript">
$(function() {
  $('form').transloadit({
    wait: true,
    triggerUploadOnFileSelection: true,

    params: {
      auth: { key: "YOUR_AUTH_KEY" }, 
      steps: {
        metadata: {
          use: ":original",
          robot: "/meta/write",
          result: true,
          data_to_write: {
            album: "Discovery",
            artist: "Daft Punk",
            year: "1999",
          }
        }
      }
    }
  });
});
</script>
</body>
</html>