motioneye-project / motioneyeos

A Video Surveillance OS For Single-board Computers
Other
7.87k stars 899 forks source link

Optimal setup to maximize FPS in movies. #2774

Closed fujinjr closed 3 years ago

fujinjr commented 3 years ago

Preliminary Docs

I confirm that I have read the CONTRIBUTING guide before opening this issue.

I confirm that I have read the FAQ before opening this issue.

motionEyeOS Version

I am running motionEyeOS version: 20190911.

Board Model

I am using the following board/model: Raspberry PI 3B+, Raspberry PI 0w.

Camera

I am using the following type of camera: Fast Network Camera.

My camera model is: Raspberry Camera PI V2 8 MP.

Network Connection

My motionEyeOS unit is connected to the network via: WiFi.

I'd like to know if my current setup is optimal in order to maximize FPS in movies. I attached two images, any opinion? Am I using the FNC and RTSP correctly?

pi0w

pi3

starbasessd commented 3 years ago

I would upgrade your motionEyeOS to 20200606 or dev20201026, rather than use any 2019 version. There were a number of updates and changes since then.

cap9qd commented 3 years ago

I would try setting movie pass through on your RPi3B+ instead of omx-h264. The RPi-0W is encoding the video in hardware to h264 so you shouldn't need to reencode the stream. Motion daemon on the RPi3B+ will still have to decode it to do the motion detection but doing pass through might lower your load. I am not sure this will help you much with fps.

I found if the video was low enough resolution (<1080p) I had better performance (in terms of CPU load on my motioneyeos server) by leaving my RPI-0W FNC setup as a mjpeg stream and using the hardware encoder on my odroid server to encode to h264. I found this recommendation on the motion project forum that motion deals well with jpegs for the motion detection algorithm and motion does not hardware accelerate the decode of h264 so the CPU load takes a hit. Of course I can't find the post now when I need it but worth a try.

This work was in terms of getting my CPU load down to support more cameras on my one server so may not be the advice you are looking for here.

On Thu, Jul 15, 2021, 15:07 fujinjr @.***> wrote:

Preliminary Docs

I confirm that I have read the CONTRIBUTING https://github.com/ccrisan/motioneyeos/blob/master/.github/CONTRIBUTING.md guide before opening this issue.

I confirm that I have read the FAQ https://github.com/ccrisan/motioneyeos/wiki/FAQ before opening this issue. motionEyeOS Version

I am running motionEyeOS version: 20190911. Board Model

I am using the following board/model: Raspberry PI 3B+, Raspberry PI 0w. Camera

I am using the following type of camera: Fast Network Camera.

My camera model is: Raspberry Camera PI V2 8 MP. Network Connection

My motionEyeOS unit is connected to the network via: WiFi.

I'd like to know if my current setup is optimal in order to maximize FPS in movies. I attached two images, any opinion? Am I using the FNC and RTSP correctly? [image: pi0w] https://user-images.githubusercontent.com/37943766/125850606-96208eae-ee1e-4203-9023-5ac045c7d884.PNG

[image: pi3] https://user-images.githubusercontent.com/37943766/125850623-647efd76-808c-47c5-937e-4e0587f93f85.PNG

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ccrisan/motioneyeos/issues/2774, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBKIUDDHMYGMXUMDK65XODTX45XFANCNFSM5AOHLNTA .

starbasessd commented 3 years ago

@cap9qd Be aware that you lose text overlays (time/date etc) using Pass Through recording, if it is not generated on the camera, which is why I didn't recommend that optimization...

fujinjr commented 3 years ago

I would upgrade your motionEyeOS to 20200606 or dev20201026, rather than use any 2019 version. There were a number of updates and changes since then.

I'm not able to physically access the two devices, so I don't want to risk a remote update. Anyway is the use of RTSP, in my Pi3 B+ 'Camera Device', correct?

starbasessd commented 3 years ago

Yes.

fujinjr commented 3 years ago

Yes.

I want to clarify some doubts that I have: if on the current setup I'll change the Camera Device, on the Pi 3B+, to -> http://192.168.1.112:8081 then I'll should observe a significant drop in FPS, am I right?

What are the disadvantages with my setup... loss in video quality?

cap9qd commented 3 years ago

Ah yes I am not concerned about text overlay. Sorry for the omission.

On Thu, Jul 15, 2021, 15:23 starbasessd @.***> wrote:

@cap9qd https://github.com/cap9qd Be aware that you lose text overlays (time/date etc) using Pass Through recording, if it is not generated on the camera, which is why I didn't recommend that optimization...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ccrisan/motioneyeos/issues/2774#issuecomment-880989126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBKIUB6QG5GFCDNGNOZNVDTX47VNANCNFSM5AOHLNTA .

starbasessd commented 3 years ago

Then your setup is almost maxed out. @cap9qd 's suggestion to shift to Pass Through is best. To give yourself the best optimization you really do need to update to current versions, just check out the improvements in the change logs here: https://github.com/ccrisan/motioneyeos/releases

starbasessd commented 3 years ago

Yes.

I want to clarify some doubts that I have: if on the current setup I'll change the Camera Device, on the Pi 3B+, to -> http://192.168.1.112:8081 then I'll should observe a significant drop in FPS, am I right?

Not necessarily, depends on what else is going on. The option slider for framerate limitations isn't absolute. If you have 1 camera, it will try to go that fast, but if the streaming camera is only sending 10 FPS, then that will be your upper limit. If you have other things on your network that eats bandwidth then you may not get the full FPS you've selected to send in FNC mode. On the other hand, if things are pretty idle, you may get the same framerate in both port 8081 vs port554/rtsp...

What are the disadvantages with my setup... loss in video quality?

fujinjr commented 3 years ago

I want to clarify some doubts that I have: if on the current setup I'll change the Camera Device, on the Pi 3B+, to -> http://192.168.1.112:8081 then I'll should observe a significant drop in FPS, am I right?

Not necessarily, depends on what else is going on. The option slider for framerate limitations isn't absolute. If you have 1 camera, it will try to go that fast, but if the streaming camera is only sending 10 FPS, then that will be your upper limit. If you have other things on your network that eats bandwidth then you may not get the full FPS you've selected to send in FNC mode. On the other hand, if things are pretty idle, you may get the same framerate in both port 8081 vs port554/rtsp...

With port 8081 the maximum FPS that I saw was 6 with many lags.

In the following weeks I'll stick with RTSP, I'll increase the 'Image Quality' to 40 on the FNC and see if I'll notice any improvement, quality wise; after all I'm good with 10 stable FPS.

starbasessd commented 3 years ago

Also, on the PiZero, you will need to watch your bit rate for the stream to get best frame rate, resolution, and quality... PiZero supports 802.11g, but seldom if ever gets anywhere near 54Mbps, which is also dependent on other traffic, the router used, and distance to the router...

fujinjr commented 3 years ago

Update: with Image Quality set to 40 I don't notice improvements in the image quality; I'll go back to 25. I could try to increase the resolution up to 720p though.

Also, on the PiZero, you will need to watch your bit rate...

Take a look:

WiFi

starbasessd commented 3 years ago

By bit rate I was referring to the PiZero, Settings, Video Device, Bit Rate, currently set to 1Mb/sec. To improve your frame rate & quality, try increasing to 2Mb/sec, and slowly increase until you don't notice any more improvement. Realize, though, at some point you will saturate your connection to WiFi. This is not brain surgery, just rocket science, where you try a setting and notice a result. Think: SpaceX and Elon Musk.... :)

fujinjr commented 3 years ago

try increasing to 2Mb/sec

I did, let's see what happens!

Another question: do you usually activate 'Denoise' option in your FNC cameras?

starbasessd commented 3 years ago

I activate Auto Noise Detection and Despeckle Filter anytime they are available as an option.

fujinjr commented 3 years ago

I was referring to the option inside the pi0:

pi0

starbasessd commented 3 years ago

Yes, enabled.

fujinjr commented 3 years ago

I don't notice any difference increasing the bitrate to 2.00 Mbps. Right now I set the bitrate to 1.25 Mbps and increased FPS to 12 and I get consistent results; one strange thing I noticed is that the Image quality slider (from 25 up to 100), on the Pi0, doesn't affect video quality to my perception.

Question: if I activate RTSP on the Pi0 but then add a camera on the Pi3 using http://192.168.1.112:8081, will it work?

starbasessd commented 3 years ago

The quickest way to answer your last question is to try it. The easy answer is Yes. BTW, the real test of the resolution, quality, frame rate and bitrate changes is not the 'preview' video showing the live feed, but the recorded video.

fujinjr commented 3 years ago

BTW, the real test of the resolution, quality, frame rate and bitrate changes is not the 'preview' video showing the live feed, but the recorded video.

I test the video quality, and FPS, with VLC.

starbasessd commented 3 years ago

BTW, the real test of the resolution, quality, frame rate and bitrate changes is not the 'preview' video showing the live feed, but the recorded video. VLC is still looking at the preview stream...

fujinjr commented 3 years ago

VLC is still looking at the preview stream...

I use VLC with downloaded movies and then I observe Codec information.

Today, in one of the recorded videos, I saw a forward jump in time (of 20 seconds); it looks like someone edited and cut a portion of the video. Is it a possible effect that happens with RTSP?

starbasessd commented 3 years ago

Yes, occasionally. If/when that happens, you can try adding the camera as UDP instead of TCP.

fujinjr commented 3 years ago

If/when that happens, you can try adding the camera as UDP instead of TCP.

How do I do that?

A suggestion for the future: is it possible to add, inside motioneyeos, the possibility to activate a different ISO during the night?

starbasessd commented 3 years ago

Remove the camera from motionEyeOS Select the PiZero Camera in the dropdown Click trashcan icon Click Add New Camera Add camera back, Untitled Select UDP this time.

As to the feature request, please start a new issue with it, so I can tag it as Feature Request.

starbasessd commented 3 years ago

As an aside, using older versions, I had to use URL: rtsp://192.168.2.120/h264 with the above settings to get UDP to work. There are many issues with the older versions of motionEyeOS and RTSP 9both sending and receiving) that have been fixed in the most recent versions (20200606 and dev20201026) compared to the 2019xxxx versions.