Beispiel #1
0
        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 void SetPrimaryAssetFile()
        {
            IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);
            IAssetFile      mp4 = myAssetOriginal.AssetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault();

            myEncodigSupport.SetPrimaryFile(myAssetOriginal, mp4);
        }
Beispiel #3
0
        private IAsset getWorkflowAsset()
        {
            IAsset          aux = null;
            IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);

            try
            {
                if (!string.IsNullOrEmpty(myConfig.AssetWorkflowID))
                {
                    //use Exiting Asset
                    aux = _MediaServicesContext.Assets.Where(a => a.Id == myConfig.AssetWorkflowID).FirstOrDefault();
                }
                else
                {
                    string worflowFile = myRequest.ButlerRequest.MezzanineFiles.Where(s => s.IndexOf(".workflow") > 0).FirstOrDefault();
                    aux = myEncodigSupport.CreateAsset
                              (myRequest.ProcessTypeId + "_workflowAssetDefinition_" + myRequest.ProcessInstanceId,
                              worflowFile,
                              myRequest.MediaStorageConn,
                              myRequest.ButlerRequest.StorageConnectionString,
                              myRequest.ButlerRequest.WorkflowName);
                }
            }
            catch (Exception X)
            {
                throw X;
            }
            return(aux);
        }
 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 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());
        }
        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();
        }
Beispiel #8
0
        /// <summary>
        /// Set MP4 as primary file
        /// </summary>
        private void setPrimaryFile()
        {
            string     myPrimaryFile = null;
            IAssetFile mp4           = null;


            if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri))
            {
                //
                IButlerStorageManager resource = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
                string jsonControl             = resource.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri));
                if (!string.IsNullOrEmpty(jsonControl))
                {
                    IjsonKeyValue myControl = new jsonKeyValue(jsonControl);
                    myPrimaryFile = myControl.Read(DotControlConfigKeys.IngestMultiMezzamineFilesPrimaryFile);
                }
            }

            IEncoderSupport myEncodigSupport = new EncoderSupport(MediaContext);

            if (!string.IsNullOrEmpty(myPrimaryFile))
            {
                mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower() == myPrimaryFile.ToLower()).FirstOrDefault();
            }
            if (mp4 == null)
            {
                mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault();
            }
            if (mp4 != null)
            {
                myEncodigSupport.SetPrimaryFile(currentAsset, mp4);
            }
            else
            {
                Trace.TraceWarning("{0} setPrimaryFile {2} processId {1}, has not MP4 file", this.GetType().FullName, myRequest.ProcessInstanceId, myRequest.ProcessTypeId);
            }
        }
 private void SetPrimaryAssetFile()
 {
     IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);
     IAssetFile mp4 = myAssetOriginal.AssetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault();
     myEncodigSupport.SetPrimaryFile(myAssetOriginal, mp4);
 }
        private IAsset getWorkflowAsset()
        {
            IAsset aux = null;
            IEncoderSupport myEncodigSupport = new EncoderSupport(_MediaServicesContext);
            try
            {
                if (!string.IsNullOrEmpty(myConfig.AssetWorkflowID))
                {
                    //use Exiting Asset
                    aux = _MediaServicesContext.Assets.Where(a => a.Id == myConfig.AssetWorkflowID).FirstOrDefault();
                }
                else
                {
                    string worflowFile = myRequest.ButlerRequest.MezzanineFiles.Where(s => s.IndexOf(".workflow") > 0).FirstOrDefault();
                    aux = myEncodigSupport.CreateAsset
                         (myRequest.ProcessTypeId + "_workflowAssetDefinition_"  + myRequest.ProcessInstanceId,
                         worflowFile,
                         myRequest.MediaStorageConn,
                         myRequest.ButlerRequest.StorageConnectionString,
                         myRequest.ButlerRequest.WorkflowName);
                }
            }
            catch (Exception X)
            {

                throw X;
            }
            return aux;
        }