我們使用Azure媒體服務器進行編碼和生成縮略圖。 我們有編碼組合的任務下面的代碼,並生成縮略圖Azure mediaserver視頻編碼/縮略圖任務失敗
IJob job = _context.Jobs.Create(filename + " - Media Encoder Standard");
IMediaProcessor processor = GetLatestMediaProcessorByName("Media Encoder Standard");
ITask task = job.Tasks.AddNew("Media Encoder Standard", processor, "H264 Single Bitrate 720p for Android", options);
// Specify the input asset to be encoded.
task.InputAssets.Add(asset);
task.OutputAssets.AddNew("Output asset",
AssetCreationOptions.None);
task = job.Tasks.AddNew("Media Encoder Standard", processor, configuration, options);
// Specify the input asset to be encoded.
task.InputAssets.Add(asset);
task.OutputAssets.AddNew("Output asset",
AssetCreationOptions.None);
// Submit the job and wait until it is completed.
job.Submit();
job = job.StartExecutionProgressTask(
j =>
{
},
CancellationToken.None).Result;
Console.WriteLine("Transcoding job finished.");
var outputAssets = job.OutputMediaAssets.ToList();
return outputAssets;
但是如果縮略圖任務失敗和視頻編碼經歷。我們仍然爲視頻生成一個網址。
我們用下面的代碼生成的URL
public string PublishAssetGetURLs(IAsset asset, string fileExt = "")
{
// Publish the output asset by creating an Origin locator for adaptive streaming,
// and a SAS locator for progressive download.
_context.Locators.Create(
LocatorType.Sas,
asset,
AccessPermissions.Read,
TimeSpan.FromDays(365));
IEnumerable<IAssetFile> assetFiles = asset
.AssetFiles
.ToList()
.Where(af => af.Name.EndsWith(fileExt, StringComparison.OrdinalIgnoreCase));
// Get the URls for progressive download for each specified file that was generated as a result
// of encoding.
List<Uri> sasUris = assetFiles.Select(af => af.GetSasUri()).ToList();
var url = sasUris.FirstOrDefault();
if (url != null)
{
return url.ToString();
}
return string.Empty;
}
然而,當URL使用我們得到以下XML
<Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:a6d14469-0001-0008-7bdb-1f3b8a000000
Time:2017-08-28T08:58:17.0773123Z</Message><AuthenticationErrorDetail>Signature fields not well formed.</AuthenticationErrorDetail></Error>
,如果這兩項任務都成功,它工作正常。我需要在資產上設置什麼嗎?
嗨,謝謝你的回覆。縮略圖任務按原樣工作。我特意製作了縮略圖任務chrash,以查看錯誤處理是否可行:)我通過在json預設文件中輸入拼寫錯誤來做到這一點。順便說一句 - 這是我跟着它的例子,非常好:) – Bjarke