AWS的IOS SDK - 弹性跨codeR工作HTTP POST请求 [英] AWS ios SDK - http post request for elastic transcoder job

查看:231
本文介绍了AWS的IOS SDK - 弹性跨codeR工作HTTP POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

展望AWS弹性反codeR,并有几个问题:

  1. 有没有使用反式codeR摆在首位,为我的用例显著的价值?我在做iOS​​应用程序,允许用户选择视频。当他们做到这一点,我上传到一个S3桶。据我了解,我应该使用弹性跨codeR到c的视频,然后转$ C $和拖放在HLS格式的第二桶。这是否有意义,否则我就只是作为小康省去了转换步骤,因为我只是创造iOS设备上的内容,然后在iOS设备上的流?

  2. 假设有一定的价值做流水线的工作,我有一个实施的问题:如果我使用的是IOS SDK是有办法解决的手工创建的弹性规定的HTTP授权头的跨codeR请求的文档?我没有看到具体的跨codeR任何方法时,我以x code我工作,但我只是想知道是否有某种方式来使用类似AWSRequest(相对于NSMutableURLRequest),其会救我做的授权密钥的麻烦。我看了看,通过了一大堆文件,包括IOS SDK示例项目,但没有看到使用像AWSRequest东西。请帮我指出了正确的方向!

code:我已经建立了JSON结构的基础上这里的文档的请求主体:<一href="http://docs.aws.amazon.com/elastictrans$c$cr/latest/developerguide/making-http-requests.html#http-request-header" rel="nofollow">http://docs.aws.amazon.com/elastictrans$c$cr/latest/developerguide/making-http-requests.html#http-request-header这是据我之前,我跑进授权头的复杂性:

 的println(我的JSON:\(jsonRequestString))

                VAR dateFormatter:NSDateFormatter = NSDateFormatter()
                dateFormatter.dateFormat =yyyyMMdd'T'HHmmss'Z'
                VAR dateString = dateFormatter.stringFromDate(日期)
                的println(dateString:\(dateString))
                VAR elasticTrans coderURLString:字符串=elastictrans coder.us-west-1.amazonaws.com
                VAR elasticTrans coderRequest:NSMutableURLRequest = NSMutableURLRequest(网址:NSURL(字符串:elasticTrans coderURLString)!)
                elasticTrans coderRequest.HTTPMethod =POST
                elasticTrans coderRequest.addValue(elastictrans coder.us-west-1.amazonaws.com,forHTTPHeaderField:主机)
                elasticTrans coderRequest.addValue(应用程序/ x-AMZ-JSON-1.0,forHTTPHeaderField:内容类型)
                elasticTrans coderRequest.addValue(dateString,forHTTPHeaderField:X-AMZ-日期)
                //占位符 - 需要补充的认证头域
                //占位符 - 需要补充的内容长度的头字段
                VAR的RequestData:NSData的= jsonRequestString.dataUsingEncoding(NSUTF8StringEncoding)!
                elasticTrans coderRequest.HTTPBody =的RequestData

                VAR elasticTrans coderSession = NSURLSession.sharedSession()

                VAR elasticTrans coderTask = elasticTrans coderSession.dataTaskWithRequest(elasticTrans coderRequest,completionHandler:{(elasticTrans coderData,响应误差)

                    的println(这里的错误:\(错误))
                    的println(这里的响应:\(响应))
                    的println(我在elasticTrans coderTask的完成处理程序)

                })//结束elasticTrans coderTask完成处理程序
                elasticTrans coderTask.resume()
 

很显然,我得到一个错误,当我运行此。

这是最接近我的问题,但它并没有一个答案:<一href="http://stackoverflow.com/questions/24234815/rest-call-with-amazon-ios-sdk-to-amazon-elastic-trans$c$cr">Rest与调用亚马逊IOS SDK亚马逊弹性跨codeR

解决方案
  1. 在这个问题的答案完全取决于你的使用情况。亚马逊弹性横贯codeR可能是一个有价值的选择要转换的视频格式,创建缩略图,直观水印和字幕等,这些只是一些例子很多。你应该看看rel="nofollow">亚马逊弹性横贯codeR产品详细信息

  2. 如果您决定使用弹性横贯codeR ,你应该建立从的 AWS管理控制台,因为它是一次性设置。它没有任何意义创建从移动设备上的管道。从移动设备,你应该只是视频文件上传到您的Amazon S3存储。后端服务器(如亚马逊的EC2和AWS弹性魔豆都是不错的选择)应监测桶和创造就业机会的弹性跨codeR。 AWS刚刚宣布 AWS LAMBDA ,你可能要检查它。一旦任务完成,您可以使用Amazon SNS得到通知。

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: http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/making-http-requests.html#http-request-header 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 = "elastictranscoder.us-west-1.amazonaws.com"
                var elasticTranscoderRequest:NSMutableURLRequest = NSMutableURLRequest(URL: NSURL(string: elasticTranscoderURLString)!)
                elasticTranscoderRequest.HTTPMethod = "POST"
                elasticTranscoderRequest.addValue("elastictranscoder.us-west-1.amazonaws.com", 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
                elasticTranscoderTask.resume()

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

解决方案

  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.

这篇关于AWS的IOS SDK - 弹性跨codeR工作HTTP POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