简体   繁体   中英

Convert image sequence to MP4 file using .Net Core and C# on Azure Storage Blobs

I have an API with a POST method which captures images and stores them to a blob container on Azure. These images will make up a sequence of frames for a video file once ready to process. I have another endpoint that my application calls when it is ready to process the sequence and get back a video file.

I have everything in place and ready for video processing but I am stuck on how to achieve what I thought would be very simple! Since my endpoint runs in .NET Core I cannot use any legacy .Net libraries and since I am deploying to an Azure WebApp (Windows OS) that may need to scale up/out I cannot install anything other than pre-compiled .Net Core compatible Nuget packages on the hardware as part of my deployment from DevOps.

I can't find any good libraries or examples that run in this scenario. I've run into issues trying to use anything related to GDI+ or FFMPEG...

Was hoping to find something similar to SixLabors.ImageSharp

I have a list of all the images in order and ready to be processed like so:

var frames = new List<Image>();

// (Removed for brevity) Retrieve images from blobs & append to frame list...

foreach(var frame in frames)
{
    // Convert frames/sequence to video file
}

// Save to blob storage as .mp4

Any help would be appreciated!

Per my experience, the solution to convert image sequence to a video streaming or file is normally to use some popular libraries like ffmpeg or libav to do that.

If you search for some keywords like C# ffmpeg images video or C# libav images video , you will get much useful content to help realizing it, as below, there are few threads you can refer to.

  1. Image sequence to video stream?
  2. Converting Images into Video using C#
  3. tomaszzmuda/Xabe.FFmpeg

And then, you can get the video streaming or file to upload to Azure Blob Storage as a block blob, please follow the offical tutorial Quickstart: Azure Blob storage client library for .NET to know how to use Azure Storage SDK for .NET standard and the key class in C# is CloudBlockBlob Class which functions enter link description here BeginUploadFromFile for video file or BeginUploadFromStream for video stream.

But there is an issue about your app deployment. Due to the limitation of Azure Web App sandbox about Win32k.sys (User32/GDI32) Restrictions as the figure below, you can not deploy any app used GDI system call to Azure WebApp.

在此处输入图片说明

So a normal recommended Azure service for your app is Azure VM.


Update:

If you considered to use dotNet Core to realize it, I suggested that you can try to use Azure App Service on Linux which be based on Docker and no limits for GDI. Also, Azure Batch is the other choice for realizing your needs in any language. And I wish you will complete your evaluation.

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