Azure 媒体播放器如何获取播放器的源 url
Azure media player How to get the source url for the player
我有一个 Azure 媒体服务帐户,其中包含一些已上传的视频,但这些视频只能在浏览器上播放,并带有一些附加参数,例如 (?sv=2017-04-17&sr=c&sig=QMSr...)身份验证密钥。
我想要一个可以随时播放的通用永久渐进式视频 URL,我尝试将 azure 媒体播放器与我的视频 URLs 一起使用 .ism/manifest 和 .mp4 但两者都不能被播放
经验值:
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 Media Services V3 文档和 ams 社区本身在解释以编程方式获取播放器视频 url 的步骤方面非常薄弱。
您似乎混合了渐进式下载和流式传输。我在 https://blogs.msdn.microsoft.com/randomnumber/2016/03/23/progressive-download-and-streaming-differences-with-azure-media-services/. If you encoded the video into an adaptive bitrate MP4 set then more than likely you'll want to stream the video instead of using progressive download on a single MP4. This might help with the streaming side: https://docs.microsoft.com/en-us/azure/media-services/latest/dynamic-packaging-overview
上写了一篇关于 Azure 媒体服务差异的博客 post
使用 AMS v3,您必须创建一个流式定位器,并且可以使用预建的流式传输策略。有针对的政策
- 仅流媒体
- 流媒体和下载
- 仅下载
使用下载策略,您将获得资产中每个 blob 的 URL。例如 :
https://myaccount-uswc.streaming.media.azure.net/1544fcae-a248-4f53-b653-cd02074b04b6/video_848x480_2200.mp4
使用流媒体策略(推荐),您将获得 DASH、HLS 和 Smooth URL,例如:
https://myaccount-uswc.streaming.media.azure.net/0eef6f88-47c6-4662-9111-60305d7c1000/video.ism/manifest(format=mpd-time-csf).mpd
我在朋友的帮助下找到了解决方案,在创建流媒体定位器之后,我必须确保流媒体端点是 运行,然后通过遍历我需要获取的路径来获取构建 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;
我有一个 Azure 媒体服务帐户,其中包含一些已上传的视频,但这些视频只能在浏览器上播放,并带有一些附加参数,例如 (?sv=2017-04-17&sr=c&sig=QMSr...)身份验证密钥。 我想要一个可以随时播放的通用永久渐进式视频 URL,我尝试将 azure 媒体播放器与我的视频 URLs 一起使用 .ism/manifest 和 .mp4 但两者都不能被播放 经验值:
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 Media Services V3 文档和 ams 社区本身在解释以编程方式获取播放器视频 url 的步骤方面非常薄弱。
您似乎混合了渐进式下载和流式传输。我在 https://blogs.msdn.microsoft.com/randomnumber/2016/03/23/progressive-download-and-streaming-differences-with-azure-media-services/. If you encoded the video into an adaptive bitrate MP4 set then more than likely you'll want to stream the video instead of using progressive download on a single MP4. This might help with the streaming side: https://docs.microsoft.com/en-us/azure/media-services/latest/dynamic-packaging-overview
上写了一篇关于 Azure 媒体服务差异的博客 post使用 AMS v3,您必须创建一个流式定位器,并且可以使用预建的流式传输策略。有针对的政策 - 仅流媒体 - 流媒体和下载 - 仅下载
使用下载策略,您将获得资产中每个 blob 的 URL。例如 : https://myaccount-uswc.streaming.media.azure.net/1544fcae-a248-4f53-b653-cd02074b04b6/video_848x480_2200.mp4
使用流媒体策略(推荐),您将获得 DASH、HLS 和 Smooth URL,例如: https://myaccount-uswc.streaming.media.azure.net/0eef6f88-47c6-4662-9111-60305d7c1000/video.ism/manifest(format=mpd-time-csf).mpd
我在朋友的帮助下找到了解决方案,在创建流媒体定位器之后,我必须确保流媒体端点是 运行,然后通过遍历我需要获取的路径来获取构建 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;