'Write video in Azure Function
I have videos that i want to process in Azure function (Service Bus Queue trigger). When new message arrives and function gets called i do the following:
- Download video from blob storage into function directory
- Process video (loop over frames and add some info on them)
- Write processed frames into output.mp4 (using OpenCVSharp's VideoWriter)
- Upload processed video into blob storage
But on the 3rd step i have a problem: i can open videos, read frames and draw info. But when i try to write the output, it does nothing. No error, no file...
Here's how i initialize video writer:
var frameSize = new Size(frameWidth, frameHeight);
using (var writer = new VideoWriter(output, FourCC.H264, fps, frameSize))
{
...
}
I know that OpenCV does not work with h264 by default, so i added openh264-1.8.0-win64.dll to my bin directory.
It all works just fine and produces valid mp4 when run locally..., but not in azure function.
I suspect that opencv can't find the openh264 dll i provided. Do i need to do something else, rather than just putting it into bin?
Can i somehow dump the output from OpenCV into function logs?
What am i missing?
Thanks.
Solution 1:[1]
I don't know OpenCV well but I imagine OpenCV is not allowed the the Kudu Sandbox. One option is to run this part in a Container either hosted in an App Service or Azure Container Instances.
All Azure Web Apps (as well as Mobile App/Services, WebJobs and Functions) run in a secure environment called a sandbox. Each app runs inside its own sandbox, isolating its execution from other instances on the same machine as well as providing an additional degree of security and privacy which would otherwise not be available. The sandbox mechanism aims to ensure that each app running on a machine will have a minimum guaranteed level of service; furthermore, the runtime limits enforced by the sandbox protects apps from being adversely affected by other resource-intensive apps which may be running on the same machine.
https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox
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 | Ken W MSFT |