从 Azure 流式传输视频(Blob 或媒体服务) [英] Streaming Videos from Azure ( Blob or Media Services)
问题描述
我有一个 MVC 4 网站托管在 azure 中,需要上传视频,并且在不同的页面上允许将上传的视频流式传输回客户端播放器.
I have an MVC 4 website hosted in azure that needs to upload a video and on a different page allow that uploaded video to be streamed back to a client player.
第一个选项允许用户上传和编码视频 (.mp4)第二个选项是我手动上传和编码视频并向用户提供 url.
The first option allows the user to upload and encode the video (.mp4) The second option is I manually upload and encode the video and provide the url to the user.
无论哪种情况,视频都会在另一个页面上呈现给用户.
In either case, the video would be presented to the users on another page.
我有一段时间试图让它发挥作用.有什么建议/工作示例吗?
Im having a devil of a time trying to get this to work. Any suggestions/working samples?
推荐答案
我在我的 c# 应用程序中使用了以下代码,并且它可以正常工作.
I used the below code for my c# application and it works properly.
public static string getBlobStreamURL(string fsBloblFilePath, string fsdirectory)
{
CloudBlobContainer cloudBlobContainer = storageAccount.CreateCloudBlobClient().GetContainerReference(fsdirectory);
var cloudBlob = cloudBlobContainer.GetBlockBlobReference(fsBloblFilePath);
var SharedAccessSignature = cloudBlob.GetSharedAccessSignature(new Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPolicy()
{
Permissions = Microsoft.WindowsAzure.Storage.Blob.SharedAccessBlobPermissions.Read,
SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1)
});
var StreamURL = string.Format("{0}{1}", cloudBlob.Uri, lsSharedAccessSignature);
return StreamURL;
}
这篇关于从 Azure 流式传输视频(Blob 或媒体服务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!