简体   繁体   中英

upload video from azure blob to azure media services

My goal is to allow a user to upload a video that isn't stored locally on disk. All of the examples I've seen for uploading a video to Azure media services show only files from the local disk being uploaded. So i decided to try a method mentioned on Stackoverflow before, which is uploading a video firstly to Azure BLOB storage and then from here uploading the video to Azure media services. So far I've successfully uploaded a video to Azure BLOB storage but I'm not sure on how to get this video to Azure media services. Is there anyway of just passing the stored videos URI to Azure media services? I've seen an example of copying an entire storage container to Azure Media services but I'd like to do it on a video by video basis. Does anyine know of any decent tutorials that explain the steps?

The Asset entity contains digital files (including video, audio, images, thumbnail collections, text tracks and closed caption files) and the metadata about these files. After the digital files are uploaded into an asset, they could be used in the Media Services encoding and streaming workflows.

If I understand correctly, your question relates to how you would address an entity within Azure Media Services without the examples most tutorials use by reading a file from disk. As far as I understand the following line of C# would return an IAsset object that references a blob that is uploaded to Blob Storage.

IAsset inputAsset = UploadFile(@"C:\VideoFiles\BigBuckBunny.mp4", AssetCreationOptions.None);`

The result of this operation could also come from a users upload, you could implement this within your own Web Application. To access this video later on, you should store this AssetId. In your case you want to use the stored Asset ID in a way similar to this:

CloudMediaContext context = new CloudMediaContext("%accountName%","%accountKey%");
string sourceAssetId = "%sourceAssetId%";
IAsset sourceAsset = context.Assets.Where(a => a.Id == sourceAssetId).First();

Now, you have retrieved an Asset by it's AssetId from Azure Media Services. You can run encoding on it, or retrieve Publishing URL's for it.

Sources: https://github.com/Azure/azure-sdk-for-media-services-extensions https://azure.microsoft.com/en-us/documentation/articles/media-services-dotnet-get-started/#encode-the-source-file-into-a-set-of-adaptive-bitrate-mp4-files

What you are looking to do is create a new instance of an Azure Media Streamer, and when you do, simply have it point to your current Blob Storage account, and not have it create a new one.

By default, AMS will create a new blob storage account when you first upload a video to it.

I have a tutorial series on Azure Media Services.

I upload videos the same way that you do -- to my Blob storage account first, so that I can place them in a named container. Otherwise, when you just use AMS, it will create a container for you with random characters.

Let me know if you need any further detail.

Is there anyway of just passing the stored videos URI to Azure media services?

Yes. You have two choices here. You can either:

I've seen an example of copying an entire storage container to Azure Media services but I'd like to do it on a video by video basis.

Yes, you can specify the blob within the container. See the "Create an Asset from a blob" section here https://github.com/Azure/azure-sdk-for-media-services-extensions

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM