public override void HandleExecute(ChainRequest request)
        {
            //1. Step Setup
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            myEncodigSupport      = new EncoderSupport(_MediaServicesContext);
            myBlobManager         = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
            IjsonKeyValue dotControlData = myBlobManager.GetDotControlData(myRequest.ButlerRequest.ControlFileUri);
            IjsonKeyValue processData    = new jsonKeyValue(myBlobManager.GetButlerConfigurationValue(ProcessConfigKeys.DefualtPartitionKey, myRequest.ProcessTypeId + ".config"));

            IjsonKeyValue allPorcessData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId);

            //2. Get Current Asset
            IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();

            //3. JOB parameters
            string OutputAssetsName   = asset.Name + "_mbGridEncode";
            string JobName            = string.Format("GridEncodeStep_{1}_{0}", myRequest.ProcessInstanceId, asset.Name);
            string MediaProcessorName = myEncodigSupport.GetMediaProcessorName(allPorcessData, DotControlConfigKeys.GridEncodeStepMediaProcessorName, "Media Encoder Standard");

            string[] encodeConfigurations = myEncodigSupport.GetLoadEncodignProfiles(dotControlData, processData, DotControlConfigKeys.GridEncodeStepEncodeConfigList, myRequest.ButlerRequest.MezzanineFiles, myRequest.ProcessConfigConn, this.StepConfiguration);

            //4. Execute JOB and Wait
            IJob currentJob = myEncodigSupport.ExecuteGridJob(OutputAssetsName, JobName, MediaProcessorName, encodeConfigurations, "Grid Task", asset.Id, MyEncodigSupport_OnJobError, MyEncodigSupport_JobUpdate);

            //9. Update AssetID
            myRequest.AssetId = currentJob.OutputMediaAssets.FirstOrDefault().Id;
        }
예제 #2
0
        public override void HandleExecute(ChainRequest request)
        {
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            myBlobManager         = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
            allPorcessData        = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId);
            //1. Select VTT
            IAsset asset   = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();
            var    vttFile = (from f in asset.AssetFiles select f).Where(f => f.Name.EndsWith(".vtt")).FirstOrDefault();

            vttFile.Download(myRequest.ProcessInstanceId);
            string readText = File.ReadAllText(myRequest.ProcessInstanceId);

            System.IO.File.Delete(myRequest.ProcessInstanceId);

            //2. Cognitive Service
            IAzureMLTextAnalyticsClient myClient = new AzureMLTextAnalyticsClient();
            Language myLanguage   = (Language)Enum.Parse(typeof(Language), allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepLanguage));
            string   apiURL       = allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepApiURL);
            string   apiKey       = allPorcessData.Read(DotControlConfigKeys.TextAnalitycsStepApiKey);
            FileType ft           = FileType.VTT;
            string   jsonResponse = myClient.keyPhrasesTxt(readText, myLanguage, ft, apiURL, apiKey);

            //3. Add File
            string assetFileName = "keyPhrases." + myRequest.ProcessInstanceId + ".txt";
            var    xf            = asset.AssetFiles.Create(assetFileName);

            File.WriteAllText(assetFileName, jsonResponse);
            xf.Upload(assetFileName);
            File.Delete(myRequest.ProcessInstanceId);
            asset.Update();
        }
예제 #3
0
        public override void HandleExecute(ChainRequest request)
        {
            //1. Setup Step
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(new MediaServicesCredentials(myRequest.MediaAccountName, myRequest.MediaAccountKey));
            myEncodigSupport      = new EncoderSupport(_MediaServicesContext);
            myBlobManager         = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
            allPorcessData        = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId);

            //2. Create Jobs definition
            List <IJobConfiguration> myJobsDefinition = GetJobConfig(myRequest.ProcessInstanceId, myRequest.AssetId, "");

            //3. Execute
            myEncodigSupport.ExecuteMultiJobTaskEncode(myJobsDefinition, myRequest.ProcessInstanceId, MyEncodigSupport_OnJobError, MyEncodigSupport_JobUpdate);

            //4. Update context with output asset ID
            myRequest.AssetId = UpdateOutPut(myJobsDefinition, this.consolidateId);

            //5. Copy all asset files to Output asset and delete all temp Asset
            ConsolidateOutputs(myJobsDefinition, consolidateId);
        }
예제 #4
0
        public override void HandleExecute(ChainRequest request)
        {
            myRequest             = (ButlerProcessRequest)request;
            _MediaServicesContext = new CloudMediaContext(myRequest.MediaAccountName, myRequest.MediaAccountKey);
            myBlobManager         = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
            //IjsonKeyValue dotControlData = myBlobManager.GetDotControlData(myRequest.ButlerRequest.ControlFileUri);
            IjsonKeyValue dotControlData = myBlobManager.GetProcessConfig(myRequest.ButlerRequest.ControlFileUri, myRequest.ProcessTypeId);

            string searchServiceName = dotControlData.Read(DotControlConfigKeys.InjectTTMLSearchServiceName);
            string adminApiKey       = dotControlData.Read(DotControlConfigKeys.InjectTTMLadminApiKey);
            string indexName         = dotControlData.Read(DotControlConfigKeys.InjectTTMLindexName);

            SearchServiceClient serviceClient = new SearchServiceClient(searchServiceName, new SearchCredentials(adminApiKey));

            if (!serviceClient.Indexes.Exists(indexName))
            {
                CreateVideoTextIndex(serviceClient, indexName);
            }

            IAsset asset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myRequest.AssetId).FirstOrDefault();

            UploadTTML(serviceClient, indexName, asset);
        }