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.e开发者_C百科xe";
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?
精彩评论