Using generated waveform in `/video/merge`

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

Hej,

I am quite new to Transloadit but already love the service! However, I am currently stuck to get the following to work:

  1. Upload audio file and encode to MP3 using /audio/encode
  2. Generate a waveform image of the MP3 using /audio/waveform
  3. Merge MP3 and waveform image to a video using /video/merge
  4. Store it.

The single steps are pretty easy to achieve.

I am stuck at #3 since this robot requires an image URL instead of making use a of previous step.

Is it possible to make this workflow work in one template?

This is my template so far:

{
  "steps": {
    "mp3": {
      "robot": "/audio/encode",
      "preset": "mp3"
    },
    "waveform": {
      "robot": "/audio/waveform",
      "use": "mp3",
      "width": 1280,
      "height": 720,
      "background_color": "000000FF",
      "center_color": "FFFFFFFF",
      "outer_color": "CCE3D3FF"
    },
    "video": {
      "robot": "/video/merge",
      "use": ":original",
      "image_url": "[HELP!]",
      "preset": "ipad-high",
      "width": 1280,
      "height": 720,
      "resize_strategy": "fillcrop"
    }
  }
}

Thanks for any suggestions on that!

Hi Dennis,

Hey this seems like a very cool use-case that we definitely will want to support. I’m going to talk with my team to figure out the best way and get back to you very soon.

Thanks!

Kevin

Hi Kevin,

Yeah, sounds great.

Thanks,
Dennis

Hi Dennis,

So I discussed with the team and it should be possible to add an intermediate export step, and then use path variables to refer to those urls in the merge step.

We understand this is not very efficient, and your use-case made us realize the /video/merge bot should really accept images from a previous step. And /http/import, could have been used to acquire the image url.

It will take some time to make these changes though, in the meantime would you like to try the workaround? We can help you with more details if needed.

Kind regards,
Kevin

Hi Dennis,

We’ve been working on the neccessary improvements to our API and are planning to launch it tomorrow morning. I won’t be here then, but my collegue Tim is going to run the show, and I’ll ask him to leave an update here if all went as planned.

Have a nice evening!

Kevin

Hey Dennis,

I am currently deploying the patch that we worked on yesterday for this. It should become available within the next 30 minutes and will allow you to support the following syntax:

merge: {
  robot : '/video/merge',
  use   : {
    steps : [
      {name: 'some_step', as: 'audio'},
      {name: 'some_other_step', as: 'image'}
    ]
  }
}

I’ll let you know here once it’s deployed so that you can take it for a spin.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Hey Dennis,

the new syntax is available now. Please let us know how it works for you.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos

Hej Kevin, hej Tim,

Sorry for getting back that late. You guys are amazing!! I will check this out later and post an update.

Many thanks,
Dennis

Hej Tim,

I have just tested the newly introduced syntax and it works like a charm.
Many thanks for your effort and the great service you are providing!

In case this scenario is of interest for someone else, here is the completed template from the beginning of this thread, which performs all necessary steps:

  1. Encode an uploaded audio file to MP3
  2. Generates a waveform image
  3. Merge the two in a video file
  4. Store it — in this case to Rackspace Cloudfiles (UK), with a unique prefix
{
  "steps": {
    "mp3": {
      "robot": "/audio/encode",
      "preset": "mp3"
    },
    "waveform": {
      "robot": "/audio/waveform",
      "use": "mp3",
      "width": 1280,
      "height": 720,
      "background_color": "000000FF",
      "center_color": "FFFFFFFF",
      "outer_color": "CCE3D3FF"
    },
    "merge": {
      "robot": "/video/merge",
      "use": {
        "steps": [
          {"name": "mp3", "as": "audio"},
          {"name": "waveform", "as": "image"}
        ]
      },
      "preset": "ipad-high",
      "width": 1280,
      "height": 720,
      "resize_strategy": "fillcrop"
    },
    "store": {
      "use": "merge",
      "robot": "/cloudfiles/store",
      "user": "***",
      "key": "REDACTED",
      "account_type": "uk",
      "container": "***",
      "path": "audio/${unique_prefix}-${previous_step.name}.${file.ext}"
    }
  }
}

Regards,
Dennis

Thank you for the feedback, Dennis!

We’ll update our documentation soon and will also add some demos that make use of the new syntax. The old image_url parameter of the merge robot will most likely be deprecated.

Kind regards,
Tim

Co-Founder Transloadit
@tim_kos