private IAsset CreateEncodingJob(IAsset workflow, IAsset video) { IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext); // Declare a new job. currentJob = _MediaServicesContext.Jobs.Create(myConfig.EncodingJobName); // Get a media processor reference, and pass to it the name of the // processor to use for the specific task. IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Media Encoder Premium Workflow"); // Create a task with the encoding details, using a string preset. ITask task = currentJob.Tasks.AddNew(myConfig.EncodigTaskName, processor, "", TaskOptions.None); // Specify the input asset to be encoded. task.InputAssets.Add(workflow); task.InputAssets.Add(video); // we add one asset // Add an output asset to contain the results of the job. // This output is specified as AssetCreationOptions.None, which // means the output asset is not encrypted. task.OutputAssets.AddNew(video.Name + "_mb", AssetCreationOptions.None); // Use the following event handler to check job progress. // The StateChange method is the same as the one in the previous sample currentJob.StateChanged += new EventHandler <JobStateChangedEventArgs>(myEncodigSupport.StateChanged); // Launch the job. currentJob.Submit(); //9. Revisa el estado de ejecución del JOB Task progressJobTask = currentJob.GetExecutionProgressTask(CancellationToken.None); //10. en vez de utilizar progressJobTask.Wait(); que solo muestra cuando el JOB termina //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal myEncodigSupport.WaitJobFinish(currentJob.Id); return(currentJob.OutputMediaAssets.FirstOrDefault()); }
private IAsset CreateEncodingJob(IAsset workflow, IAsset video) { IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext); // Declare a new job. currentJob = _MediaServicesContext.Jobs.Create(myConfig.EncodingJobName); // Get a media processor reference, and pass to it the name of the // processor to use for the specific task. IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Media Encoder Premium Workflow"); // Create a task with the encoding details, using a string preset. ITask task = currentJob.Tasks.AddNew(myConfig.EncodigTaskName, processor, "", TaskOptions.None); // Specify the input asset to be encoded. task.InputAssets.Add(workflow); task.InputAssets.Add(video); // we add one asset // Add an output asset to contain the results of the job. // This output is specified as AssetCreationOptions.None, which // means the output asset is not encrypted. task.OutputAssets.AddNew(video.Name + "_mb", AssetCreationOptions.None); // Use the following event handler to check job progress. // The StateChange method is the same as the one in the previous sample currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(myEncodigSupport.StateChanged); // Launch the job. currentJob.Submit(); //9. Revisa el estado de ejecución del JOB Task progressJobTask = currentJob.GetExecutionProgressTask(CancellationToken.None); //10. en vez de utilizar progressJobTask.Wait(); que solo muestra cuando el JOB termina //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal myEncodigSupport.WaitJobFinish(currentJob.Id); return currentJob.OutputMediaAssets.FirstOrDefault(); }
private IAsset WaterMArkJob() { IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext); string xmlEncodeProfile; if (!string.IsNullOrEmpty(this.StepConfiguration)) { xmlEncodeProfile = this.StepConfiguration; } else { string errorTxt = string.Format("[{0}] process Type {1} instance {2} has xmlEncodeProfile ", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId); throw new Exception(errorTxt); } // Declare a new job to contain the tasks IJob currentJob = _MediaServicesContext.Jobs.Create("Watermak Video base on " + xmlEncodeProfile + " " + myAssetOriginal.Name); // Set up the first Task to convert from MP4 to Smooth Streaming. // Read in task configuration XML string myEncoderProfile = myEncodigSupport.LoadEncodeProfile(xmlEncodeProfile, myRequest.ProcessConfigConn); // Get a media packager reference //IMediaProcessor processor = MediaButler.BaseProcess.MediaHelper.GetLatestMediaProcessorByName("Windows Azure Media Encoder",_MediaServicesContext); IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Windows Azure Media Encoder"); // Create a task with the conversion details, using the configuration data ITask task = currentJob.Tasks.AddNew("Task profile " + xmlEncodeProfile, processor, myEncoderProfile, TaskOptions.None); // Specify the input asset to be converted. task.InputAssets.Add(myAssetOriginal); // Add an output asset to contain the results of the job. task.OutputAssets.AddNew(myAssetOriginal.Name + "_mb", AssetCreationOptions.None); // Use the following event handler to check job progress. // The StateChange method is the same as the one in the previous sample currentJob.StateChanged += new EventHandler <JobStateChangedEventArgs>(StateChanged); // Launch the job. currentJob.Submit(); //9. Revisa el estado de ejecución del JOB Task progressJobTask = currentJob.GetExecutionProgressTask(CancellationToken.None); //10. en vez de utilizar progressJobTask.Wait(); que solo muestra cuando el JOB termina //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal myEncodigSupport.WaitJobFinish(currentJob.Id); return(currentJob.OutputMediaAssets.FirstOrDefault()); }
private void ConvertMP4toSmooth(IAsset assetToConvert) { //0 Helper IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext); string xmlEncodeProfile = "H264 Adaptive Bitrate MP4 Set 1080p.xml"; //if (this.StepConfiguration != null) if (!string.IsNullOrEmpty(this.StepConfiguration)) { //TODO:support storage and LABEL xmlEncodeProfile = this.StepConfiguration; } else { string txt = string.Format("StandarEncodeStep try to read StepConfiguration but it is not in configuration table! at {0} ", DateTime.Now.ToString()); Trace.TraceWarning(txt); } // Declare a new job to contain the tasks currentJob = _MediaServicesContext.Jobs.Create("Convert to Smooth Streaming job " + myAssetOriginal.Name); // Set up the first Task to convert from MP4 to Smooth Streaming. // Read in task configuration XML string configMp4ToSmooth = LoadEncodeProfile(xmlEncodeProfile); // Get a media packager reference //IMediaProcessor processor = GetLatestMediaProcessorByName("Windows Azure Media Encoder"); IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Windows Azure Media Encoder"); // Create a task with the conversion details, using the configuration data ITask task = currentJob.Tasks.AddNew("Task profile " + xmlEncodeProfile, processor, configMp4ToSmooth, TaskOptions.None); // Specify the input asset to be converted. task.InputAssets.Add(assetToConvert); // Add an output asset to contain the results of the job. task.OutputAssets.AddNew(assetToConvert.Name+"_mb", AssetCreationOptions.None); // Use the following event handler to check job progress. // The StateChange method is the same as the one in the previous sample //currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged); currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(myEncodigSupport.StateChanged); // Launch the job. currentJob.Submit(); //9. Revisa el estado de ejecución del JOB Task progressJobTask = currentJob.GetExecutionProgressTask(CancellationToken.None); //10. en vez de utilizar progressJobTask.Wait(); que solo muestra cuando el JOB termina //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal myEncodigSupport.WaitJobFinish(currentJob.Id); }
private IAsset WaterMArkJob() { IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext); string xmlEncodeProfile; if (!string.IsNullOrEmpty(this.StepConfiguration)) { xmlEncodeProfile = this.StepConfiguration; } else { string errorTxt = string.Format("[{0}] process Type {1} instance {2} has xmlEncodeProfile ", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId); throw new Exception(errorTxt); } // Declare a new job to contain the tasks IJob currentJob = _MediaServicesContext.Jobs.Create("Watermak Video base on " + xmlEncodeProfile + " " + myAssetOriginal.Name); // Set up the first Task to convert from MP4 to Smooth Streaming. // Read in task configuration XML string myEncoderProfile = myEncodigSupport.LoadEncodeProfile(xmlEncodeProfile, myRequest.ProcessConfigConn); // Get a media packager reference //IMediaProcessor processor = MediaButler.BaseProcess.MediaHelper.GetLatestMediaProcessorByName("Windows Azure Media Encoder",_MediaServicesContext); IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Windows Azure Media Encoder"); // Create a task with the conversion details, using the configuration data ITask task = currentJob.Tasks.AddNew("Task profile " + xmlEncodeProfile,processor,myEncoderProfile, TaskOptions.None); // Specify the input asset to be converted. task.InputAssets.Add(myAssetOriginal); // Add an output asset to contain the results of the job. task.OutputAssets.AddNew(myAssetOriginal.Name + "_mb", AssetCreationOptions.None); // Use the following event handler to check job progress. // The StateChange method is the same as the one in the previous sample currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged); // Launch the job. currentJob.Submit(); //9. Revisa el estado de ejecución del JOB Task progressJobTask = currentJob.GetExecutionProgressTask(CancellationToken.None); //10. en vez de utilizar progressJobTask.Wait(); que solo muestra cuando el JOB termina //se utiliza el siguiente codigo para mostrar avance en porcentaje, como en el portal myEncodigSupport.WaitJobFinish(currentJob.Id); return currentJob.OutputMediaAssets.FirstOrDefault(); }