New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPi 3 + motionEye = slow preview/recording fps #227

Closed
perrychan opened this Issue Mar 22, 2016 · 73 comments

Comments

Projects
None yet
@perrychan
Copy link

perrychan commented Mar 22, 2016

First of all, great job with motionEyeOS. Was excited to see this software available and bought a couple of RPi 3s.

Unfortunately, recording stutters (1-2fps) once motion is detected. This applies whether its on large or small resolution. While watching the stream, I get 10fps, but drops down to 2-3fps as soon as it detects motion.

A lot of you don't seem to be having this problem. I am using an RPi camera when I first purchased my Raspberry Pi Model B. Think it might have anything to do with that?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Mar 22, 2016

What fps setting have you configured? If you're using a relatively high fps, the video encoding process might be too much for the CPU.

@perrychan

This comment has been minimized.

Copy link

perrychan commented Mar 22, 2016

It was set to ~20fps. I have adjusted to 10fps and res to 640x480. Am getting an average framerate of 2.5 now, which is an improvement from ~1.5. It's an improvement, but it's not usable at the moment. Any ideas?

I tried to use Fast Network Camera, but the stream never appears (constant spinner).

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Mar 23, 2016

Please attach all of your log files. I'll take a look over them and see if I can spot anything fishy.

@perrychan

This comment has been minimized.

Copy link

perrychan commented Mar 24, 2016

Attached are my logs.

motionEyeOS-logs.zip

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Mar 24, 2016

I just got a RPI 3 today as well and when it starts recording, my FPS also plummets
even at 640 x 480 as well.

I've attached my logs.
logs.zip

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Mar 24, 2016

It appears to be any sort of recording, even with still images it starts to lag horribly and the FPS drops to 1 or 2 as @perrychan experienced.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Mar 25, 2016

I watched the CPU usage during recording/image taking and it remains at a normal level of 30 - 40% and the I/O remains at 0% so it doesn't seem like the CPU isn't powerful enough at least?

@anglaborg

This comment has been minimized.

Copy link

anglaborg commented Mar 27, 2016

Have the same problem as @perrychan!
Running RPi2

#235

Could not upload my log files on github for some reason...
My logs

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Mar 28, 2016

I'll take a look over this. I haven't yet managed to investigate the problem.

@CrazyEyesPete

This comment has been minimized.

Copy link

CrazyEyesPete commented Apr 1, 2016

Having same issue with RPI3 as well. I'm new to MotionEyeOS so maybe I'm something wrong. When a person walks into the view, it is initially smooth video, but then looses several frames.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Apr 1, 2016

@CrazyEyesPete Exactly the same thing I get, it's perfectly smooth for a few seconds when something moves and then drops frames as well. It still does this even with motion disabled and continuous recording enabled, it drops the frames permanently in this mode of course.

@zettam

This comment has been minimized.

Copy link

zettam commented Apr 3, 2016

Anyone able to find a temp solution to this, till this is fixed permanently?
I like motioneyeos but this makes it unusable :(

@perrychan

This comment has been minimized.

Copy link

perrychan commented Apr 6, 2016

I'm hoping @ccrisan will be able to look over the logs soon.

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Apr 6, 2016

I will be taking care of this issue in the following weeks. I'm currently terribly busy with some personal matters but I haven't abandoned this project :)

@ShacharWeis

This comment has been minimized.

Copy link

ShacharWeis commented Apr 9, 2016

Same problem here, only much worse. RPI V2. FPS drops to 0.1 once motion is detected. System is unusable.

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Apr 9, 2016

@perrychan , @ShacharWeis , @CrazyEyesPete , @zettam can I have your config files please? I cannot seem to reproduce the problem at all.

@zettam

This comment has been minimized.

Copy link

zettam commented Apr 9, 2016

I deleted everything, was waiting for the fix. Sorry.
I do not remember changing the defaults though. It worked, with the mentioned problem.

@ShacharWeis

This comment has been minimized.

Copy link

ShacharWeis commented Apr 9, 2016

I've deleted the system and am now installing Zoneminder. After 12 hours my dropbox folder was full of false triggers and blank images that say "unable to open video device". Motioneyeos has a lot of potential, but I don't have time to debug it.

@tsrgit

This comment has been minimized.

Copy link

tsrgit commented Apr 9, 2016

@ccrisan , I am having the same issue with my RPi 3. It can easily maintain frame rates over 10 fps, even while detecting motion, as long as it is only streaming. As soon as I enable the saving of movies onto a Samba share on a network drive, the frame rate drops to around 1 fps when motion is detected.

Attached are my logs and what I think are the relevant config files.

motioneyefiles.zip

Let me know if you need anything else.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Apr 9, 2016

I'm happy to provide my config as well if you let me know where to find it.

@zettam

This comment has been minimized.

Copy link

zettam commented Apr 10, 2016

@ShacharWeis I would not bother with zoneminder. I've tried it. It does the same thing, motion does (of course depends on what you're looking for) with a much complicated and needy setup process. It's old.

