High CPU usage on desktops

I would love to see more discussion here on performance tuning on a desktop. I’ll start by saying i’m a total newbie-- today’s my first day, i’ve only loaded the Server app (haven’t yet tried the client, or the android client). I’ve connected 3 cams (and see the unlicensed banner on the 3rd) via custom URL per useful tips on the ‘XMEye’ thread in the support forum. Kudos so far.

That said, i’ve noticed via system responsiveness, and then confirmed in running TaskMan that when minimized and not displaying any video NetCamStudio runs at ~30%, and if displaying the Server applet UI and displaying video my CPU pegs red. I did notice that even with the record rules enabled (as they are by default) they don’t record unless i select/activate motion on the right-click menu per cam. I’m fine with that btw (albeit i’d probably like 1 switch i could flip for all cams that says ‘i’m leaving’ and would like to record and thus activate motion, along with ability to say ‘i’m home’ and disable motion so that i don’t record while i’m here), though seems like there should be some dramatically lower requirement just to display some video without the need for being ready to at a moments notice persist to disk… and in so doing pay a much lower CPU cost for the ability. (and in turn, would hope by saying ‘i’m leaving’ or ‘i’m home’ have that cost while i’m away incurred on the machine’s CPU, but not while i’m sitting there and don’t need record).

In short, i’d prefer to just leave the ‘server running’ and have the UI accessible… but not have it hog the CPU while i’m home and at the machine, and be available for me to tell it… ‘i’m leaving’… at which time, it could then really enable recording, and use as much CPU as it needs to be ready to do so and/or to do so based on motion it sees.

next day, post some add’l investigation on my part.
Reviewed some related GPU support threads in the forum. Namely these 2: #1 on updating graphics driver, and #2 on some GPU related internals wrt NCS impl utilization constraints

wrt, #1 I did after some effort update my driver. In short, my tablet is old/unimpressive at this time in history. But with some research, I successfully updated the Sony VAIO SVT11213CXB Intel HD Graphics from an Intel 10/16/17 v20.19.15.4835 on my Win10 64bit install to an Intel 3/25/20 v20.19.15.5126 version, which indicates DirectX Runtime v12.0 with Hw Support ver 11.1. (and perhaps this assists in either tweaking NCS to utilize this older GPU capability, OR succinctly allows someone to confirm it’s ‘by design’ that this is NOT supported in this older hw).

That said, on the NCS X Server tab’s encoding page (in switching from the default CPU/SingleThread to) Intel (as well as trying all other options in the dropdown, in both Single and Auto/multi threaded mode) I saw NO difference; namely no utilization of the GPU when looking on the TaskMan Performance tab.

