Record High-res H264 streams 24/7 with low CPU Load

If you've made a patch to quick fix a bug or to add a new feature not yet in the main tree then post it here so others can try it out.
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by trumee »

@iconnor That is great news. Is 1.35 stable going to be released any time soon?
ernball
Posts: 1
Joined: Tue Dec 29, 2020 10:54 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by ernball »

iconnor wrote: Thu Dec 10, 2020 9:35 pm Just a heads up, in 1.35.16 (just pushed to master) we now have a DecodingEnabled setting on each monitor that turns off the decoding. So this script may or may not be necessary anymore.
@iconnor
In record mode with analysis and decoding disabled, I get buffer errors "Buffer too small" etc. I can't increase the buffers to the requested size because they're too large (9GB for 4K cams@ 20fps). If fast, resource friendly recording is the goal of these two new options, disabling buffering altogether and writing the stream straight to disk is preferable, no? If not, the script is still the better option, here.

*** If you've upgraded to 1.35:
The script will fail to create proper filenames due to database column renaming. Replace instances of "StartTime" with "StartDateTime" and "EndTime" with "EndDateTime".
User avatar
iconnor
Posts: 2862
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by iconnor »

reduced ram requirements is coming soon.
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

Been playing with this script for a few days, and made some additions. It's a bit rough, but thought I'd post a diff regardless.

Changes:

- record audio on /off toggle
- 'linked monitor' id
- update Events row with 1 alarm frame, if an alarm happens on 'linked monitor'
- insert of 1 frame on start, so you can watch the event via the GUI
- bulk/etc frames inserted upon stream completion
- mysql auth/password in script
- upon start, name='New Event', which then changes to the desired event prefix upon completion

Why the alarm frames, and New Event change? The alarm frames help me with filters + deleting, as I want to keep alarm events longer. New Events text is something else I can filter against, to ensure I do not delete streaming events.

The 1 frame on start allows me to go into Events and start streaming a new event. For whatever reason, I needed this for it to work.

Not sure if further changes are forthcoming, although there is still some tidy up work to do.
Attachments
f4d305996756336ff85d6f5ea1fb4c76.zmrecord.sh.diff.gz
(2.92 KiB) Downloaded 213 times
Cramac1
Posts: 111
Joined: Wed Aug 29, 2018 11:29 am

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by Cramac1 »

Hello. Something does not want to be added to my service. Or I misunderstood. How to enable for all cameras?

Code: Select all

# systemctl start zmrecord @ <MonitorID ..>. service
bash: MonitorID ..: No such file or directory
Or do you need each one separately?
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

A second diff. A minor fix.

Frames update/info wasn't done, if a linked camera wasn't provided. Now it is.
Attachments
f4d305996756336ff85d6f5ea1fb4c76.zmrecord.sh.rev2.diff.gz
(341 Bytes) Downloaded 225 times
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

Cramac1 wrote: Sat Mar 27, 2021 6:48 am Hello. Something does not want to be added to my service. Or I misunderstood. How to enable for all cameras?

Code: Select all

# systemctl start zmrecord @ <MonitorID ..>. service
bash: MonitorID ..: No such file or directory
Or do you need each one separately?
The readme.txt shows how to do this. There are examples right at the end of the file.
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

bbarnett wrote: Tue Mar 30, 2021 9:35 pm A second diff. A minor fix.

Frames update/info wasn't done, if a linked camera wasn't provided. Now it is.
Another small fix. Sometimes, I'd end up with a 0 prefacing the frame count remainder. This would get interpreted as octal.
Attachments
f4d305996756336ff85d6f5ea1fb4c76.zmrecord.sh.rev3.diff.gz
(229 Bytes) Downloaded 216 times
Cramac1
Posts: 111
Joined: Wed Aug 29, 2018 11:29 am

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by Cramac1 »

but did not think how to show an online picture?
tried ffmpeg

Code: Select all

ffmpeg -i "'.$cam.'" -b:v 2048k -crf 50  -f mpjpeg pipe:
but it loads the cpu
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

You're not really reading, or at least understanding the documentation here. You might also be thinking this is for something other than it is for.

This might not be right for you.
Cramac1
Posts: 111
Joined: Wed Aug 29, 2018 11:29 am

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by Cramac1 »

bbarnett wrote: Wed Apr 07, 2021 9:26 am You're not really reading, or at least understanding the documentation here. You might also be thinking this is for something other than it is for.

This might not be right for you.
this is not a question for this script. If you run it, instead of zmс, access to online viewing of the picture from the camera is lost.
Or is it just me?

works view through https://video.site/zm/cgi-bin/nph-zms ?
xefil
Posts: 53
Joined: Wed Jul 19, 2017 1:30 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by xefil »

Hello!
I'm trying to use this script on a zoneminder 1.35.21 setup. I've applied the patched from @bbarnett as well the correction mentioned by @ernball.
BTW I'm getting:

Code: Select all

TS: FPS: BW: FRAME:
ERROR 1366 (22007) at line 1: Incorrect decimal value: '' for column `zm`.`Monitor_Status`.`CaptureFPS` at row 1
Ideas?

Thanks!

Simon
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

Sorry, I'm back on 1.23.
xefil
Posts: 53
Joined: Wed Jul 19, 2017 1:30 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by xefil »

Uh, far away from me. BTW Meanwhile I've noticed that my test cam has not audio, but looking to the vlc stream it seems to have it, so I've added it and now it works, at least in recording. BTW the events are correctly shown in the event view, but they are not shown in the console view.
The console view is not reporting even numbers and not the size as well. I'll look in the script if there are some failed queries.
So the linked monitor is not used correctly as well.
Meanwhile thanks for any suggestion.

Simon
bbarnett
Posts: 21
Joined: Thu Dec 22, 2005 11:40 pm

Re: Record High-res H264 streams 24/7 with low CPU Load

Post by bbarnett »

xefil wrote: Sat Apr 10, 2021 11:16 am Uh, far away from me. BTW Meanwhile I've noticed that my test cam has not audio, but looking to the vlc stream it seems to have it, so I've added it and now it works, at least in recording. BTW the events are correctly shown in the event view, but they are not shown in the console view.
The console view is not reporting even numbers and not the size as well. I'll look in the script if there are some failed queries.
So the linked monitor is not used correctly as well.
Meanwhile thanks for any suggestion.

Simon
Just to be clear.. there are three patches to apply, on top of the initial post.

There was another post about changes with mysql/a new version of ZM, so not sure on that. Also, you are running on the command line? It will help, and show potentially more info. Lastly, there is a debug switch, which I might have used or not (sorry)... and there may be some commented out echos for debugging...
Post Reply