Commit 9fb4b19c authored by Xavier de Blas's avatar Xavier de Blas

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

parent ce00d0cc
......@@ -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;
}
/*
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment