Page 1 of 1

Cant maintain FPS

Posted: Fri Sep 23, 2016 1:47 pm
by punisherb273
I have four amcrest 1080p 30fps cameras set up on ZM 1.30 and i cant seem to get the playback to be smooth 30fps. For the first few seconds of the playback it is definitely close to 30fps, and then after looking at the stills it drops to about 5fps. I have been lurking around for a week or two and cant seem to find an answer to this problem.

My setup is a xeon E5-2670 with 16gb ram running Ubuntu 16.04, so cpu power shouldnt be an issue. Cameras are running in FFmpeg and RTP/RTSP.

Re: Cant maintain FPS

Posted: Tue Sep 27, 2016 2:38 pm
by punisherb273
Anyone else have a fix for dropping frame rates? I'm running an identical ubuntu setup in virtualbox on a my gaming computer and playback is smooth as butter. they are using the same connection and everything. The only thing i can think of is that my virtualbox is running on an SSD and my zoneminder server is running on a WD purple 2tb and that the mechanical drive isnt fast enough?? I dont see any logs or something indicating that there are issues

Re: Cant maintain FPS

Posted: Tue Sep 27, 2016 3:12 pm
by bbunge
You can try to set PATH_SWAP to use your tmpfs (/dev/shm) which will be faster than writing to the hard drive. I have set up my 16.04 to create a directory /dev/shm/zm with www-data:www-data permissions that I use for PATH_SWAP and PATH_MAP.

Otherwise slow your camera down. There is no way anyone needs 30 FPS for a security system. I have a very old Axis camera that runs along at the blinding rate of 1 FPS and catches all the motion in front of it! The rest of the cameras (16) in my production system are set to 5 FPS. All running on an i5 QUAD 16 GIG RAM with a WD Blue 1 TB.

Re: Cant maintain FPS

Posted: Tue Sep 27, 2016 3:44 pm
by punisherb273
so i figured out it is the hard drive that is too slow, i had an old 60 gig ssd laying around that I set up and video is much smoother now. I am going to try all of the cameras at 10fps while im gone today and see if that helps. I was reading that most people dont use that high of FPS for security, i just figured with 30fps cameras and a xeon setup it could just run whatever! if that doesn't work I will get more detailed instructions on how to set up that path. Zoneminder has been my first linux experience so im not sure how to create a directory or set permissions. So tmpfs is bascially stored in ram? does it get moved to another location after the event is over?

Re: Cant maintain FPS

Posted: Tue Sep 27, 2016 4:02 pm
by punisherb273
even at 10fps i have the same issue. Starts recording smooth and then drops way down. I tried setting the PATH_SWAP to /dev/shm and no change. Im wondering is there a way to use a small SSD to run the OS and temporarily save images and then have an auto backup that moves the files to the HDD?

Re: Cant maintain FPS

Posted: Fri Sep 30, 2016 7:15 am
by nirv199
punisherb273 just a quick question to see if i am bumping into the same problem on a new setup, did you see the frames properly ordered "1, 2, 3 ..." when you clicked "frames" or would there be frame numbers skipped "1, 2, 4, 7 ...." *before you* fixed the issue?
thanks

Re: Cant maintain FPS

Posted: Fri Sep 30, 2016 12:14 pm
by knight-of-ni
ZoneMinder is a security application. It is not a media player, and consequently it was not designed to playback HD video at 30fps (30fps HD video did not exist for the typical home user in 2003 when the core code was written). That might change once the ability to record to a video container file, rather than jpgs, becomes production ready. In the meantime, you are facing an uphill battle trying to achieve high frame rates, which is almost certainly not worth yours or anyone else's troubleshooting time.

Set each camera to 5 fps (set it in the camera, not in zoneminder). That is plenty for a surveillance system, and you will not miss any events at this frame rate.

If you playback frame rate cannot achieve 5 fps then here are a few questions:

Are you playing back video from a web browser running directly on the server, or are you playing back video from a different machine? If different machine, then describe the network connection between the two.

What browser are you using?

Does the same issue occur viewing live video as well as recorded video?

Re: Cant maintain FPS

Posted: Fri Sep 30, 2016 2:41 pm
by punisherb273
I tried playing back video from my desktop and from my server, both had the same issue. It's not that the video just doesnt play smoothly on the webUI, there are literally only 5 frames per second recorded so even if the stills are exported those frames arent there. When i compared the images my virtual machine captured compared to my dedicated server, I had better stills and was able to capture stills capable of identification. To me it is worth it to have higher than 10fps for faster moving events.

I tried ubuntu server 16.04, desktop 16.04, and fedora 24 all had the same problem.

What fixed my issue was running ubuntu and zoneminder on an old 60 gig SSD and then I followed the directions in the wiki on a dedicated hard drive to set my WD purple as the save location for events and images. I found that 20FPS is a negligable difference from 30fps and that 30fps was not worth the load on my server. Smooth playback and no missing frames.

Re: Cant maintain FPS

Posted: Fri Sep 30, 2016 2:43 pm
by punisherb273
nirv199 wrote:punisherb273 just a quick question to see if i am bumping into the same problem on a new setup, did you see the frames properly ordered "1, 2, 3 ..." when you clicked "frames" or would there be frame numbers skipped "1, 2, 4, 7 ...." *before you* fixed the issue?
thanks
I lost all of that information when i reformatted my hard drive, so i cant remember if my frames were in order or not. I want to say that they were but i couldn't be sure.

Re: Cant maintain FPS

Posted: Sat Oct 01, 2016 3:48 pm
by nirv199
punisherb273 wrote:
nirv199 wrote:punisherb273 just a quick question to see if i am bumping into the same problem on a new setup, did you see the frames properly ordered "1, 2, 3 ..." when you clicked "frames" or would there be frame numbers skipped "1, 2, 4, 7 ...." *before you* fixed the issue?
thanks
I lost all of that information when i reformatted my hard drive, so i cant remember if my frames were in order or not. I want to say that they were but i couldn't be sure.
Did you find any particular log (either from linux, zoneminder, mysql) showing some sort of error before changing the to the SSD drive?

Also, did you change your sysctl.conf or mysql.cnf with any optimization?

I just want to understand how to find out if disk is the root cause before getting an SSD drive. I am getting ~4 FPS being stored (12 FPS set on the camera, and I do get 12 FPS on monitor mode), and 4 FPS is not enough to replay faster paced events. I am not trying to get 30 FPS, but 4 FPS is too low.

Re: Cant maintain FPS

Posted: Tue Nov 29, 2016 2:22 pm
by SpikeyGG
Yeah, it seems like there's an issue with zoneminder after an alarm triggers. My camera is fine at 10fps in idle mode, but as soon as an alarm triggers the frame rate drops to 2-3 FPS. Here's an example that just triggered this morning: https://dl.dropboxusercontent.com/u/148 ... -r1-s1.mp4

I recently figured out how to add milliseconds to the time stamp value in the top-left of the recording. If you watch the top left of the capture you can see almost perfectly even 10ms divisions for about the first half of the video (0.12, 0.22, 0.32, 0.42, 0.52, etc...). After the cat reaches half way across the screen, the divisions clearly drop to between 2-3 FPS (0.33, 0.63, 0.93, 1.33, 1.53, 1.74, etc).

I don't believe my capture machine is the issue as I have 6 core (12 HT) Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz, 128GB of DDR3 ram with a 60GB tmp/shm ramdrive. During alarm/capture, the cpu utilization is around 10% on one core, the machine is essentially idle. I have an SSD that my OS runs from and a bunch of 2TB hard drives. Anyway, trying to figure out how to stabilize the frame rate since it should be possible.

When I look at the "Frames" link from one of my captures I see completely sequential frame numbering on the far left column so it doesn't appear that ZM is dropping frames intentionally. I think there's something more sinister going on here. Can someone post a capture from their setup that has a solid frame rate at 10fps or faster?

Maybe the ZM infrastructure just can't do it as knnniggett was eluding to. Also, I get that 5fps is adequate for security, but I want more than what's adequate... :)

Re: Cant maintain FPS

Posted: Wed Nov 30, 2016 9:47 pm
by jbg70
I had a similar issue. In alarm I lost lot of frames.
I have now 6 cameras in mocord mode, 5 of them are set 1280x720p@25fps and 1 is 1280x960@20fps.
CPU is Xeon E3-1246, and load does not go over 3.00 if all cameras go in alarm. So less power compared to your, and I do not loose any frame even in alarm mode.
I discovered that mysql was the most responsible of that.
Try to run iotop -o and check the i/o load.

What solved my problem are the following lines in my.cnf:

Code: Select all

innodb_read_io_threads=4
innodb_write_io_threads=8  #To stress the double write buffer
innodb_buffer_pool_size=20G
innodb_buffer_pool_load_at_startup=ON
innodb_log_file_size = 32M #Small log files, more page flush
innodb_log_files_in_group=2
innodb_file_per_table=1
innodb_log_buffer_size=8M
innodb_flush_method=O_DIRECT
innodb_flush_log_at_trx_commit=0
skip-innodb_doublewrite  #commented or not depending on test
I also mounted /var/lib/mysql, /var/cache/zoneneminder(images and events) in a xfs formatted drive. This also helped.

Hope it helps!

Re: Cant maintain FPS

Posted: Sat May 25, 2019 4:55 am
by SpikeyGG
jbg70 wrote:
Wed Nov 30, 2016 9:47 pm
Hope it helps!
I would like to say that this is quite possibly the best post in the forum. Every time my cameras would trigger and start recording the first set of frames before the alarm would be smooth then as soon as the alarm hit it would be chunk city. This set of mysql options, whatever it does, works wonders for the frame rates on all my cameras.

Thank you very much for sharing jbg70!
-Greg