What I DID notice, which achieves my goal of being able to keep the Server running and NOT over-taxing the system… was that while/if the NCS Server UI is showing cameras whether maximized/visible or minimzed it is an unacceptable CPU drain, WHEREAS while that UI is on the ‘Encoding’ tab it stays below 3% (which is great) with ‘motion’ disabled for all cameras (which matches my ‘i’m home’ state, where I don’t need it ‘ready to record’
I’ll further note, even when cameras are set to ‘motion’ enabled, so that the enabled recording rule works… for 1st camera motion enabled CPU stays at ~20%, and for 2nd camera motion enabled CPU stays at ~40% (v. 95-99%) when UI is on the ‘encoding tab’ (v. on the cameras display)… true whether UI is visible/rendering OR minimized to the taskbar… AND it still records properly when there’s motion!

SO-- I have discovered a workaround, though it’s quite clear to me, there is opportunity to further optimize the app to mitigate performance impact on lower class machines so that while minimized it can result in minimal system overhead (and still be highly functional)… AND then quickly be available to do its job to record, and/or be visible when UI is rendered on screen. It is possible; though it appears it warrants an update.

In short, 2 things could be tweaked to greatly improve perf/usability:

  1. when UI is displaying cameras (but minimized to the toolbar), under the covers the UI applet should do whatever its doing when it renders the settings.encoding tab to minimize the CPU utilization. In this way, one can keep the NCS Server running and even on the Camera display (primary left most button on toolbar) but have minimal required CPU impact. If we left it there while minimzed that would be super.
    Further/even better-- maybe another iteration-- the non-minimized to toolbar UI could further, display each cam window with ability to be ‘frozen’ on the LKG screenshot when it was last ‘running’ and it could present itself with a VCR control play/pause button, so that in general while paused (it would have min CPU utilization) and when playing (when i’m viewing it) it is fine to use CPU. Clicking the running video would act like YouTube and pause it to a screenshot with a ‘play’ button, and/or leave it running (and burning CPU) with a pause button visible when hovering over center. Clicking the video whether button is visible or not (depending on hover state and time since) would have expected result to pause or play (again, like a YouTube video).
  2. there should be a toolbar button (togglable) on the toolbar which changes state between ‘home’ & ‘away’ which enables the desired/MRU per camera state wrt ‘motion/audio detector’ on/off state… so that in short, the lower CPU consumption off state can be assoc w/‘home’ whereas the high cpu consumption on states (which enabled desired recording) can be enabled/disabled together/easily when i’m away from the desktop and have no issue with the tradeoff associated with high CPU use in return for security cam video recording capability.
    And a further, small iteration feature here wrt this button… namely, a set-able ‘delay on exit’ timer so I could set for 3 or 5min, etc… such that I don’t trip all the cameras as family and I make it from my desk/their locations out the door causing unecessary recordings… v. have it recording while we’re gone so we know about any activity in our absence.

Any comments/questions/concerns welcomed; and if dev can use this to assist in further tuning i’d greatly appreciate it. Thanks!

Hi and thanks for all your input!
I recommend to run Netcam Studio as a service which will not involve rendering to the UI as when running NCS X. For interaction with NCS service start the NCS Windows client or use the web client.
Also as you discovered update all drivers for CPU and graphics card since utilizing a GPU will lower the overall CPU usage a lot. In older computers hardware encoding is not always possible since that is not implemented in the GPU. Netcam Studio will then use the CPU.
Increase the number of threads for encoding is usually good when for example the recorded video is jumpy and irregular assuming there are still capacity in the CPU.
When running a desktop with an older CPU is it usually well invested to reflect over the necessary resolution and frame rate from each camera and also the recorded frame rate.

You have also many great suggestions for the future which we thank for. Many of the suggestions are implemented in home security systems. Netcam Studio can be controlled from these systems using webAPI presented in the support section on the web site. Netcam Studio will in the future focus on being a camera surveillance server for Windows. There are enough challenges in that area also in the future :slight_smile:

Thanks again,

Thanks for the response. I can appreciate your focus and direction. (and in general i’m a tinkerer, and more of a plumber than a painter… so i like the notion of scripting what i want v. you spending time on UI, etc… which in part was why i initially came asking re: perf, and got to UI/UX in part as a workaround wrt perf… though sounds like we agree re: utility of some of the home use scenarios).

I have started down this path, and setup as a service, created a unique new user so that i can get a permanent/reusable token in my scripts v. using a sessionID, etc. And logging on w/the client v. the ServerXapp with UI.

I am able to succesfully turn motionDetectors on/off for enabled cameras. Per some of my other q’s elsewhere in the forum, i opt’ed to skip Android/iDevice and to keep it simple and use my PC’s webcam once i saw the option for setting up that cam to keep an eye on anyone at my keyboard… yet similar for this cam i want to enable/disable that cam entirely wrt NCS connection/usage when i’m Away/Home respectively. I’ve had more trouble scripting that. While in the client i can easily rightClick Source enable/disable… when i attempt to script it i notice that (for SourceID=3 == my LaptopWebCam:
http://localhost:8124/Json/DisconnectCamera?sourceId=3&authToken=myPermToken results in the cam disconnecting… HOWEVER the image in the NCS Client freezes all together, and i have to shut down the client. When i restart it the camera is not longer available as a source. In the debug log i see a yellow error indicating (though i can’t copy the row to paste text here): Source: WCF.SourceIsOutOfBounds; Description: Source(3) is out of bounds. It seems this is a highly ungraceful disconnect and not consistent with how the UI enables it behind the scenes (though i gather it uses a different API and not the json interface)
Of couse, at this point no amount of: http://localhost:8124/Json/ConnectCameraJson?sourceId=3&enabled=true&authToken= results in the camera coming back online. Even after manually recreating the Camera… attempting to toggle enabled=true or false to bring the camera on/offline also doesn’t work; this results an an exception. I gather in reviewing the WSDL via:
i’m missing a ‘provider’ and/or other ‘parameters’, though i’m not sure what…
It’s not obvious to me based on reviewing the WSDL nor on reviewing the params enumerated when i query: http://localhost:8124/Json/GetCameras?authToken=myPermToken

This is the exception:
The server encountered an error processing the request. The exception message is ‘Value cannot be null. Parameter name: value’. See server logs for more details. The exception stack trace is:

at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at Moonware.Server.WCF.MoonwareServerWCF.d__31.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.ServiceModel.Dispatcher.TaskMethodInvoker.d__16.MoveNext() — End of stack trace from previous location where exception was thrown — at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.ServiceModel.Dispatcher.TaskMethodInvoker.InvokeEnd(Object instance, Object[]& outputs, IAsyncResult result) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeEnd(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage7(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

How can i connect/disconnect the camera easily/gracefully, a kin to how i can:
http://localhost:8124/Json/StartStopMotionDetector?sourceId=3&enabled=true&authToken=myPermToken &
associated with states i’d like to flip as part of running one big script when i’m ‘LeavingHome’ and ‘ReturnedBackHome’ respectively?

also… to the extent anyone has created this wheel before which i’m trying to recreate-- is there a ‘known’ place where people keep/share such scripts for review/study/reuse/repurposing by others which you all champion and redir others to? Or should i create such a home out on GitHub? (sample code, particularly for some of these common home use cases would be a great start to ramp myself and i’d presume others… and would assist, like this forum does, in mitigating repeat repeat requests which i fear i’m probably guilty of by asking such an nube question). In any case, thanks for any suggestions. and again best regards.

after an additional month, i wanted to post an update… on referencing the forum & via empirical investigation/experimentation… i have successfully automated my ‘ARM system (mult cams) w/30secDelay’ & DisARM system’ scenarios via PowerShell…
HOWEVER, i believe it is not possible via WebAPI to enable/disable a ‘Source’ (camera) as part of those scripts (eg. to ‘enable’ my disabled PCweb cam). That is to say, i’m fairly confident via scripting solely via web calls, the NCS framework does not expose connect/disconnect methods as web service calls. I further point to the NCSWebUI to highlight the absence of this… namely, http://localhost:8100/#/client/source-list appears to NOT display what the Win32 UI exposes as ‘Source enabled/Online’. There are no entries in the table for sources/cameras which are ‘disabled’, whereas enabled cameras are enumerated in the table i see.

I would be happy to be corrected with an example of how to properly enable (& disable) a configured cam/video source, by anyone who can point me in the right direction. Thanks! --PapaMarc

Here are my scripts for ‘ARM system with delay’ and ‘disARM system’ for others to reference/reuse (they’re not pretty, but they work):

#Arms NCS with Delay on departure

$URLLogon = “http://localhost:8124/Json/Login?username=YourUNHere8password=YourPwdHere
PowerShell Invoke-WebRequest -Uri $URLLogon -Method GET

$URLListCams = “http://localhost:8124/Json/GetCameras?authToken=YourTokenHere
PowerShell Invoke-WebRequest -Uri $URLListCams -Method GET

#ideally, i would enable SourceID=3 PC Webcam here

#enable motion detector on CamN (which facilitates recording to occur on motion)
$URLCam0 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=0&enabled=true&authToken=YourTokenHere
$URLCam1 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=1&enabled=true&authToken=YourTokenHere
#$URLCam2 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=2&enabled=true&authToken=YourTokenHere
#$URLCam3 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=3&enabled=true&authToken=YourTokenHere

#PowerShell Invoke-WebRequest -Uri $URLCam0 -Method GET

1…30 | ForEach {
Start-Sleep -s 1
Write-Progress -activity "Arming System in: " -Status (30-$_)

Invoke-WebRequest -Uri $URLCam0
Invoke-WebRequest -Uri $URLCam1
#Invoke-WebRequest -Uri $URLCam2
#Invoke-WebRequest -Uri $URLCam3

Write-Progress -activity “System ARMED!”

#disarms NCS upon return home

$URLLogon = “http://localhost:8124/Json/Login?username=YourUNHere8password=YourPwdHere
PowerShell Invoke-WebRequest -Uri $URLLogon -Method GET

#List Cams
$URLListCams = “http://localhost:8124/Json/GetCameras?authToken=YourTokenHere
PowerShell Invoke-WebRequest -Uri $URLListCams -Method GET

#disables motion detector on cameras causing motion triggered recording rules to no longer fire
$URLCam0 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=0&enabled=false&authToken=YourTokenHere
$URLCam1 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=1&enabled=false&authToken=YourTokenHere
#$URLCam2 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=2&enabled=false&authToken=YourTokenHere
#$URLCam3 = “http://localhost:8124/Json/StartStopMotionDetector?sourceId=3&enabled=false&authToken=YourTokenHere

#disconnects Laptop cameras
#ideally, i’d disable SourceID=3 (laptop cam) here
#NOT working

Invoke-WebRequest -Uri $URLCam0
Invoke-WebRequest -Uri $URLCam1
#Invoke-WebRequest -Uri $URLCam2

Write-Progress -activity “System disarmed”

btw, as an example by placing a shortcut for PowerShell on the desktop and setting Target:
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -ExecutionPolicy RemoteSigned -File C:\Users<MyWin10UserDir>\Documents\NCSScript\Arm.ps1
I can double-click that shortcut and ARM the system w/delay. Further, if i copy the shortcut into:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs i can further ARM by saying, “Hey Cortana, open/start ARM”. To the extent you consider heading down this slippery slope, you may want to further investigate how to setup Cortana to make its best attempt to recognize and only respond to you…