I am running a surveillance system, and wanting to record the video from some CCTV cameras to my PC.
I can get the recording to occur using the VLC command line like this,
vlc rtsp://*username*:*password*@192.168.1.60:554/ch01/0 --qt-start-minimized --sout=#transcode{ab=128,channels=2,samplerate=44100,scodec=none}:file{dst=D:\CCTV\Concord\2019_05_24\2019-05-24_2111_C1.mp4,no-overwrite}
However I want to stop and restart the recording every half an hour so that I get files small enough that I can use.
I wrote a C# application to do this, it simply kills all VLC processes and starts new ones. It is triggered by task scheduler on the half hour.
This works when I run normal VLC instances showing in the taskbar. However I want they to be out of the way in the system tray. I can do this by adding this VLC option,
--qt-start-minimized
Which runs it under background processes if I look in task manager.
My code does this,
foreach(Process process in Process.GetProcesses().Where(x => x.ProcessName == "vlc"))
{
Process.GetProcessById(id).CloseMainWindow();
}
However VLC no longer has a main window, so that doesn't work.
If I do this,
Process.GetProcessById(id).Kill();
The videos get corrupted because VLC doesn't exist gracefully.
I tried the other methods Close, Dispose, but they don't work.
It seems to me that I need to maximise these windows first before calling CloseMainWindow, or find some other way to exit them, or if there is an option in VLC to start a new file every half an hour?