public static async Task <MediaInfoProcess> RunAsync(params string[] args) { var mediaInfoProcess = new MediaInfoProcess(args); await mediaInfoProcess.RunAsync(); return(mediaInfoProcess); }
internal static async Task ProcessJobAssignmentAsync(AmeServiceWorkerRequest @event) { var resourceManager = @event.Request.GetAwsV4ResourceManager(); var table = new DynamoDbTable(@event.Request.StageVariables["TableName"]); var jobAssignmentId = @event.JobAssignmentId; try { // 1. Setting job assignment status to RUNNING await UpdateJobAssignmentStatusAsync(resourceManager, table, jobAssignmentId, "RUNNING", null); // 2. Retrieving WorkflowJob var ameJob = await RetrieveAmeJobAsync(resourceManager, table, jobAssignmentId); // 3. Retrieve JobProfile var jobProfile = await RetrieveJobProfileAsync(resourceManager, ameJob); // 4. Retrieve job inputParameters var jobInput = ameJob.JobInput; // 5. Check if we support jobProfile and if we have required parameters in jobInput ValidateJobProfile(jobProfile, jobInput); S3Locator inputFile; if (!jobInput.TryGet <S3Locator>(nameof(inputFile), out inputFile)) { throw new Exception("Invalid or missing input file."); } S3Locator outputLocation; if (!jobInput.TryGet <S3Locator>(nameof(outputLocation), out outputLocation)) { throw new Exception("Invalid or missing output location."); } MediaInfoProcess mediaInfoProcess; if (inputFile is HttpEndpointLocator httpEndpointLocator && !string.IsNullOrWhiteSpace(httpEndpointLocator.HttpEndpoint)) { Logger.Debug("Running MediaInfo against " + httpEndpointLocator.HttpEndpoint); mediaInfoProcess = await MediaInfoProcess.RunAsync("--Output=EBUCore_JSON", httpEndpointLocator.HttpEndpoint); } else if (inputFile is S3Locator s3Locator && !string.IsNullOrWhiteSpace(s3Locator.AwsS3Bucket) && !string.IsNullOrWhiteSpace(s3Locator.AwsS3Key)) { var s3GetResponse = await(await s3Locator.GetClientAsync()).GetObjectAsync(s3Locator.AwsS3Bucket, s3Locator.AwsS3Key); var localFileName = "/tmp/" + Guid.NewGuid().ToString(); await s3GetResponse.WriteResponseStreamToFileAsync(localFileName, false, CancellationToken.None); Logger.Debug("Running MediaInfo against " + localFileName); mediaInfoProcess = await MediaInfoProcess.RunAsync("--Output=EBUCore_JSON", localFileName); File.Delete(localFileName); }
public async Task ExecuteAsync(WorkerJobHelper <AmeJob> job) { S3Locator inputFile; if (!job.JobInput.TryGet(nameof(inputFile), out inputFile)) { throw new Exception("Unable to parse input file as S3Locator"); } S3Locator outputLocation; if (!job.JobInput.TryGet(nameof(outputLocation), out outputLocation)) { throw new Exception("Unable to parse output location as S3Locator"); } MediaInfoProcess mediaInfoProcess; if (inputFile is HttpEndpointLocator httpEndpointLocator && !string.IsNullOrWhiteSpace(httpEndpointLocator.HttpEndpoint)) { Logger.Debug("Running MediaInfo against " + httpEndpointLocator.HttpEndpoint); mediaInfoProcess = await MediaInfoProcess.RunAsync("--Output=EBUCore_JSON", httpEndpointLocator.HttpEndpoint); }