0

This is the code i cant understand why its showing the console window of the process .

class Ffmpeg
    {
        NamedPipeServerStream p;
        String pipename = "mytestpipe";
        byte[] b;
        System.Diagnostics.Process process;
        string ffmpegFileName;
        string workingDirectory;

        public Ffmpeg()
        {
            workingDirectory = Path.GetDirectoryName(Application.LocalUserAppDataPath) + @"\workingDirectory";
            ffmpegFileName = @"\ffmpeg.exe";
            if (!Directory.Exists(workingDirectory))
            {
                Directory.CreateDirectory(workingDirectory);
            }
            ffmpegFileName = workingDirectory + ffmpegFileName;
        }

        public void Start(string pathFileName, int BitmapRate)
        {
            string outPath = pathFileName;
            p = new NamedPipeServerStream(pipename, PipeDirection.Out, 1, PipeTransmissionMode.Byte);
            b = new byte[1920 * 1080 * 3]; // some buffer for the r g and b of pixels of an image of size 720p

            ProcessStartInfo psi = new ProcessStartInfo();
            psi.WindowStyle = ProcessWindowStyle.Hidden;
            psi.UseShellExecute = false;
            psi.CreateNoWindow = false;
            psi.FileName = ffmpegFileName;
            psi.WorkingDirectory = workingDirectory;
            psi.Arguments = @"-f rawvideo -pix_fmt bgr0 -video_size 1920x1080 -i \\.\pipe\mytestpipe -map 0 -c:v libx264 -r " + BitmapRate + " " + outPath;
            //psi.RedirectStandardOutput = true;
            process = Process.Start(psi);
            process.EnableRaisingEvents = false;
            p.WaitForConnection();
        }

I did psi.WindowStyle = ProcessWindowStyle.Hidden; but still when i run the process i see the window . Why is that ?

joneK
  • 241
  • 1
  • 4
  • 13
  • read the documentation, it show with screen shot how `None look like http://msdn.microsoft.com/en-us/library/system.windows.window.windowstyle.aspx` – Mzf Jun 07 '13 at 08:34
  • CreateNoWindow = true; ? [documentation](http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.createnowindow.aspx) – Igarioshka Jun 07 '13 at 08:34
  • You should read this question to get a more detailed answer http://stackoverflow.com/questions/5094003/net-windowstyle-hidden-vs-createnowindow-true – Steve Jun 07 '13 at 08:43

1 Answers1

3

This is the cause of your problem:

psi.CreateNoWindow = false;

Should be true.

ElmoVanKielmo
  • 10,907
  • 2
  • 32
  • 46