Open rdavey228 opened 5 years ago
Try passthrough recording. https://rawgit.com/Motion-Project/motion/master/motion_config.html#movie_passthrough
Thanks but that doesn’t help me
The documentation says it will ignore any text overlays which I need and also any masks applied to the camera. I need the masks as it’s in a residential area and part of the camera covers a road that I do not want to trigger on every time a car goes past.
I can’t believe that even with one camera that at 640x960 resolution can’t record without spiking the cpu to 100% on a system that has been given 6 processors and is on enterprise spec hardware that’s just ludicrous
Your RTSP video stream is already encoded. To do motion detection on it, your server needs to decode (in CPU) the video stream, then run motion detection on the raw video. Motion software then adds text overlays to the raw video, then encodes it (in CPU) to whatever format that you've selected. The video encoding is VERY CPU intensive.
With pass-through recording, the idea is to skip the encoding part. That also means you can't add text overlays onto the video because that involves decode-add-encode.
If you still want text overlays, you could offload video encoding (and maybe encoding too) to the GPU. Make sure your ffmpeg library supports hardware accelerated video encoder. In your thread-1.conf
file, set your preferred encoder this way ffmpeg_video_codec <format>:<encoder>
. Example ffmpeg_video_codec mp4:h264_nvenc
. Which encoder to use depends on what's available on your system. Please read ffmpeg hwaccel documentation for more info. If you do go down this option, please report back on how you went. I'm interested to know how hwaccel perform on other systems.
Hi jasaw
I have tried your suggestion but my CPU is still flatlined at 100%.
Only happens when recording. My CPU when streaming but not recording all 4 cameras at 1920x1080 is hovering around 20/30% CPU.
That means you're still using CPU to encode the video. Make sure you actually have a hardware accelerated video encoder.
Run ffmpeg -encoders
and see which hardware accelerated video encoder is available on your system. h264_nvenc
won't be available if you don't have nVidia GPU. If you have Intel GPU, try h264_vaapi
instead if it's available.
Yep - Ran that command and got the following output
Encoders:
V..... = Video
A..... = Audio
S..... = Subtitle
.F.... = Frame-level multithreading
..S... = Slice-level multithreading
...X.. = Codec is experimental
....B. = Supports draw_horiz_band
.....D = Supports direct rendering method 1
------
V..... a64multi Multicolor charset for Commodore 64 (codec a64_multi)
V..... a64multi5 Multicolor charset for Commodore 64, extended with 5th color (colram) (codec a64_multi5)
V..... alias_pix Alias/Wavefront PIX image
V..... amv AMV Video
V..... apng APNG (Animated Portable Network Graphics) image
V..... asv1 ASUS V1
V..... asv2 ASUS V2
V..... avrp Avid 1:1 10-bit RGB Packer
V..X.. avui Avid Meridien Uncompressed
V..... ayuv Uncompressed packed MS 4:4:4:4
V..... bmp BMP (Windows and OS/2 bitmap)
V..... cinepak Cinepak
V..... cljr Cirrus Logic AccuPak
V.S... vc2 SMPTE VC-2 (codec dirac)
V.S... dnxhd VC3/DNxHD
V..... dpx DPX (Digital Picture Exchange) image
VFS... dvvideo DV (Digital Video)
V.S... ffv1 FFmpeg video codec #1
VF.... ffvhuff Huffyuv FFmpeg variant
V..... flashsv Flash Screen Video
V..... flashsv2 Flash Screen Video Version 2
V..... flv FLV / Sorenson Spark / Sorenson H.263 (Flash Video) (codec flv1)
V..... gif GIF (Graphics Interchange Format)
V..... h261 H.261
V..... h263 H.263 / H.263-1996
V.S... h263p H.263+ / H.263-1998 / H.263 version 2
V..... libx264 libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V..... libx264rgb libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
V..... h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
V..... h264_omx OpenMAX IL H.264 video encoder (codec h264)
V..... h264_vaapi H.264/AVC (VAAPI) (codec h264)
V..... nvenc NVIDIA NVENC H.264 encoder (codec h264)
V..... nvenc_h264 NVIDIA NVENC H.264 encoder (codec h264)
V..... hap Vidvox Hap
V..... libx265 libx265 H.265 / HEVC (codec hevc)
V..... nvenc_hevc NVIDIA NVENC hevc encoder (codec hevc)
V..... hevc_nvenc NVIDIA NVENC hevc encoder (codec hevc)
V..... hevc_vaapi H.265/HEVC (VAAPI) (codec hevc)
VF.... huffyuv Huffyuv / HuffYUV
V..... jpeg2000 JPEG 2000
VF.... libopenjpeg OpenJPEG JPEG 2000 (codec jpeg2000)
VF.... jpegls JPEG-LS
VF.... ljpeg Lossless JPEG
VFS... mjpeg MJPEG (Motion JPEG)
V..... mjpeg_vaapi MJPEG (VAAPI) (codec mjpeg)
V.S... mpeg1video MPEG-1 video
V.S... mpeg2video MPEG-2 video
V..... mpeg2_vaapi MPEG-2 (VAAPI) (codec mpeg2video)
V.S... mpeg4 MPEG-4 part 2
V..... libxvid libxvidcore MPEG-4 part 2 (codec mpeg4)
V..... msmpeg4v2 MPEG-4 part 2 Microsoft variant version 2
V..... msmpeg4 MPEG-4 part 2 Microsoft variant version 3 (codec msmpeg4v3)
V..... msvideo1 Microsoft Video-1
V..... pam PAM (Portable AnyMap) image
V..... pbm PBM (Portable BitMap) image
V..... pcx PC Paintbrush PCX image
V..... pgm PGM (Portable GrayMap) image
V..... pgmyuv PGMYUV (Portable GrayMap YUV) image
VF.... png PNG (Portable Network Graphics) image
V..... ppm PPM (Portable PixelMap) image
VF.... prores Apple ProRes
VF.... prores_aw Apple ProRes (codec prores)
V.S... prores_ks Apple ProRes (iCodec Pro) (codec prores)
V..... qtrle QuickTime Animation (RLE) video
V..... r10k AJA Kona 10-bit RGB Codec
V..... r210 Uncompressed RGB 10-bit
V..... rawvideo raw video
V..... roqvideo id RoQ video (codec roq)
V..... rv10 RealVideo 1.0
V..... rv20 RealVideo 2.0
V..... sgi SGI image
V..... snow Snow
V..... sunrast Sun Rasterfile image
V..... svq1 Sorenson Vector Quantizer 1 / Sorenson Video 1 / SVQ1
V..... targa Truevision Targa image
V..... libtheora libtheora Theora (codec theora)
VF.... tiff TIFF image
VF.... utvideo Ut Video
V..... v210 Uncompressed 4:2:2 10-bit
V..... v308 Uncompressed packed 4:4:4
V..... v408 Uncompressed packed QT 4:4:4:4
V..... v410 Uncompressed 4:4:4 10-bit
V..... libvpx libvpx VP8 (codec vp8)
V..... vp8_vaapi VP8 (VAAPI) (codec vp8)
V..... libvpx-vp9 libvpx VP9 (codec vp9)
V..... libwebp_anim libwebp WebP image (codec webp)
V..... libwebp libwebp WebP image (codec webp)
V..... wmv1 Windows Media Video 7
V..... wmv2 Windows Media Video 8
V..... wrapped_avframe AVFrame to AVPacket passthrough
V..... xbm XBM (X BitMap) image
V..... xface X-face image
V..... xwd XWD (X Window Dump) image
V..... y41p Uncompressed YUV 4:1:1 12-bit
V..... yuv4 Uncompressed packed 4:2:0
VF.... zlib LCL (LossLess Codec Library) ZLIB
V..... zmbv Zip Motion Blocks Video
A..... aac AAC (Advanced Audio Coding)
A..... ac3 ATSC A/52A (AC-3)
A..... ac3_fixed ATSC A/52A (AC-3) (codec ac3)
A..... adpcm_adx SEGA CRI ADX ADPCM
A..... g722 G.722 ADPCM (codec adpcm_g722)
A..... g726 G.726 ADPCM (codec adpcm_g726)
A..... adpcm_ima_qt ADPCM IMA QuickTime
A..... adpcm_ima_wav ADPCM IMA WAV
A..... adpcm_ms ADPCM Microsoft
A..... adpcm_swf ADPCM Shockwave Flash
A..... adpcm_yamaha ADPCM Yamaha
A..... alac ALAC (Apple Lossless Audio Codec)
A..... comfortnoise RFC 3389 comfort noise generator
A..X.. dca DCA (DTS Coherent Acoustics) (codec dts)
A..... eac3 ATSC A/52 E-AC-3
A..... flac FLAC (Free Lossless Audio Codec)
A..... g723_1 G.723.1
A..... libgsm libgsm GSM (codec gsm)
A..... libgsm_ms libgsm GSM Microsoft variant (codec gsm_ms)
A..X.. mlp MLP (Meridian Lossless Packing)
A..... mp2 MP2 (MPEG audio layer 2)
A..... mp2fixed MP2 fixed point (MPEG audio layer 2) (codec mp2)
A..... libtwolame libtwolame MP2 (MPEG audio layer 2) (codec mp2)
A..... libmp3lame libmp3lame MP3 (MPEG audio layer 3) (codec mp3)
A..... libshine libshine MP3 (MPEG audio layer 3) (codec mp3)
A..... nellymoser Nellymoser Asao
A..X.. opus Opus
A..... libopus libopus Opus (codec opus)
A..... pcm_alaw PCM A-law / G.711 A-law
A..... pcm_f32be PCM 32-bit floating point big-endian
A..... pcm_f32le PCM 32-bit floating point little-endian
A..... pcm_f64be PCM 64-bit floating point big-endian
A..... pcm_f64le PCM 64-bit floating point little-endian
A..... pcm_mulaw PCM mu-law / G.711 mu-law
A..... pcm_s16be PCM signed 16-bit big-endian
A..... pcm_s16be_planar PCM signed 16-bit big-endian planar
A..... pcm_s16le PCM signed 16-bit little-endian
A..... pcm_s16le_planar PCM signed 16-bit little-endian planar
A..... pcm_s24be PCM signed 24-bit big-endian
A..... pcm_s24daud PCM D-Cinema audio signed 24-bit
A..... pcm_s24le PCM signed 24-bit little-endian
A..... pcm_s24le_planar PCM signed 24-bit little-endian planar
A..... pcm_s32be PCM signed 32-bit big-endian
A..... pcm_s32le PCM signed 32-bit little-endian
A..... pcm_s32le_planar PCM signed 32-bit little-endian planar
A..... pcm_s64be PCM signed 64-bit big-endian
A..... pcm_s64le PCM signed 64-bit little-endian
A..... pcm_s8 PCM signed 8-bit
A..... pcm_s8_planar PCM signed 8-bit planar
A..... pcm_u16be PCM unsigned 16-bit big-endian
A..... pcm_u16le PCM unsigned 16-bit little-endian
A..... pcm_u24be PCM unsigned 24-bit big-endian
A..... pcm_u24le PCM unsigned 24-bit little-endian
A..... pcm_u32be PCM unsigned 32-bit big-endian
A..... pcm_u32le PCM unsigned 32-bit little-endian
A..... pcm_u8 PCM unsigned 8-bit
A..... real_144 RealAudio 1.0 (14.4K) (codec ra_144)
A..... roq_dpcm id RoQ DPCM
A..X.. s302m SMPTE 302M
A..X.. sonic Sonic
A..X.. sonicls Sonic lossless
A..... libspeex libspeex Speex (codec speex)
A..X.. truehd TrueHD
A..... tta TTA (True Audio)
A..X.. vorbis Vorbis
A..... libvorbis libvorbis (codec vorbis)
A..... wavpack WavPack
A..... libwavpack (codec wavpack)
A..... wmav1 Windows Media Audio 1
A..... wmav2 Windows Media Audio 2
S..... ssa ASS (Advanced SubStation Alpha) subtitle (codec ass)
S..... ass ASS (Advanced SubStation Alpha) subtitle
S..... dvbsub DVB subtitles (codec dvb_subtitle)
S..... dvdsub DVD subtitles (codec dvd_subtitle)
S..... mov_text 3GPP Timed Text subtitle
S..... srt SubRip subtitle (codec subrip)
S..... subrip SubRip subtitle
S..... text Raw text subtitle
S..... webvtt WebVTT subtitle
S..... xsub DivX subtitles (XSUB)
I used ffmpeg_video_codec mp4:h264_vaapi
as per your suggestion as that was in my list above. Set camera to record and CPU is still 100% when recording!
Ok, I tried something different and installed motioneye onto its own box. This was a spare Dell R610 I had lying around. The system has 72GB of memory and 12 cores to which I assigned all of it to this system!
I set my camera at the lowest resolution and set the camera to record.
Turns out whilst I can use GPU acceleration, the GPU in these machines is very basic so wouldst be much use so I'm back to using CPU.
CPU still spiked out at 100%....I cannot understand that with all that power the system still cant keep up recording a single camera at such a small resolution. I am currently recording all of my cameras at full resolution into a windows OS based NVR at the moment all with motion detection and text and zone overlays with only 4 CPUs assigned and 8gb of memory and it doesn't bat an eyelid....so why is motion so bad at doing utilising system resources when I've given it the entire 12 cores of the CPU and 72GB of memory.
I wanted to move over to motioneye as its a smaller footprint being able to run it on a core Ubuntu OS inside docker rather than spinning up an entire windows environment. I also like the web browser of Motioneye for viewing my cameras too, something my current NVR won't do unless I pay for it as its not included in the free version.
I have also tried passthu as recommended above just to see if it made a difference.....it didn't....
CPU still 100%.
I did find this on motions support page
This does not seem to be solvable in Motion code. RTSP thread must run at the speed the camera is issuing pictures and can not be slowed to a lower frame rate without smearing of images which triggers false positives.
My cameras output at 1080p and cant be changed. So even though I set Motioneye to use a lower resolution it seems the recording still processes the full 1080p stream which seems to be what is killing the CPU. I still don't understand though why with 12 cores thrown at it that it still struggles to process 1 video at 1080p.
Any one know why when I tried passthu my CPU was still 100%? If its not encoding/decoding the video then why does my CPU spike still when using this mode?
I see you have these hardware accelerated encoders, but don't know why your CPU is still running at 100%
V..... h264_nvenc NVIDIA NVENC H.264 encoder (codec h264) V..... h264_omx OpenMAX IL H.264 video encoder (codec h264) V..... h264_vaapi H.264/AVC (VAAPI) (codec h264)
You could try using ffmpeg to transcode a video using one of these encoders, see what your CPU load is like. If your CPU load is still 100%, then there's nothing motionEye or motion can do about it.
About the passthrough recording, you could try doing motion detection on the low res video, and record the high res video. Most IP cameras support 2 video streams (low and high res). You might also want to ask motion developers about your passthrough recording using 100% CPU.
See https://github.com/ccrisan/motioneye/blob/master/motioneye/mediafiles.py#L46
There is a hard selection of codecs, which can not be replaced easily using the accelerated encoders.
@kleini Yes, the codec selection cannot be changed to an arbitrary codec from motionEye front end, but can be changed by editing the thread-1.conf file directly.
+1 also experiencing mad cpu load on ubuntu desktop (mint) install. I am using a single usb webcam at 640x480 (microsoft lifecam 5000) with motion detection off and still hitting 90% cpu with 8gb mem. Not running inside of a docker container either.
I'd just like to mention that if you're using the docker container and want to do GPU stuff, you need to pass the GPU into the container, eg;
docker run ... --device /dev/dri:/dev/dri --privileged ...
https://docs.docker.com/engine/reference/commandline/run/#add-host-device-to-container---device
I don't think it's related (only) to encoding. On my RPi 3 B+ the CPU is 100% busy only when the framerate is over 4, which coincidentally is the number of processors.
Could it be a spinlock issue between threads??
Did you ever found a solution to this issue?
I have to leave a comment on this.
I'm currently setting up a motioneye environment on an home server running 8 GB of memory and an i5-7400. Running 1x 1080p, 2x 1440p, 2x 360p. No recording, no motion detection. The CPU burns to death and the rtsp streams are barely smooth at just 10fps!
Streams are coming over a dedicated wifi bridge (cameras in it's own vLAN, behind a powerfull Cisco PoE switch too...), so I thought it's related to that somehow, but running all streams via VLC works just fine.
Shinobi and others can run just fine while recording, and it's a shame motion(eye). can't even without.
@Joshua2504 Maybe its time to drop the motioneye project and use something else, if it is better. Why do you stick to motioneye and blame this community project?
@kleini motioneye builds on motion which is the issue at this point. motion is a CPU-roasting monster as soon as it starts to touch your raw streams in any way. motioneye was made for a raspberry pi and motion alone can't even really run on "good" state-of-the-art hardware.
I'm pretty happy with Shinobi now (setup given above, 30% CPU usage while permanent recording on all cameras and 2x motion detection on 1440p, pretty small files!), although it has kinda active development. I can only excuse for blaming the motioneye community on this, as this is not in your hands at all. you'ld need to build your own ffmpeg stuff and ditch motion to get the CPU load under control. If I would use my Ryzen 2600x (or a dedicated GPU with HW encoding) to decode and encode one 1440p 30fps rtsp H256 with motion(eye), it would probably run just fine.
motion can use HW-acceleration, which would avoid CPU-roasting. But HW may be very different and HW video support in Linux is hard: VDPAU, VA-API and vendor specific APIs, HW encoding is even harder. I was never able to get good hardware acceleration working under Linux. motioneye is a Python project, it is not made for Raspberry Pi. It works very well everywhere, but motion is the not so easy thing.
Hi
I have 4 1080p PoE IP cameras running into MotionEye using rtsp
To start with I had the resolution at 1920x1080 and for motion detection and image grabs on motion detection this was fine.
My problem starts when I want to record video! At this resolution, even with only 1 camera enabled (the rest are off) my CPU is 100% all the time. I have tried to drop the resolution of the camera down to 1280x768 but CPU is still 100% when recording and FPS drops from 8/10fps to 0.5/1fps 2fps if I'm lucky.
The cameras are running into a top of the line Cisco POE gigabit switch and are on their own dedicated CCTV VLAN along with MotionEye.
I am running motioneye inside a docker container. The docker installation sits inside a Hyper-V VM which is running Ubuntu 18.04. The Underlying Ubuntu Installation that runs docker has 8vCPU assigned to it and 8GB of RAM. Nothing else is running on this ubuntu VM apart from Docker and motioneye is the only container that Docker is running.
I even have a crappy mjpeg camera covering my garage running into motion eye at the worst resolution possible and recording still is at 100% CPU.
Any help would be appreciated please?
Thanks Ross