If you are running Agent DVR on a slow computer and keep getting errors like OPEN_INPUT: file not found
You can look in the logs and see things like:
1 2 3 4 5 6 |
Camera 1: DoStart: Reader: Camera 1: OPEN_INPUT:No such file or directory at CoreLogic.Sources.Combined.MediaStream.DoStart() Camera 1: SourceErrorHandler: CoreLogic.Sources.Combined.MediaStream:Reader: Camera 2: OPEN_INPUT:No such file or directory Camera 1: SourcePlayingFinished: Playing finished (SourceError) Camera 1: NextReconnectTarget: Reconnecting in 1s Connect: creating pipe *pipe GUID* Connect: Cannot access a closed pipe. at CoreLogic.Extensions.WaitForConnectionEx(NamedPipeServerStream stream, ManualResetEvent cancelEvent) at CoreLogic.Sources.DVR.Connect() |
And the cameras sometimes appear and sometimes don’t, the logs actually give a good hint of what’s going on.
OPEN_INPUT is looking for a pipe, which is only being created later on where it says creating pipe
I tried all kinds of things like using CPU, GPU, using a different version of ffmpeg, lowering the bitrate of the streams, but the problem is a race condition that happens before all that can have any effect. When it finally starts working, it works fine for any quality setting.
OK, how do we fix this? Easy. Before you start make sure the service isn’t running. Run services.msc
, look for a service called Agent
, which should be one of the first ones, and press stop.
Also look for the file Program files\Agent\CoreLogic.dll
and make a backup copy of it.
Now get your favorite .NET decompiler (I used dnSpy which wasn’t great but worked) and open CoreLogic.dll
.
Look for the class CoreLogic.Sources.Combined.NamedPipe
and look for the public void Start()
method. Right click and choose Edit Method (C#). Add the following lines so it looks like this:
1 2 3 4 5 6 7 |
public void Start() { this.DVR.Start(); CoreLogic.Utilities.Logger.LogDebug("Called start, will wait...", null, "Start"); System.Threading.Thread.Sleep(500); CoreLogic.Utilities.Logger.LogDebug("Continuing...", null, "Start"); } |
Now press File > Save module, and save it as CoreLogic.dll
. This will update the file in-place. Now go back to services.msc
and restart the service. It should work after a couple seconds. Your log should look like this now:
(The first time it tries I still get an error, but the next time I see this:)
1 2 3 4 5 6 7 8 9 |
2:02:15 PM Camera 1: CheckReconnect: Reconnecting 2:02:15 PM Camera 1: EnableDevice: Enabled 2:02:15 PM Start: Called start, will wait... 2:02:15 PM Connect: creating pipe *GUID* 2:02:16 PM PortScanner: checking: *ip address* 2:02:16 PM PortScanner: checking: *ip address* ... 2:02:16 PM Start: Continuing... 2:02:16 PM Camera 1: SetupFormat: Finding Stream Info |
Notice how the pipe is created right after the wait starts, so 500ms is pretty safe. Enjoy!