tomaszzmuda / Xabe.FFmpeg

.NET Standard wrapper for FFmpeg. It allows to process media without know how FFmpeg works, and can be used to pass customized arguments to FFmpeg from dotnet core application.
https://xabe.net/product/xabe_ffmpeg/
Other
715 stars 128 forks source link

Issue with FindAndValidateExecutables #456

Open theolivenbaum opened 1 year ago

theolivenbaum commented 1 year ago

I'm seeing an error that seems to be related to this logic:.

System.ComponentModel.Win32Exception: An error occurred trying to start process '/app/Xabe.FFmpeg.dll' with working directory '/app'. Exec format error
at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at Xabe.FFmpeg.FFmpeg.RunProcess(String args, String processPath, Nullable`1 priority, Boolean standardInput, Boolean standardOutput, Boolean standardError)
at Xabe.FFmpeg.FFmpegWrapper.<>c__DisplayClass14_0.<RunProcess>b__0()
at Xabe.FFmpeg.Conversion.Start(String parameters, CancellationToken cancellationToken)

It seems like the code in question tries to find any file that contains ffmpeg in the name, which ends up finding (depending on the order of the GetFiles() call, the Xabe.FFmpeg.dll file incorrectly:

if (!string.IsNullOrWhiteSpace(ExecutablesPath))
{
    FFprobePath = new DirectoryInfo(ExecutablesPath).GetFiles()
                                              .FirstOrDefault(x => x.Name.ToLower()
                                                                    .Contains(_ffprobeExecutableName.ToLower()))?
                                              .FullName;
    FFmpegPath = new DirectoryInfo(ExecutablesPath).GetFiles()
                                             .FirstOrDefault(x => x.Name.ToLower()
                                                                   .Contains(_ffmpegExecutableName.ToLower()))?
                                             .FullName;
    ValidateExecutables();
    _lastExecutablePath = ExecutablesPath;
    return;
}