I have a group of Azure functions that I publish to a functions app. One of these is a blob triggered function, meant to extract thumbnails from videos uploaded to Azure storage, and to do so, uses ffmpeg.exe
.
I have published the project via Visual Studio, adding the executable in a directory in the root of the project. The relative path is exe/ffmpeg.exe
. To include the executable in the published bundle I followed the instructions in this Microsoft Developer instructional video.
After publication, If I enter the Kudu debug console for this function app, I can find the file under C:\home\site\wwwroot\exe\ffmpeg.exe
, as expected. I can even use that absolute path to execute ffmpeg inside the Kudu console.
This is the code I use to call the ffmpeg executable in the blob function:
using (var process = new Process())
{
process.StartInfo = new ProcessStartInfo
{
FileName = @"C:\home\site\wwwroot\exe\ffmpeg.exe",
Arguments = $"-hide_banner -loglevel error -i {videoTempPath} -frames:v 1 {thumbTempPath}",
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
};
process.Start();
await process.WaitForExitAsync();
}
However, this does not work. I get the following error in the logs:
An error occurred trying to start process 'C:\home\site\wwwroot\exe\ffmpeg.exe' with working directory 'C:\Program Files (x86)\SiteExtensions\Functions 4.25.2132bit. The system cannot find the file specified.
And indeed my thumbnails are never created. How can I solve this, or why does it happen?
Check and adjust file permissions in Azure Blob Storage or via Kudu console if needed.
Function1.cs:
Deployment status:
ffmpeg-master-latest-win64-gpl
Zip file inside the application folder and unzipped in kudu by using commandunzip ffmpeg-master-latest-win64-gpl
and installed.Below is the latest version installed in kudu.
Then I uploaded a test.mp4 file into the container.
I am able to access the storage container with the function app, below are the app insights.
func start
and able to get the Thumbnail at the adjusted time00:00:05
.Result:
Note:
Instead of manually calling
ffmpeg
, consider using Azure Media Services for video processing tasks. Azure Media Services provides a platform for encoding, transforming, and streaming media, and it can simplify video processing tasks in Azure.