AWS ios SDK - http post request for elastic transcoder job

Looking into AWS elastic transcoder, and have a few questions:

  1. Is there significant value using the transcoder in the first place, for my use case? I'm making an ios app that allows users to select a video. When they do this I'm uploading it to an S3 bucket. As I understand it, I should use elastic transcoder to then transcode those videos and drop them in a second bucket in hls format. Does this make sense, or would I be just as well off eliminating the transcoding step since I'm only creating content on ios devices and then streaming it on ios devices?

  2. Assuming there is some value to doing the pipeline jobs, I have an implementation question: if I'm using the ios SDK is there a way to get around the manual creation of the http authorization header specified in the elastic transcoder request docs? I don't see any methods specific to the transcoder when I'm working in xcode, but I'm just wondering if there is some way to use something like AWSRequest (as opposed to NSMutableURLRequest) that would save me the trouble of making the authorization key. I looked through a whole bunch of documentation, including the ios SDK sample projects, but did not see anything like AWSRequest being used. Please help point me in the right direction!

Code: I've already built the json structure for the body of the request based on the documentation here: Here is as far as I got before I ran into the complexity of the authorization header:

println("my json: \(jsonRequestString)")

                var dateFormatter:NSDateFormatter = NSDateFormatter()
                dateFormatter.dateFormat = "yyyyMMdd'T'HHmmss'Z'"
                var dateString = dateFormatter.stringFromDate(date)
                println("dateString: \(dateString)")
                var elasticTranscoderURLString:String = ""
                var elasticTranscoderRequest:NSMutableURLRequest = NSMutableURLRequest(URL: NSURL(string: elasticTranscoderURLString)!)
                elasticTranscoderRequest.HTTPMethod = "POST"
                elasticTranscoderRequest.addValue("", forHTTPHeaderField: "Host")
                elasticTranscoderRequest.addValue("application/x-amz-json-1.0", forHTTPHeaderField: "Content-Type")
                elasticTranscoderRequest.addValue(dateString, forHTTPHeaderField: "x-amz-date")
                //placeholder - need to add authorization header field
                //placeholder - need to add content-length header field
                var requestData: NSData = jsonRequestString.dataUsingEncoding(NSUTF8StringEncoding)!
                elasticTranscoderRequest.HTTPBody = requestData

                var elasticTranscoderSession = NSURLSession.sharedSession()

                var elasticTranscoderTask = elasticTranscoderSession.dataTaskWithRequest(elasticTranscoderRequest, completionHandler: {(elasticTranscoderData, response, error) in

                    println("here's the error: \(error)")
                    println("here's the response: \(response)")
                    println("I'm in the completion handler of elasticTranscoderTask")

                })//end elasticTranscoderTask completion handler

Obviously I get an error when I run this.

this is the closest thing to my question, but it does not have an answer: Rest call with amazon ios sdk to amazon elastic transcoder

Answers 1

    1. The answer to this question is entirely up to your use case. Amazon Elastic Transcoder can be a valuable option to convert the video format and create thumbnails, visual watermarks, and captions, etc. These are just a few of many examples. You should check out Amazon Elastic Transcoder Product Details.

    2. If you decide to use the Elastic Transcoder, you should set up a pipeline from the AWS Management Console because it is a one-time setup. It does not make sense to create a pipeline from mobile devices. From mobile devices, you should just upload video files to your Amazon S3 bucket. A backend server (e.g. Amazon EC2 and AWS Elastic Beanstalk are both good options) should monitor the bucket and create jobs for Elastic Transcoder. AWS just announced AWS Lambda, and you may want to check it. Once the job is done, you can use Amazon SNS to get notified.

Related Articles