@ShacharWeis

This comment has been minimized.

Copy link

ShacharWeis commented Apr 10, 2016

@zettam yeah, I found that out. Can't even get Zoneminder to run at all. I've given up and am now using an old android phone. Very sad. Do you have a good guide for setting up Motion?

@zettam

This comment has been minimized.

Copy link

zettam commented Apr 10, 2016

@ShacharWeis motion is very easy to set up actually, did you check the online docs?
I got zoneminder running, it's not worth the effort really. Motion is much better, with the same capabilities (and a newer/better interface) with much cleaner setup.

@perrychan

This comment has been minimized.

Copy link

perrychan commented Apr 14, 2016

@cuddylier you can find the log files under the Expert Settings menu.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Apr 14, 2016

@perrychan I already attached my log files earlier in this issue report, just found the config backup part under General.

@ccrisan my config files:
ConfigFiles.zip

@ghost

This comment has been minimized.

Copy link

ghost commented Apr 15, 2016

Same problem, currently on a RPi 2 (Model B).

@anglaborg

This comment has been minimized.

Copy link

anglaborg commented Apr 15, 2016

Is this bug only on MotionEyeOS or can switch to Motion untill the bug is fixed?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Apr 15, 2016

I haven't been able to establish what "the bug" is about. People complain about slow fps in general. I'll take a look over the log files but I doubt there's one single problem that covers everything users are complaining about here.

@anglaborg

This comment has been minimized.

Copy link

anglaborg commented Apr 17, 2016

@ccrisan I dont know if this has something to do with the bug but read this thread.

They talk about ARMv6 and ARMv7. I dont know, maybe this has something to do with it.

@sjabbie88

This comment has been minimized.

Copy link

sjabbie88 commented Dec 26, 2016

@ccrisan That's why I recommend using RPi1 devices just as fast network cameras. I myself have 8 of them (I just finished installing the 8th one today), all of them working in FNA mode. I use an Odroid XU4 running motionEye as a hub that performs all the motion detection, movie encoding, notifications and whatnot.

Casin, can you clarify how you have set-up motionEye on your Odroid XU4 to perform the motion detection and encoding of your 8 cameras while they are set-up as Fast Network Cameras on the Odroid XU4?

If I imitate your setup, I only have a fraction of the FNA camera options on the MotionEye Hub device, only general settings and no motion detection or encoding options....?

The way I read it, It is a very interesting set-up =)

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Dec 26, 2016

FNC is not available on Odroid XU4. You'll have to enable it on your RPi-based cameras, and then add them as regular network cameras to the Odroid XU4 running regular motionEye or motionEyeOS.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Dec 26, 2016

@ccrisan You haven't seen any FPS issues using motioneyeos on your Odroid in this setup during recording of video?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Dec 26, 2016

I run my 9 cameras at 1024x768@10fps. Provided not all of them record motion at once, things are pretty smooth.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Dec 26, 2016

