Serving Video Content from Azure Blob Storage

余生颓废 提交于 2019-12-18 11:56:01

问题


I am trying to serve MP4 Video content from Azure Blob Storage. I can get the video to play in modern browsers by ensuring that the Blob's Content Type is set to video/mp4; however I am unable to seek backwards.

Dropping the same video into an S3 bucket yields the desired result so I am ruling out problems with the content.

Do I need to configure the Storage role in a specific way to serve video content?


回答1:


it was not clear for me from @smarx's answer how to set that for my blob container - but after some googling i found the code below. Just execute it in LINQPad, and video will start streaming:

var storageAccount = CloudStorageAccount.Parse("AccountName=<accountName>;AccountKey=<accountKeyBase64>;DefaultEndpointsProtocol=http");
var blobClient = storageAccount.CreateCloudBlobClient();

// Get the current service properties
var serviceProperties = blobClient.GetServiceProperties();

// Set the default service version to 2011-08-18 (or a higher version like 2012-03-01)
serviceProperties.DefaultServiceVersion = "2011-08-18";

// Save the updated service properties
blobClient.SetServiceProperties(serviceProperties);



回答2:


You may try setting the default version for your storage account to 2011-08-18: http://blogs.msdn.com/b/windowsazurestorage/archive/2011/09/15/windows-azure-blobs-improved-http-headers-for-resume-on-download-and-a-change-in-if-match-conditions.aspx. It improves a couple things around range requests (probably what progressive download in your browser is doing). I haven't heard anything specific about video playback, but it can't hurt to try. :-)




回答3:


I tried playing a very small MP4 encoded blob directly from HTML5 video element with control enabled, i could use the control to scroll back and forth my video.

What is the size of your video content? Also you can use Fiddler to check the HTTP Headers to verify if they are expected or does they match exactly same when you use the same blob from S3 bucket?

If you can share your blob link, i can give a quick try and see what could be the issue.




回答4:


You can do it via Powershell. Here is an example for Azures ARM (not classic, but you can convert it easily).

Select-AzureRmSubscription -SubscriptionName "subscription" $Name = 'storageaccountname' $resourcegroup = 'resourcegroup'

$sp = New-Object -TypeName Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties 

$sp.DefaultServiceVersion = "2017-04-17" $key = (Get-AzureRMStorageAccountKey -StorageAccountName $Name
-ResourceGroupName $resourcegroup).Value[1]

$context = New-AzureStorageContext -StorageAccountName $Name
-StorageAccountKey $key

$blobClient = $context.StorageAccount.Create



回答5:


For anyone coming here from google:

Azure has two types of storage accounts: StorageV1/V2 (default option selected when making new account) and BlobStorage.

While the StorageV2 option may have more features, it does not support partial content requests, meaning Chrome will not allow video seeking.

You can identify the type of storage you have in the Azure Portal by navigating to your Storage Account > Properties > Account Type



来源:https://stackoverflow.com/questions/11503776/serving-video-content-from-azure-blob-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!