简体   繁体   中英

Azure Media Service using IAssetFile in task

I would like to know if I can use the AssetFile to added into the task ? I have this flow:

  1. Encode video into several resolution.
  2. Make summarized with 360p resolution video.

I know the Id of IAsset and successfully get the IAssetFile for the 360p resolution video. But, I cannot use it because the task needs IAsset instead of IAssetFile.

Here is my sample code:

        IJob job = _MediaServicesContext.Jobs.Create("Video Thumbnail Job");

        string MediaProcessorName = "Azure Media Video Thumbnails";

        var processor = GetLatestMediaProcessorByName(MediaProcessorName);

        IAsset curretAsset = _MediaServicesContext.Assets.Where(a => a.Id == request.AssetId).FirstOrDefault();

        IAssetFile file360 = curretAsset.AssetFiles.Where(f => f.Name.EndsWith("360_500.mp4")).FirstOrDefault();

        String configuration = "{\"version\":\"1.0\",\"options\":{\"outputAudio\" : \"false\", \"maxMotionThumbnailDurationInSecs\": \"10\", \"fadeInFadeOut\" : \"false\" }}";

        // Create a task with the encoding details, using a string preset.
        ITask task = job.Tasks.AddNew("My Video Thumbnail Task",
            processor,
            configuration,
            TaskOptions.None);

        // Specify the input asset.
        task.InputAssets.Add(file360);

        // Specify the output asset.

        task.OutputAssets.AddNew(curretAsset.Id.ToString() + " Summarized", AssetCreationOptions.None);

        // Use the following event handler to check job progress.  
        job.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);

        // Launch the job.
        job.Submit();

        // Check job execution and wait for job to finish.
        Task progressJobTask = job.GetExecutionProgressTask(CancellationToken.None);

        progressJobTask.Wait();

Thank You

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM