0

我有一个 azure 媒体服务帐户,其中包含一些上传的视频,但这些视频只能在浏览器上播放,并带有一些额外的参数,比如这些 (?sv=2017-04-17&sr=c&sig=QMSr...),比如身份验证密钥。我想要一个可以随时播放的通用永久渐进式视频 URL,我尝试将 azure 媒体播放器与带有 .ism/manifest 和 .mp4 的视频 URL 一起使用,但两者都无法播放 exp:

https://<MY_BLOBSTORAGE_ACCOUNT>.blob.core.windows.net/<Asset-ID>/Video_FILE_NAME>.ism/manifest

https://<MY_BLOBSTORAGE_ACCOUNT>.blob.core.windows.net/<Asset-ID>/<Video_FILE_NAME>_1280x720_AACAudio.mp4

我已经从这个官方微软文档中尝试过播放器:http: //amp.azure.net/libs/amp/latest/docs/index.html#full-setup-of-azure-media-player

另请注意,Azure 媒体服务 V3文档和 ams 本身的社区在解释以编程方式获取播放器的视频 url 的步骤方面非常糟糕和薄弱。

4

3 回答 3

2

使用 AMS v3,您必须创建流式定位器,并且可以使用预构建的流式传输策略。有政策 - 仅流式传输 - 流式传输和下载 - 仅下载

使用下载策略,您将获得资产中每个 blob 的 URL。例如: https ://myaccount-uswc.streaming.media.azure.net/1544fcae-a248-4f53-b653-cd02074b04b6/video_848x480_2200.mp4

使用流式传输策略(推荐),您将获得 DASH、HLS 和平滑 URL,例如: https ://myaccount-uswc.streaming.media.azure.net/0eef6f88-47c6-4662-9111-60305d7c1000/video.ism/清单(格式=mpd-time-csf).mpd

于 2019-10-02T14:52:56.263 回答
1

您似乎正在混合渐进式下载和流式传输。我在https://blogs.msdn.microsoft.com/randomnumber/2016/03/23/progressive-download-and-streaming-differences-with-azure-上写了一篇关于与 Azure 媒体服务相关的差异的博客文章媒体服务/。如果您将视频编码为自适应比特率 MP4 集,那么您很可能希望流式传输视频,而不是在单个 MP4 上使用渐进式下载。这可能有助于流媒体方面:https ://docs.microsoft.com/en-us/azure/media-services/latest/dynamic-packaging-overview

于 2019-10-02T14:21:19.970 回答
1

我在朋友的帮助下找到了解决方案,在创建流式定位器后,我必须确保流式端点正在运行,然后通过遍历我需要使用的路径来获取构建 URL StreamingLocators.ListPathsAsync,下面是代码片段。

        private async Task<StreamingLocator> CreateStreamingLocatorAsync(
            IAzureMediaServicesClient client,
            string resourceGroup,
            string accountName,
            string assetName,
            string locatorName)
        {
            StreamingLocator locator = await client.StreamingLocators.CreateAsync(
                resourceGroup,
                accountName,
                locatorName,
                new StreamingLocator
                {
                    AssetName = assetName,
                    StreamingPolicyName = PredefinedStreamingPolicy.ClearStreamingOnly
                });

            return locator;
        }

        private async Task<IList<string>> GetStreamingUrlsAsync(
            IAzureMediaServicesClient client,
            string resourceGroupName,
            string accountName,
            String locatorName)
        {
            const string DefaultStreamingEndpointName = "default";

            IList<string> streamingUrls = new List<string>();

            StreamingEndpoint streamingEndpoint = await client.StreamingEndpoints.GetAsync(resourceGroupName, accountName, DefaultStreamingEndpointName);

            if (streamingEndpoint != null)
            {
                if (streamingEndpoint.ResourceState != StreamingEndpointResourceState.Running)
                {
                    await client.StreamingEndpoints.StartAsync(resourceGroupName, accountName, DefaultStreamingEndpointName);
                }
            }

            ListPathsResponse paths = await client.StreamingLocators.ListPathsAsync(resourceGroupName, accountName, locatorName);

            foreach (StreamingPath path in paths.StreamingPaths)
            {
                UriBuilder uriBuilder = new UriBuilder();
                uriBuilder.Scheme = "https";
                uriBuilder.Host = streamingEndpoint.HostName;

                uriBuilder.Path = path.Paths[0];
                streamingUrls.Add(uriBuilder.ToString());
            }

            return streamingUrls;
        }

在我的服务方法中,我执行以下操作:

StreamingLocator locator = await CreateStreamingLocatorAsync(client,
config.ResourceGroup, config.AccountName, outputAsset.Name, locatorName);

IList<string> streamingUrls = await GetStreamingUrlsAsync(client, config.ResourceGroup, config.AccountName, locator.Name);
foreach (var url in streamingUrls)
   {
       urls.Add(url);
       Console.WriteLine(url);
   }
myModel.StreamingUrls = urls;
于 2019-10-03T07:15:30.277 回答