Ah, still not great then :( Not worth investing in such a system for achieving that for me sadly.

@smanschi

This comment has been minimized.

Copy link

smanschi commented Dec 30, 2016

Since v3.1, ffmpeg offers built-in support for using the decoding/encoding capabilities of the Raspberry Pi (see for example here http://www.cnx-software.com/2016/06/29/ffmpeg-3-1-adds-support-for-openmax-encoding-on-raspberry-pi-va-api-h-264-h-265-encoding-and-more/). I am not familiar with motion or ffmpeg.. would it be possible to make use of that? E.g., ship motioneyeos with a newer version of ffmpeg and activate the hardware encoding via an option?

Here is a link with the options (At least I think they are the proper ones): http://stackoverflow.com/questions/40175644/ffmpeg-hardware-acceleration-on-raspberry-pi

@KyleKatarn31

This comment has been minimized.

Copy link

KyleKatarn31 commented Dec 30, 2016

Hello,

I'm running 3 IP Cam on RPi 1B.
Of course it's lagging a lot but i'd like to know what is the 0.3/0.0 fps that is displayed on the motioneyeOS web monitoring page ?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Dec 30, 2016

Just hover it with the mouse and you'll see a tooltip with details. It's basically streaming/capture fps.

@BigPapoo

This comment has been minimized.

Copy link

BigPapoo commented Jan 8, 2017

Disable "Motion optimization" in "Video streaming" tab.

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Feb 25, 2017

How are you guys monitoring CPU useage?

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Feb 25, 2017

Using 'top' in ssh.

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Feb 25, 2017

cuddylier wow thanks... so it is not when expert settings - Enable System Monitoring. there is some values displayed. first is temperature, last is some kind of a network speed, i don't know which and where though. but second is complete mistery, i was thinking it is cpu load, but wondering what units it is.

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Feb 25, 2017

@shinji2009 it's the sysload and it's read from /proc/loadavg: https://github.com/ccrisan/motioneyeos/blob/master/board/raspberrypi/motioneye-modules/boardctl.py#L34

It's non-dimensional and possible values range from 0 to infinity. For a normal functioning, you should expect values from 0 to the number of cores.

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Feb 25, 2017

@ccrisan wow thanks...
strange thing that i'm using rpi3 and never seen values more than 1.4. i did something wrong with installation or motioneyeos can't use 4 cores?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Feb 25, 2017

Unless you have more than one camera attached to your PI, it's very unlikely to see loads above e.g. 1.5. 1.5 can be seen as 100% of one core (the thread handling your camera) + 50% of another one (the rest of the processes that are usually less CPU intensive).

Adding a second camera will instruct motion to spawn a second thread to handle the new camera. As far as I know it can't leverage more than one CPU (read: more than one thread) per camera.

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Feb 25, 2017

@ccrisan thank you. and what about third value? what speed is it?

@ccrisan

This comment has been minimized.

Copy link
Owner

ccrisan commented Feb 25, 2017

The total (send + receive) network IO, in kilobytes per second.

@cuddylier

This comment has been minimized.

Copy link

cuddylier commented Feb 25, 2017

@shinji2009 I'm sorry for confusing you, I knew about the monitoring overlay load value but I always check with top directly in ssh to see exactly what's going on (what each process is using) and the actual % although the load figure represents this somewhat.

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Feb 25, 2017

@cuddylier it's ok i need to know this too) it's my first *nix expirience

@ccrisan thank you. it is almost №5 of roadmap

@bortek

This comment has been minimized.

Copy link
Collaborator

bortek commented Mar 1, 2017

Guys if you are satisfied with the resolution please close the Issue. Thanks!

@bortek bortek added the question label Mar 7, 2017

@bortek bortek closed this Mar 7, 2017

@DeastinY

This comment has been minimized.

Copy link

DeastinY commented May 26, 2017

Hey, maybe this could/should be added to the device overway ?
I was expecting it to work with smooth 30FPS / FHD as well - maybe something to 'warn' people about ?
Furthermore - is there hardware that is capable of doing what we expect short of a dedicated server ?

@Sja91

This comment has been minimized.

Copy link

Sja91 commented Jan 6, 2018

Agreed with @DeastinY, This would've been nice to know before spending several hours on it. It's a shame too, seems like a good project. But thanks for it anyways!

@jasaw

This comment has been minimized.

Copy link
Collaborator

jasaw commented Jan 6, 2018

@Sja91 Hardware accelerated video encoding is now supported on version 20171008 version and above, just make sure you choose OMX version of the movie format, like H264/OMX.
The original Raspberry Pi 1 should be able to handle 30 fps at 800 x 600 resolution. Raspberry Pi 2 & 3 will be able to handle higher resolution.

@Sja91

This comment has been minimized.

Copy link

Sja91 commented Jan 6, 2018

@jasaw Well this sounds promising! I tried googling around for this but I can't find anything on it. Would you mind explaining more? I'm not recording if that matters, just looking to stream video. But getting 2 fps

@smanschi

This comment has been minimized.

Copy link

smanschi commented Jan 6, 2018

I think the general problem is not that the raspberry is too slow, but the way videos are handled is extremly inefficient. Typical motion detection software works like this:

  1. Demultiplex incoming camera stream (e.g., mp4 to h264)
  2. Decode video stream (h264 to raw images)
  3. Analyze raw images (Detect motion)
  4. If motion is detected, encode raw images to video stream (raw images -> h264)
  5. Multiplex video stream (h264 -> mp4)

The computationally expensive part is the encoding of the video, which in my opinion is completely unnecessary. Last year, I started prototyping my own motion detection software. Instead of encoding the video, I stored the incoming h264 frames in a ring buffer (2. from above). As soon as a motion was detected in step 3, I multiplexed the frames from the ring buffer to an mp4 video. By doing this, the encoding (4.) could be skipped completely.

There are two main disadvantages with my approach. First, no information can be added to the video, as only the incoming stream is stored (e.g., no frame can be drawn around a detected moving object). Second, my approach was only able to handle h264 streams (which was not a problem for me as my camera was a h264 stream). The major advantage is that this approach is super fast. I don't remember the exact numbers, but by bypassing the encoding of the video the raspberry pi 3 could easily handle at least two Full HD cameras @ 25 fps. So it is definitely possible to use the raspberry pi for motion detection at high resolutions (without having only 2 or 3 fps).

Unfortunately, I did not have a lot of time to continue with the project as I finished my PhD last year. Maybe I will pick it up again and put some prototype on github. Would be great if something like this could be integrated into motioneyeos.

@KyleKatarn31

This comment has been minimized.

Copy link

KyleKatarn31 commented Jan 6, 2018

Appart from selecting H264/OMX as active codec, is there anything to do to enable HW acceleration ?

@shinji2009

This comment has been minimized.

Copy link

shinji2009 commented Jan 7, 2018

smanschi very interesting. hope you will succeed. about first disadvantage: any info can be added to video using subtitles. like SRT. it is basically a plain text format, low storage and cpu usage, easy to generate.

wow gpu. maybe its time to move back to motioeyos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment