4

I'm doing a CMS site with node.js, for handle the user posted video, I decided to employ the amazon's Elastic Transcoder service. I already figured out how to create a job and transcode the video with aws-sdk for node.js, but one issue still stucking me.

My site also handle user posted pictures, after received their post, I will display a preview of the picture, and waiting for user confrim. I can do this beacuse I got notified (in the callback) after the picture actually stroed on server(aws s3), then response user with the location of it.

Just like handle picture, I want display a preview of the video that user posted, but this case seems different, the transcoding is time consuming and happend in the cloud I don't know how to get notified when the job's status changed. (progress, finished, error etc. I want display those info to user)

According to the aws docs and manual, the job will send notification through the aws SNS, does it mean that I must subscribe the SNS manually after I created the job? That's over complicated I think.

is there any better solution for this? thanks.

John Rotenstein
  • 241,921
  • 22
  • 380
  • 470
Hetfield Joe
  • 1,443
  • 5
  • 15
  • 26

1 Answers1

3

You should look at the waitFor method, where you need to pass the job id and you can set event callback like this

var params = {
  Id: 'STRING_VALUE' /* required */
};
elastictranscoder.waitFor('jobComplete', params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
}); 
Max
  • 5,733
  • 4
  • 30
  • 44