-
Notifications
You must be signed in to change notification settings - Fork 341
Description
I deployed an azure function to extract frames of videos. I cannot get ffmpeg.exe to be found.
The error I get when trying to run anything that uses ffmpeg.exe, is this:
2025-11-10T23:17:18Z [Information] Current Environment.CurrentDirectory: C:\home\site\wwwroot
2025-11-10T23:17:18Z [Information] FFmpeg exe path: C:\home\site\wwwroot\ffmpeg\windows\ffmpeg.exe
2025-11-10T23:17:18Z [Information] FFmpeg exe exists: True
2025-11-10T23:17:18Z [Information] FFmpeg exe size: 190383616 bytes
2025-11-10T23:17:18Z [Information] FFmpeg exe last write: 11/9/2025 12:50:14 PM
2025-11-10T23:17:18Z [Information] Intentando ejecutar FFmpeg -version directamente...
**2025-11-10T23:17:19Z [Error] Error ejecutando FFmpeg directamente: An error occurred trying to start process 'C:\home\site\wwwroot\ffmpeg\windows\ffmpeg.exe' with working directory 'C:\home\site\wwwroot'. The system cannot find the path specified.**
2025-11-10T23:17:19Z [Error] Test exception type: Win32Exception
2025-11-10T23:17:19Z [Error] Error específico al ejecutar FFMpegArguments para frame 0: An error occurred trying to start process 'C:\home\site\wwwroot\ffmpeg\windows\ffmpeg.exe' with working directory 'C:\home\site\wwwroot'. The system cannot find the path specified.
2025-11-10T23:17:19Z [Error] Exception type: Win32Exception
2025-11-10T23:17:20Z [Error] Stack trace: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at Instances.ProcessArguments.Start()
at Instances.Instance.Start(ProcessStartInfo startInfo, EventHandler`1 outputHandler, EventHandler`1 errorHandler)
at Instances.Instance.Finish(ProcessStartInfo startInfo, EventHandler`1 outputHandler, EventHandler`1 errorHandler)
at Instances.Instance.Finish(String path, String arguments, EventHandler`1 outputHandler, EventHandler`1 errorHandler)
at FFMpegCore.Helpers.FFMpegHelper.VerifyFFMpegExists(FFOptions ffMpegOptions)
at FFMpegCore.FFMpegArgumentProcessor.PrepareProcessArguments(FFOptions ffOptions, CancellationTokenSource& cancellationTokenSource)
at FFMpegCore.FFMpegArgumentProcessor.ProcessAsynchronously(Boolean throwOnError, FFOptions ffMpegOptions)
at Creatio.Services.VideoService.ExtractFramesAsync(String campaignId, String videoId, ILogger logger) in D:\a\creatio-functions\creatio-functions\Services\VideoService.cs:line 413
2025-11-10T23:17:20Z [Information] Restaurando Environment.CurrentDirectory a 'C:\local\Temp\functions\standby\wwwroot'
And the code I have for extracting the frames is this:
success = await FFMpegArguments
.FromFileInput(localVideoPath)
.OutputToFile(outputPath, true, options => options
.Seek(TimeSpan.FromSeconds(second))
.WithFrameOutputCount(1)
.WithVideoCodec("mjpeg")
.ForceFormat("image2"))
.ProcessAsynchronously();
Currently I run a simple way (the one throwing above log) to test if I can use ffmpeg like this:
try
{
using var testProcess = new System.Diagnostics.Process();
testProcess.StartInfo.FileName = ffmpegExePath;
testProcess.StartInfo.Arguments = "-version";
testProcess.StartInfo.UseShellExecute = false;
testProcess.StartInfo.RedirectStandardOutput = true;
testProcess.StartInfo.RedirectStandardError = true;
testProcess.StartInfo.CreateNoWindow = true;
testProcess.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
logger?.LogInformation("Intentando ejecutar FFmpeg -version directamente...");
testProcess.Start();
I had to put a lot of logs because the issue is only present when deployed. Locally, it works. I also have another method to extract the audio form the video; that process uses ffprobe, and works deployed. I validated the binary folder and working directory, the presence of the ffmpeg and ffprobe and ffplay binaries. I realized ffmpeg uses Environment current directory instead of the one I set in GlobalFFOptions.Confgure So I am changing the environment working directory prior to execute any of the snippets above. But still not getting the binary to work.
My ffmpeg global configuration is in another method that looks for the binaries and configures it.
GlobalFFOptions.Configure(new FFOptions
{
BinaryFolder = foundPath,
TemporaryFilesFolder = Path.GetTempPath(),
WorkingDirectory = workingDirectory
});
This method is used for both endpoints, the one to extract audio and the one to extract frames.
this i show I extract the audio.
var success = await FFMpegArguments
.FromFileInput(inputPath)
.OutputToFile(outputPath, overwrite: true, options => options
.WithAudioCodec("libmp3lame")
.DisableChannel(FFMpegCore.Enums.Channel.Video))
.ProcessAsynchronously();
I fell frustrated because I have tried a lot of things and validate paths and everything, but I can get this to work. If there is need to share more code, I will. But I tried to keep the relevant parts. here.
Thank you.