简体   繁体   中英

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

I have a site where users can upload videos to be encoded and viewed in azure media player. Some of the videos uploaded do not have audio tracks which azure media player can't play. How can I encode an empty audio track with these videos? I'm using v3 of the REST api.

My current code for transforms is:

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

UPDATE:

After scouring the documentation, I've gotten a little further with this: https://docs.microsoft.com/en-us/azure/media-services/latest/custom-preset-rest-howto#define-a-custom-preset

I now define a custom preset, read it in and send that in the body instead. Problem now is I can't find a similiar option for "condition": "InsertSilenceIfNoAudio" like in v2 of the API. I've opened a github issue about it here: https://github.com/MicrosoftDocs/azure-docs/issues/28133

What's your target encoding settings? Do you need a custom preset? If not, and you just need a standard adaptive streaming profile preset, you can use the AdaptiveStreaming preset. It handles the insert silence.

It's not finally announced, but as we tested for our project, Azure Media Player got complete support of Video Only content, starting with version 2.3.0 (April 30, 2019) .

Officially there is a mention in feature list that the feature is already implemented ("Video Only" feature with comment "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 ), but we personally tested for SMOOTH and HLS as well - no issues, so video-only assets start playing without any issues starting with version 2.3.0.

At the same time the issue is still mentioned in Known Issues : "Assets that are audio or video only will not play back via the AzureHtml5JS tech.", but I guess they just didn't update the docs. Another option, probably they didn't test it completely, but as I say from our internal testing it looks like it completely works.

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