5

I would like to add an option for users to upload videos to a website. I am wondering about AWS Elemental MediaConvert for handling the necessary transcoding.

Using the aws sdk, I can submit a job to aws Elemental MediaConvert for transcoding like so...

const result = await new AWS.MediaConvert({apiVersion: '2017-08-29'}).createJob(params).promise()

...However this just returns the newly created job. I cannot seem to see anywhere how to actually know when the job completes. I am wondering: Is there a simple way to know when the job actually completes (or fails) so that I can send a response back to the client?

user1031947
  • 6,294
  • 16
  • 55
  • 88

2 Answers2

5

One way to do this is by using CloudWatch Events and Simple Notification Service (SNS).

You'd have to:

  1. Set up an HTTP endpoint on your web server to handle incoming notifications.
  2. Create an SNS topic and subscribe your HTTP endpoint to the topic.
  3. Set up the CloudWatch Event Rule just as zolaemil described and set the target of the event to the SNS topic.

When your MediaConvert job completes, it will trigger the CloudWatch Event and will send the job result to SNS, which will then forward it to your web server. So you're effectively pushing from MediaConvert to your web server instead of polling.

alenz
  • 84
  • 8
2

You can set up Cloudwatch rules based off MediaConvert events. E.g.

{
  "source": [
    "aws.mediaconvert"
  ],
  "detail-type": [
    "MediaConvert Job State Change"
  ],
  "detail": {
    "status": [
      "COMPLETE"
    ]
  }
}

which can target a number of things, including Lambda functions, SNS topics and more.

zolaemil
  • 21
  • 1
  • Thanks for the reply -- I looked at Cloudwatch rules, however as far as I can tell, it can only be used to target a new service... ie I can use it to call a new lambda.... But that doesn't help me if I am waiting to send a response back to the client... I need a way to know when mediaconvert completes, from within the calling code that originally creates the job. – user1031947 Feb 12 '19 at 17:51
  • 1
    To strictly answer your question, you'd need to poll the job based on the ID you get back when you created it. However, you really don't want block your lambda while the conversion is in progress! This way you'd essentially be paying twice for the conversion: once for MediaConvert, plus the duration of the lambda while it's waiting and doing nothing useful. And since MediaConvert jobs are generally process-intensive, this can be pretty significant, not no mention the possibility that the conversion taking longer than the max duration of your lambda. – zolaemil Feb 15 '19 at 17:59
  • @user1031947 there is not way to do it as it is an asynchronous invocation. What you can do is by polling or using a websocket. Unfortunately is not really simple – Matteo May 07 '20 at 01:41
  • Any idea what might cause the complete event to not be called consistently? – Scott Wilson Dec 17 '20 at 22:18