【发布时间】:2019-03-27 14:11:35
【问题描述】:
我有一个网站,用户可以在其中上传要在 azure 媒体播放器中编码和查看的视频。上传的某些视频没有 azure 媒体播放器无法播放的音轨。如何使用这些视频对空音轨进行编码?我正在使用 REST api 的 v3。
我当前的转换代码是:
private async Task<string> CreateTransformAsync(string transform)
{
JObject body = new JObject(
new JProperty("properties",
new JObject(
new JProperty("description", "Basic Transform using an Adaptive Streaming encoding preset from the libray of built-in Standard Encoder presets"),
new JProperty("outputs",
new JArray(
new JObject(
new JProperty("onError", "StopProcessingJob"),
new JProperty("relativePriority", "Normal"),
new JProperty("preset",
new JObject(
new JProperty("@odata.type", "#Microsoft.Media.BuiltInStandardEncoderPreset"),
new JProperty("presetName", "H264MultipleBitrate720p")
)
)
)
)
)
)
)
);
var jsonBody = new StringContent(body.ToString(), Encoding.UTF8, "application/json");
HttpResponseMessage responseMsg = await _httpClient.PutAsync($"subscriptions/{_config.Value.SubscriptionId}/resourceGroups/{_config.Value.ResourceGroup}/providers/Microsoft.Media/mediaServices/{_config.Value.MediaAccountName}/transforms/{transform}/?api-version={_config.Value.ApiVersion}", jsonBody);
string responseContent = await responseMsg.Content.ReadAsStringAsync();
var response = JObject.Parse(responseContent);
if (response["error"] == null)
{
return response["name"].ToString();
} else
{
throw new Exception(response["error"].ToString());
}
}
更新:
在浏览了文档之后,我对此有了更深入的了解:https://docs.microsoft.com/en-us/azure/media-services/latest/custom-preset-rest-howto#define-a-custom-preset
我现在定义一个自定义预设,将其读入并在正文中发送。现在的问题是我在 API 的 v2 中找不到“条件”的类似选项:“InsertSilenceIfNoAudio”。我在这里打开了一个关于它的 github 问题:https://github.com/MicrosoftDocs/azure-docs/issues/28133
【问题讨论】:
-
正确,我们的 v3 API 还没有暴露 InsertSilence 标志。我也在 github 上做出了回应,我们将更新 docs.microsoft.com/en-us/azure/media-services/latest/… 以包含此主题。您是否特别需要使用 v3 API?您可以通过 amshelp@microsoft.com 与我们联系,以离线讨论您的方案。谢谢
标签: azure azure-media-services