Author Topic: CPU Usage  (Read 12940 times)

vasilis

  • Newbie
  • *
  • Posts: 5
    • View Profile
CPU Usage
« on: May 11, 2010, 10:02:49 AM »
Hi,

This is my first post here as I just got your app installed on my iPhone.

First of all, really nice app, well done!

But as always it could be even better. I noticed that my CPU usage for iCamSource, on my MBP, with Preferences closed, is about 12% constantly even when I view or not view the video from my iPhone and irrespective of the sensitivity set on the motion detection.

It would be pretty cool if you could reduce that 12% to something a lot lower, maybe half? With the sensitivity lowered you could reduce the framerate as well as the resolution of the images using in the motion detection (I am sure you already use binary images for the motion detection). Then, when an iPhone is connected and streaming is established, or when a motion event recording initiates, the framerate and resolution would increase. This way you would spend minimum resources (reduce power consumption, heat, reduce carbon footprint! etc.) when nothing is happening or no one is watching.

All the best,
Vasilis

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #1 on: May 11, 2010, 11:03:46 AM »
Thanks for the great feedback. :)

Actually, the CPU usage is from the motion detection logic actually doing the image processing on the images, so the sensitivity won't affect that.

On the Mac version you can change the frequency that the iCamSource checks for motion by copy-and-pasting the following line into an Applications > Utilities > Terminal window and pressing Return:

defaults write com.skjm.icamsource MotionDetectionWait -int 1000

That changes the wait time between motion detection processing jobs from 500 ms (the default) to 1000 ms or 1 second. If you change the 1000 in that line to any other number that should have an effect on your CPU usage.

vasilis

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: CPU Usage
« Reply #2 on: May 11, 2010, 02:31:17 PM »
Thanks for your prompt reply!

I tested on a range of values between 500ms to 8000ms to find an approximately 2.0% CPU improvement between 500 and 8000ms intervals.

500ms   -> 13.5% CPU
1000ms -> 12.5% CPU
2000ms -> 12.0% CPU
4000ms -> 11.6% CPU
8000ms -> 11.5% CPU

Also, please note there was a jump in CPU usage every now and then (I think its period is the same as the interval) by about 0.5% CPU usage. So, for example, with the 8sec interval you could get an about constant 11.5% CPU usage which would then jump to 12% for a bit and then back down to about 11.4-11.5% which means something else is using up the CPU between intervals, it can't be the sleep counter using up 11.5% but I am not sure about the camera drivers, maybe having a feed from the cam open is expensive anyway...

If you can figure something out, it would be great, else I guess 10% is not the end of the world.

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #3 on: May 11, 2010, 04:19:43 PM »
Interesting, thanks. What if you choose No Audio as the audio input?

I believe that you will see lower CPU usage settings when connecting to a network IP camera since you aren't dealing with the video and audio capture and processing from the direct hardware itself.

vasilis

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: CPU Usage
« Reply #4 on: May 11, 2010, 06:50:25 PM »
Thats it! The audio takes up most of the CPU. Without audio and 500ms interval it goes down to 4% and with 1000ms down to 3% which is pretty sweet.

Its interesting to note that with the build-in microphone it seems to use more CPU than with other sources like a USB microphone or the line-in its which is like 4% less, down to 8% total CPU usage.

Thanks for the help!

slappywhite

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: CPU Usage
« Reply #5 on: May 12, 2010, 09:04:47 AM »
Interesting, thanks. What if you choose No Audio as the audio input?

I believe that you will see lower CPU usage settings when connecting to a network IP camera since you aren't dealing with the video and audio capture and processing from the direct hardware itself.


Where is it you disable audio? At the camera itself?

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #6 on: May 12, 2010, 10:31:30 AM »
No, in the iCamSource by choosing "No Audio" from the Audio drop-down list.

slappywhite

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: CPU Usage
« Reply #7 on: May 12, 2010, 10:59:10 AM »
Okay I see, that's for USB/FW/Built-In cams. Any way to reduce CPU on Ethernet/WiFi cams? My four iCam Source apps hover around 16% CPU each. Not a problem, but if there's anything I can do, it's worth a shot.

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #8 on: May 12, 2010, 01:54:28 PM »
If you are using an MJPEG URL you could reduce the frame rate / fps that the camera puts out. That way the iCamSource won't have to receive and handle as many images per second.

OUAnthony

  • Hero Member
  • *****
  • Posts: 801
    • View Profile
Re: CPU Usage
« Reply #9 on: May 12, 2010, 06:43:57 PM »
Are these CPU usage percentages for Macs??? Mine is only between 2-6% for 1 instances of icamsource...with motion detection and push notifications enabled for my IP camera.

zak

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: CPU Usage
« Reply #10 on: June 26, 2010, 04:18:49 PM »
Hey Guys, really enjoying this setup so far.

I found this thread very useful.  I was happy to get my CPU usage down from a constant 12/13% to a more reasonable 3% by turning off audio and decreasing the motion detection frequency. [I was actually surprised that it would be that high for a beefy i7 machine in the first place!]

I did really like having the audio available though.  Would it be possible to enable audio on demand through iCam's interface?  Or to only start processing audio encoding when iCam was connected?  This way when the machine was just sitting around, it wouldn't be doing un-necessary work.

It might also be nice to be able to toggle the audio quality in addition to what I've mentioned so that it wouldn't be as intense - although I'm not sure how that works in the background.

I guess the idea is that when your machine is idle, it should be using basically no CPU, and then when you connect, it makes sense that it spikes up a bit.

Thanks!
« Last Edit: June 26, 2010, 04:20:30 PM by zak »

OUAnthony

  • Hero Member
  • *****
  • Posts: 801
    • View Profile
Re: CPU Usage
« Reply #11 on: June 26, 2010, 07:17:10 PM »
If you have motion detection enabled, it will constantly have to analyze the captured images...so it won't ever quite go to nothing. But like I said, my PC (which is several years old) is only between 2-6% CPU usage with PUSH notifications and motion detection/recording enabled on an IP camera. I guess it'd be higher if I could do audio along with the IP camera.

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #12 on: June 26, 2010, 09:20:51 PM »
What is the CPU difference between choosing an audio input and No Audio? The motion detection processing is more involved than the audio capture, so I would assume that you would see more of a drop in CPU usage when you decrease the rate at which the motion detection processing is performed than if you disable audio processing altogether.

zak

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: CPU Usage
« Reply #13 on: June 27, 2010, 06:55:12 PM »
I thought the same thing, but the audio seems more intensive...

On my system (i7 imac), we are talking about a difference of about 5%.  It's between 2-3% with audio turned off, and about 8% with audio turned on.  Both of these are with the preferences closed, of course.

I've turned my mocap frequency down to about 1.8 seconds.

I'm really happy with the 2-3%, but like I mentioned in my previous post, I'd love to have the option to turn the audio capture on on the fly in case I wanted it when I am tuned in.

Doesn't seem like there would really be a need for audio to be enabled unless you were tuned in.

What do you think?

Stefan

  • Administrator
  • Hero Member
  • *****
  • Posts: 2358
    • View Profile
Re: CPU Usage
« Reply #14 on: June 28, 2010, 11:56:34 AM »
I believe the original thought behind "engaging" the video and audio inputs (besides monitoring the video for motion) was to make sure that no other application blocked the iCamSource from accessing the inputs when the time came.

On some hardware configurations, only one application can access an input at a time, and if, when you attempt to connect via iCam, the input is not able to be acquired by the iCamSource, there's not much that can be done about it programatically.

I suppose that it is something that we could look into, though ... To see what level of a problem it would actually be.