[chronojump] chronojump ffmpegCapture copies ok when ended (hopefully also on win)



commit 9fb4b19cd424281952e9001798a76f8b2329ba35
Author: Xavier de Blas <xaviblas gmail com>
Date:   Wed Jan 9 18:10:10 2019 +0100

    chronojump ffmpegCapture copies ok when ended (hopefully also on win)

 src/executeProcess.cs | 28 ++++++++++++++++++----------
 src/webcamFfmpeg.cs   | 15 +++++++++++++--
 2 files changed, 31 insertions(+), 12 deletions(-)
---
diff --git a/src/executeProcess.cs b/src/executeProcess.cs
index df9eb2b9..55c7bc46 100644
--- a/src/executeProcess.cs
+++ b/src/executeProcess.cs
@@ -207,41 +207,49 @@ class ExecuteProcess
         */
        public static bool IsRunning3 (int processID, string executable)
        {
+                LogB.Information("\nCalled IsRunning3\n");
                //Debug
                Process[] pdebug;
 
-               LogB.Information("executable: ffmpeg");
-               pdebug = Process.GetProcessesByName("ffmpeg");
-               LogB.Information((pdebug.Length == 0).ToString());
+               LogB.Information("running with executable: " + executable);
+               pdebug = Process.GetProcessesByName(executable);
+               LogB.Information((pdebug.Length > 0).ToString());
 
-               LogB.Information("LastPartOfPath of executable: " + Util.GetLastPartOfPath(executable));
+               /*
+               LogB.Information("running with LastPartOfPath of executable: " + 
Util.GetLastPartOfPath(executable));
                pdebug = Process.GetProcessesByName(Util.GetLastPartOfPath(executable));
-               LogB.Information((pdebug.Length == 0).ToString());
+               LogB.Information((pdebug.Length > 0).ToString());
 
-               LogB.Information("executable: " + executable);
+               LogB.Information("running with executable: " + executable);
                pdebug = Process.GetProcessesByName(executable);
-               LogB.Information((pdebug.Length == 0).ToString());
+               LogB.Information((pdebug.Length > 0).ToString());
+               */
 
                //Debug
                Process[] allThisMachine = Process.GetProcesses();
-               LogB.Information("All processes in this machine:");
+                LogB.Information("All processes in this machine containing: " + executable);
                foreach(Process p in allThisMachine)
                {
                        try {
-                               LogB.Information(p.ToString()); //this is problematic on windows
+                                if(p.ToString().Contains(executable))
+                                        LogB.Information(p.ToString()); //this is problematic on windows
                        } catch {
                                LogB.Information("catched at IsRunning3");
                        }
                }
 
-               Process[] pNameArray = Process.GetProcessesByName(Util.GetLastPartOfPath(executable));
+               //Process[] pNameArray = Process.GetProcessesByName(Util.GetLastPartOfPath(executable));
+                Process[] pNameArray = Process.GetProcessesByName(executable);
                if (pNameArray.Length == 0)
                        return false;
 
+                Console.WriteLine("Found one or more " + executable + " process, checking Id");
                foreach(Process p in pNameArray)
                        if(p.Id == processID)
                                return true;
 
+               Console.WriteLine("This Id is not running");
+
                return false;
        }
        /*
diff --git a/src/webcamFfmpeg.cs b/src/webcamFfmpeg.cs
index 255e53b8..f0cc15bc 100644
--- a/src/webcamFfmpeg.cs
+++ b/src/webcamFfmpeg.cs
@@ -133,7 +133,18 @@ public class WebcamFfmpeg : Webcam
                // ffplay /dev/video0
                List<string> parameters = new List<string>();
                int i=0;
-               parameters.Insert (i++, videoDevice);
+
+               parameters.Insert (i ++, "-f");
+               if(os == UtilAll.OperatingSystems.LINUX)
+                       parameters.Insert (i ++, "v4l2");
+               else    //windows
+                       parameters.Insert (i ++, "dshow");
+
+               if(os == UtilAll.OperatingSystems.LINUX)
+                       parameters.Insert (i ++, videoDevice);
+               else
+                       parameters.Insert (i ++, "video=" + videoDevice);
+
                parameters.Insert (i++, "-window_title");
                parameters.Insert (i++, "Chronojump webcam preview");
                return parameters;
@@ -278,7 +289,7 @@ public class WebcamFfmpeg : Webcam
                do {
                        LogB.Information("waiting 100 ms to end Ffmpeg");
                        System.Threading.Thread.Sleep(100);
-               } while(ExecuteProcess.IsRunning3(processID, executable));
+               } while(ExecuteProcess.IsRunning3(processID, "ffmpeg")); //note on Linux and Windows we need 
to check ffmpeg and not ffmpeg.exe
 
                streamWriter = null;
                process = null;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]