Exception in Loop: Object reference not set to an instance of object


I’m running Server 2012 R2 standard with around 30 cameras, and Netcam Studio software version Mainboard is ASUS H170-PRO using on-board graphics, i7-6700, 16GB
.NET version 4.5.51650. 2 x SSD hard-disks.

If I set up to serve all cameras, CPU load is around 20%.
But as I change each to be recorded, the CPU load goes up to 60-70% and the client (on the same machine) becomes slow to respond. Finally, web-service fails. Record settings were set for minimum work (low frame rate etc).

So, I changed strategy to motion induced recording. Now I get many errors as below.
Is there anything I can do to improve the 24h recording? I normally leave the client running on the server, for monitoring. Do I need to add a better graphics card or do something else?

Thanks in advance

After server restart i get follow error: "Object reference not set to an instance of object"

Unfortunately I have never seen this error (despite it gives me already a good idea of where it happens).

Can you please try using Netcam Studio X instead of Service and check in the console to see if by luck we have more details / information.

Also can you please try to set the date of your computer correctly (it’s set in 2559 ??), this may have some strange effects on duration / timestamps calculation.

Did this start with or you never had previous versions ?


For the recording, we were actually looking for a good candidate to evaluate the background-encoding and you look like one :slight_smile:

You can try in the option to enable to Quick-Recording Mode / Background-encoding and:

  1. maybe in the meantime it will solve the problem since it’s a different encoder that will be used
  2. also maybe it may reduce a bit the cpu load since it will record directly in mjpeg and then encode only 1 file at time


You must be up late, or early…!?

OK, I ran only Server X.
It is slow to respond to mouse clicks, and to draw.

I changed the Thai date to Gregorian. I don’t think it did anything.

I think this started with, but I only ran the previous version for a few days.

Console log and recording settings:


The quick record was already set!


Further info:
I switched off all motion detection and recording.
Errors stopped.

I had around 20% CPU background, with no Client or Smartphone.
When I logged in with Client, multi-view, the CPU load went to around 60% and the Server X became …extremely… slow, but seemed to serve OK.


It seems to come from before already (there are other errors like trying to stop recording which is already stopped).

Please do the following:

in NetcamStudioX.exe.config in C:\Program Files (x86)\Netcam Studio


<add key="EventLogsToFile" value="true" />

Then reproduce the issue one more time.

Collect the current log file in C:\ProgramData\Moonware\Netcam Studio\Server and post it back here.

Hopefully it will allow me to understand the reason of this. Also strange that the problem is in WorkerThreadFFMPEG if you have background-encoding enabled, in this case it should be in WorkerThreadMJPEG


I reproduced it to a log file in the dropbox link here:


Great, having a look now.

Can you please also post a screenshot on how the scheduler looks for a source, let’s say the source nb 24.

It seems to confuse a bit netcam studio between motion detection and recording…


Here you are: It was originally 100% recoding, then I used “No action” to clean it, then re-wrote “motion”.


Not sure if related:
When I deleted one source (camera unstable), the naming of the sources in the footnote of the video became out of correspondence with the actual camera. To re-set all of the source names, I used “edit video source” to simply re-save each one without editing.


If you have this with the Quick-Record mode can you please check if it’s also here without it?


Without Quick-record mode starting at 17:13:00
Looks like the error is not there.


I’ll be online again in 16hrs or so…is there anything else you need?


For now I have all I need. Thank you.

Unfortunately I don’t yet exactly know the exact reason of the problem so probably I will ask you later or tomorrow to upgrade to another version which will be improved in term of logging in this area so that I can really figure out the root cause.

At least it’s already better if you can use the standard recording mode in the meantime and if it’s just the Quick-Recording mode which is impacted.


I have uploaded a new version, when you have opportunity please uninstall your current version.

Download the one from this thread on dropbox:

And install it over to see if it helps, your settings should be kept however i’m not 100% sure it will fix the problem.

If it still occurs please provide logs from this version, they will hopefully give a bit more details about the problem.

I suppose that’s is related to the fact you have several sources timing out but still trying to record (therefore generating empty file or trying to record but not being able to get the images). I have added some some checks in this direction to prevent problems due to this…


And just regarding your recording settings (Crf). I think that better quality / lower Crf uses less Cpu because it’s not compressing as much (and generates bigger files).

Not sure it will make a huge difference but I suppose that for lower Cpu, the Crf setting should be set on the best quality possible. In case of background encoding it won’t make any difference during the recording itself (only during the background encoding operation which may be a bit faster).


Thanks for the update. I played with Crf (compression factor?) before, and had already figured out that no compression is probably better for me. However, it didn’t seem to make much difference to the CPU load.

I uninstalled the program, and installed and logged the console to a text file as before.

I changed roughly half of the sources to record 24x7. No motion detection.
The first start-up had a server connection warning. The second start-up did not reproduce it.
Both logs are in the following dropbox link.
I hope it helps!


Well, I just found that Server 2012 Power management was at least responsible for the slow down: Power option changed from “Balanced” to “high performance” (!)
CPU % dropped significantly, and Netcam Server X FPS, response to redraw, mouse clicks improved considerably…
Didn’t change the Exceptions for ultra-fast recording, however… :
Anyway, I’m fine without it, at the moment.


I’m still investigating however the latest logs shows that it’s not anything that iI was suspecting so I’m a bit lost…

Yes, I always forget about this high-performance mode on Windows Server but i’ve already been impacted by the setting a few times in the past.