Question

I'm using ffmpeg to compile videos, and I'd like to prevent it from displaying a console when performing actions.

Here's how I start ffmpeg:

ProcessStartInfo si = new ProcessStartInfo();
si.Arguments = string.Format("-y -loop 1 -t " + DucationToString(frameDuration) + " -r 25 -f image2 -i \"{0}\" \"{1}\"",
                             item.Value, otpt);
si.FileName = "ffmpeg";
si.UseShellExecute = false;

Process.Start(si).WaitForExit();

No matter the settings I try in ProcessStartInfo, the console always shows up.

How do I prevent the console from being shown when creating child process?

Était-ce utile?

La solution

You should try to use

ProcessStartInfo si = new ProcessStartInfo();
si.WindowStyle = ProcessWindowStyle.Hidden;
si.CreateNoWindow = true;
si.UseShellExecute = false;

MSDN refs

Autres conseils

Set ProcessStartInfo.CreateNoWindow to true.

Note that:

To use ProcessWindowStyle.Hidden or ProcessStartInfo.CreateNoWindow the ProcessStartInfo.UseShellExecute property must be false.

Have you added this in your code

    si.CreateNoWindow = true;
    si.RedirectStandardOutput = true;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top