'Seek in Audio File in Azure Blob Storage

I have audio files of differnt types (wav, mp3...) in a Azure Blob Storage. I want to stream them but i also want to stream them from a specific position in the audio file. So for example i want a stream to start at 0:00 seconds and another one to start at 01:15 seconds of the file.

Is this somehow possible? I know that there is the Method "DownloadRangeToStream". Is this possible with this method? Even if this works i think that there will be problems with the offset because the Header of the File is missing right?

I would appreciate any input!

Thanks for your help, Metabolic



Solution 1:[1]

By default Azure Blob Storage service uses oldest possible version which dates to 2009-09-19 . This version doesn't support byte ranges so seeking doesn't work.

You can switch to newest version in multiple ways:

  1. using Set Blob Service Properties via HTTP REST API
  2. using Plasma/AzureBlobUtility:

    BlobUtility.exe -k <AccessKey> -a <StorageName> -c <ContainerName> --setDefaultServiceVersion 2015-02-21

  3. write your own program and use CloudBlobClient.SetServiceProperties function from Windows Azure Storage package

EDIT You can read more here Serving Video Content from Azure Blob Storage and here Hosting progressive download videos on Azure Blobs

Solution 2:[2]

The default version of Azure Blob Storage API doesn't return a Accept-Ranges: Bytes header in the response, which prevents the audio files from being seekable.

You can change the default Blob Storage API version with PowerShell, like this:

$context = New-AzStorageContext `
    -StorageAccountName <yourAccount> `
    -StorageAccountKey <key>

Update-AzStorageServiceProperty `
    -ServiceType Blob `
    -DefaultServiceVersion 2021-04-10 `
    -Context $context

Note: that the PowerShell Az module to be installed. You can also use the old AzureRM module, in which case your commands will be New-AzureStorageContext and Update-AzureStorageServiceProperty respectively.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Micha? Jab?o?ski