我试图将一个.net控制台应用程序移植到docker容器中。该应用程序尝试调用ffmpeg.exe,但我遇到了错误?是否可能在该容器中无法运行exe文件?
static void encoder(string inputFile, string outputFolder, string outputFileName)
{
if (!Directory.Exists(outputFolder))
{
Directory.CreateDirectory(outputFolder);
}
var GetDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
// Part 1: use ProcessStartInfo class.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.FileName = GetDirectory + @"/ffmpeg.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
// Part 2: set arguments.
startInfo.Arguments = "-i " + inputFile + " -q:a 8 -filter:a loudnorm " + outputFolder + outputFileName;
// Part 3: start with the info we specified.
// ... Call WaitForExit.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.StandardInput.WriteLine("y");
exeProcess.WaitForExit();
}
}
错误
OPUS-Encoder System.ComponentModel.Win32Exception (8): An error occurred trying to start process '/App/ffmpeg.exe' 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 System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at Program.<<Main>$>g__encoder|0_0(String inputFile, String outputFolder, String outputFileName) in /App/Program.cs:line 77
at Program.<Main>$(String[] args) in /App/Program.cs:line 34
谢谢
ffpmeg.exe
。Exec format error
错误是 Linux 错误。你不能在 Linux 上运行 Windows 二进制文件,你需要发布并调用 Linux 二进制文件。在 Linux 上,你可以通过 apt-get 安装ffmpeg
。该文件不会有.exe
扩展名。 - Panagiotis Kanavos