繁体   English   中英

在任务中使用IAssetFile的Azure媒体服务

[英]Azure Media Service using IAssetFile in task

我想知道是否可以使用AssetFile添加到任务中? 我有这个流程:

  1. 将视频编码为几种分辨率。
  2. 用360p分辨率视频进行总结。

我知道IAsset的ID,并成功获取了360p分辨率视频的IAssetFile。 但是,我不能使用它,因为任务需要IAsset而不是IAssetFile。

这是我的示例代码:

        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();

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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