I am trying to create a simple video converter that uses ffmpeg (console
application). To do this I am using the Process class hooking up the
OutputDataReceived event to get the output from the program.

The problem is that the event is never raised. I saw that there was a bug
about this before 2.4 but now in 2.10 the problem still exists for me. Could
the reason be that ffmpeg spawns multiple threads or something? This same
code works great in Windows:

        public void Start ()
                {
                        if (File.Exists (_outputFileName)) {
                                File.Delete (_outputFileName);  
                        }
                        
                        // Set up the process
                        movieEncoderProcess = new Process ();

                        string ffmpegPath = "usr/local/bin/ffmpeg";

                        movieEncoderProcess.StartInfo.WindowStyle = 
ProcessWindowStyle.Hidden;
                        movieEncoderProcess.StartInfo.UseShellExecute = false;
                        movieEncoderProcess.StartInfo.FileName = ffmpegPath;

                        movieEncoderProcess.EnableRaisingEvents = true;
                
                        movieEncoderProcess.StartInfo.RedirectStandardOutput = 
true;
                        movieEncoderProcess.StartInfo.Arguments = _argument;

                        movieEncoderProcess.OutputDataReceived += 
HandleOutputDataReceived;     
                        movieEncoderProcess.Exited += new EventHandler
(movieEncoderProcess_Exited);

                        movieEncoderProcess.Start ();
                        movieEncoderProcess.BeginOutputReadLine ();
                }


                void HandleOutputDataReceived (object sender, 
DataReceivedEventArgs e)
                {
                        // Only returns null when the process is finished
                        Console.WriteLine("Output is: " + e.Data);
                }

--
View this message in context: 
http://mono.1490590.n4.nabble.com/OutputDataReceived-event-not-raised-when-using-the-Process-class-together-with-Ffmpeg-tp4649705.html
Sent from the Mono - OSX mailing list archive at Nabble.com.
_______________________________________________
Mono-osx mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/mono-osx

Reply via email to