0

I've created a GUI app that basically loads a video file, launches 3 processes with arguments in sequential order, (ffmpeg, x264, mp4box) and has the ability to abort if needed.

I'm trying to figure out a way to launch these processes without them stealing focus from whatever program is opened. Not necessarily the original form itself...it could be IE, MS WORD, etc...I know about ProcessWindowStyle, however, all options still take focus away. I do not want to start these processes hidden either.

This is an example of my code for starting a process

        Process ffmpegProcess = new Process();
            ffmpegProcess.StartInfo.FileName = Settings.Default.ffmpeg;
            ffmpegProcess.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;   
            string outputaud = text2 + "_audio.aac";
            string AudioBitrate = this.cBAudiobitrate.GetItemText(this.cBAudiobitrate.SelectedItem);
            string ffargs = "-i " + quote + SourceFile + quote + " -filter_complex " + quote + "[0:2][0:3]amerge=inputs=2,pan=stereo|c0=c0+c1|c1=c0+c1[aout]" + quote + " -map " + quote + "[aout]" + quote + " -strict experimental -acodec aac -b:a " + AudioBitrate + "k " + quote + outputaud + quote;              
            ffmpegProcess.StartInfo.Arguments = ffargs;
            ffmpegProcess.Start();

                         while (!ffmpegProcess.HasExited)
                         {
                             if (this.bw404p_withaudio.CancellationPending)
                             {
                                 ffmpegProcess.Kill();

                                 e.Cancel = true;

                                 return;
                             }
                             Thread.Sleep(1000);
                         }

I know about using the Microsoft.VisualBasic Reference and Shell command with AppWinStyle as it has options for launching with no focus, I just can't seem to figure out how to modify my code to make it work with that.

Any ideas?

Thanks

Derek
  • 131
  • 1
  • 1
  • 7
  • Why do you want to create external processes and monitor them? What is the problem you can't handle with some video libraries? – EZI Jul 19 '15 at 21:46
  • I'm trying to automate the process of taking an MXF video file and creating an mp4. I prefer to use ffmpeg/x264 for this process as I know it will produce compliant video/audio. I want to have the ability to see how far along each process is – Derek Jul 19 '15 at 23:05
  • Any ideas? Not sure why I have a -2, I've thoroughly searched this forum and others alike to try and find an answer but none have been able to. I know there is code in the Microsoft.VisualBasic reference, I just need some help implementing it, if its even possible. Thanks! – Derek Jul 22 '15 at 20:20

1 Answers1

0
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;

Is that would you're looking for? More info below

How to start Process hidden?
http://www.dotnetperls.com/process-start
ProcessWindowStyle Enumeration

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Rami Alshareef
  • 7,015
  • 12
  • 47
  • 75
  • This would launch the apps hidden and I wouldn't be able to monitor them. I want to have the ability to monitor them, however I don't want them taking focus when the process launches initally. – Derek Jul 19 '15 at 23:06
  • how would you monitor them if you are not seeing the window or being notified that a process has been launched? – Rami Alshareef Jul 19 '15 at 23:07
  • 2
    Well, the process would still show up in the taskbar and be open behind whatever program I was currently running – Derek Jul 20 '15 at 00:17