如何为 Azure 媒体服务 v3 编码空音轨?

How to encode an empty audio track for Azure Media Services v3?

我有一个网站,用户可以在其中上传要编码的视频并在 azure 媒体播放器中观看。上传的某些视频没有 azure media player 无法播放的音轨。如何使用这些视频对空音轨进行编码?我正在使用 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

我现在定义一个自定义预设,读入它并将其发送到正文中。现在的问题是我找不到 "condition" 的类似选项:"InsertSilenceIfNoAudio" 就像 API 的 v2 中那样。我在这里打开了一个 github 问题:https://github.com/MicrosoftDocs/azure-docs/issues/28133

您的目标编码设置是什么?您需要自定义预设吗? 如果没有,而您只需要一个标准的自适应流配置文件预设,您可以使用 AdaptiveStreaming preset. 它处理插入静默。

尚未最终宣布,但在我们对项目进行测试时,Azure Media Player 从版本 2.3.0(2019 年 4 月 30 日)开始完全支持纯视频内容.

官方在功能列表中提到该功能已经实现("Video Only" 带有注释 "Supported in AzureHtml5JS"、here) and it's said in Change list of 2.3.0 release that "Added support for video-only assets for DASH" (here 的功能),但我们亲自测试了 SMOOTH 和 HLS,因为好吧 - 没问题,所以 video-only 资产从版本 2.3.0 开始播放没有任何问题。

同时 Known Issues: "Assets that are audio or video only will not play back via the AzureHtml5JS tech." 中仍然提到了这个问题,但我猜他们只是没有更新文档。另一种选择,可能他们没有完全测试,但正如我所说,从我们的内部测试来看,它看起来完全有效。