The AWS Elastic Transcoder Service.
public static void BuildRuntimePipeline(TestContext t) { _client = new MockElasticTranscoderClient(new BasicAWSCredentials("access_key", "secret_key"), new AmazonElasticTranscoderConfig { ServiceURL = @"http://EtsListPresets" }); }
public static void Transcode(string inputS3Key,string outputS3Key, string bucketName) { var email = "*****@*****.**"; // Create a topic the the pipeline to used for notifications var topicArn = CreateTopic(email); // Create the IAM role for the pipeline var role = CreateIamRole(); var etsClient = new AmazonElasticTranscoderClient(); var notifications = new Notifications() { Completed = topicArn, Error = topicArn, Progressing = topicArn, Warning = topicArn }; // Create the Elastic Transcoder pipeline for transcoding jobs to be submitted to. //var pipeline = etsClient.CreatePipeline(new CreatePipelineRequest //{ // Name = "MyVideos" + UNIQUE_POSTFIX, // InputBucket = bucketName, // OutputBucket = bucketName, // Notifications = notifications, // Role = role.Arn //}).Pipeline; var listPipeLines = etsClient.ListPipelines(); var pipeline=listPipeLines.Pipelines[0]; // Create a job to transcode the input file etsClient.CreateJob(new CreateJobRequest { PipelineId = pipeline.Id, Input = new JobInput { AspectRatio = "auto", Container = "auto", FrameRate = "auto", Interlaced = "auto", Resolution = "auto", Key = inputS3Key }, Output =( new CreateJobOutput { ThumbnailPattern = "", Rotate = "0", // Generic 720p: Go to http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/create-job.html#PresetId to see a list of some // of the support presets or call the ListPresets operation to get the full list of available presets PresetId = "1351620000000-100010", Key = outputS3Key.Substring(0,outputS3Key.LastIndexOf("."))+".mp4" }) }); }
public async Task <S3Event> FunctionHandler(S3Event input, ILambdaContext context) { if (input.Records.Count == 0) { return(input); } //do we need to specify a region?? string pipelineId = Environment.GetEnvironmentVariable("ELASTIC_TRANSCODER_PIPELINE_ID"); var key = input.Records[0].S3.Object.Key; // decode var sourceKey = System.Net.WebUtility.UrlDecode(key.Replace('+', ' ')); //remove file extension var outputKey = sourceKey.Split('.')[0]; var request = new Amazon.ElasticTranscoder.Model.CreateJobRequest { PipelineId = pipelineId, OutputKeyPrefix = outputKey + "/", Input = new Amazon.ElasticTranscoder.Model.JobInput { Key = sourceKey }, Outputs = { new Amazon.ElasticTranscoder.Model.CreateJobOutput { Key = outputKey + "-1080p" + ".mp4", PresetId = "1351620000001-000001" //Generic 1080p }, new Amazon.ElasticTranscoder.Model.CreateJobOutput { Key = outputKey + "-720p" + ".mp4", PresetId = "1351620000001-000010" //Generic 720p }, new Amazon.ElasticTranscoder.Model.CreateJobOutput { Key = outputKey + "-web-720p" + ".mp4", PresetId = "1351620000001-100070" //Web Friendly 720p } } }; var client = new Amazon.ElasticTranscoder.AmazonElasticTranscoderClient(); await client.CreateJobAsync(request); return(input); }
// Test exception parsing with selected services public void TestExceptions() { var fakeData = "obviously-super-duper-fake-data"; using (var client = new Amazon.Lightsail.AmazonLightsailClient()) { var ex = AssertExtensions.ExpectException <Amazon.Lightsail.Model.NotFoundException>(() => { client.GetInstance(new Amazon.Lightsail.Model.GetInstanceRequest { InstanceName = fakeData }); }); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var client = new Amazon.ElasticTranscoder.AmazonElasticTranscoderClient()) { var ex = AssertExtensions.ExpectException <Amazon.ElasticTranscoder.Model.ValidationException>(() => { client.DeletePipeline(new Amazon.ElasticTranscoder.Model.DeletePipelineRequest { Id = fakeData }); }); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var ddb = new Amazon.DynamoDBv2.AmazonDynamoDBClient()) { var ex = AssertExtensions.ExpectException <Amazon.DynamoDBv2.Model.ResourceNotFoundException>(() => ddb.DescribeTable("fakey-mcfake-table")); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var client = new Amazon.Pinpoint.AmazonPinpointClient()) { var ex = AssertExtensions.ExpectException <Amazon.Pinpoint.Model.NotFoundException>(() => { client.DeleteCampaign(new Amazon.Pinpoint.Model.DeleteCampaignRequest { ApplicationId = fakeData, CampaignId = fakeData }); }); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var client = new Amazon.Batch.AmazonBatchClient()) { var ex = AssertExtensions.ExpectException <Amazon.Batch.Model.ClientException>(() => { client.UpdateComputeEnvironment(new Amazon.Batch.Model.UpdateComputeEnvironmentRequest { ComputeEnvironment = fakeData }); }); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var client = new Amazon.Glacier.AmazonGlacierClient()) { var ex = AssertExtensions.ExpectException <Amazon.Glacier.Model.ResourceNotFoundException>(() => { client.InitiateMultipartUpload(new Amazon.Glacier.Model.InitiateMultipartUploadRequest { AccountId = "-", ArchiveDescription = fakeData, VaultName = fakeData, PartSize = 123 }); }); Assert.AreEqual(ErrorType.Unknown, ex.ErrorType); } using (var client = new Amazon.IdentityManagement.AmazonIdentityManagementServiceClient()) { var ex = AssertExtensions.ExpectException <Amazon.IdentityManagement.Model.NoSuchEntityException>(() => { client.AttachGroupPolicy(new Amazon.IdentityManagement.Model.AttachGroupPolicyRequest { PolicyArn = fakeData, GroupName = fakeData }); }); Assert.AreEqual(ErrorType.Sender, ex.ErrorType); } }