当前位置: 动力学知识库 > 问答 > 编程问答 >

command line - Problem launching FFmpeg inside C#

问题描述:

I'm calling FFmpeg via ProcessStartInfo inside my C# application however, I can't keep getting the error;

File for preset 'lossless_slow' not

found

Here's my C# code;

var processinfo = new ProcessStartInfo();

processinfo.FileName = "FFmpeg\\bin\\ffmpeg.exe";

processinfo.Arguments = "-i C:\Temp\input.mp4 -y -acodec aac -strict experimental -ab 96k -vcodec libx264 -vpre lossless_slow -crf 22 -threads 0 C:\Temp\output.mp4"

processinfo.RedirectStandardOutput = true;

processinfo.RedirectStandardError = true;

processinfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;

processinfo.UseShellExecute = false;

processinfo.LoadUserProfile = true;

processinfo.EnvironmentVariables.Add("HOME", @"C:\Users\wonea\.ffmpeg");

var reg = System.Diagnostics.Process.Start(processinfo);

string output = string.Empty;

string error = string.Empty;

using (System.IO.StreamReader myOutput = reg.StandardOutput)

{

output = myOutput.ReadToEnd();

}

using (System.IO.StreamReader myError = reg.StandardError)

{

error = myError.ReadToEnd();

}

Now I've put my presets in the folder

C:\Users\wonea\ .ffmpeg

and included this in the Windows path user variable HOME. This works fine when running FFmpeg from the command line, however fails when the commands are issued inside my C# application, why!? Thanks for any help...!

Also of note, I'm running the service as "Network Service".

网友答案:

In situations like this I always start up the procmon tool which can show you all the file operations of your application. You can set up a filter based on the name of the preset file and see where ffmpeg is trying to locate it.

网友答案:

Setting the HOME variable looks good here.

The only thing I see is that in the code you set HOME to be @"C:\Users\wonea.ffmpeg" and in the text you mention the file is at : C:\Users\wonea.ffmpeg

Is one of these a typo?

分享给朋友:
您可能感兴趣的文章:
随机阅读: