waveform80 / pistreaming

A little demo of streaming the Pi's camera to web browsers
BSD 3-Clause "New" or "Revised" License
765 stars 205 forks source link

(Question) high CPU usage with pistreaming #30

Closed ligc closed 6 years ago

ligc commented 7 years ago

I noticed that the pistreaming uses quite a bit CPU(around 70%) on Raspberry PI 3, the majority of the CPU usage is on avconv, any suggestion on how to reduce the CPU usage with pistreaming? I am trying to preserve CPU for further video analysis effort. Thanks.

PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
13718 root      20   0  217464  35556  21256 S  70.8  4.0   1:04.35 avconv
13707 root      20   0  118320  17132   8104 S  11.8  1.9   0:12.03 python3
waveform80 commented 6 years ago

Sorry, that's pretty much unavoidable. It's because ffmpeg is being used to handle MPEG1 compression on the CPU (as opposed to using the GPU to do H.264 - see the README for all the background on why I originally picked this method). That said, I believe it only pegs one core - you should still have the other three available for processing (and don't worry about the GIL: it's a separate process doing the MPEG1 conversion).