Adding Monitors via Web Interface vs API - WebGUI differs from API Defaults

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
jeremyb
Posts: 18
Joined: Mon May 29, 2023 10:28 pm

Adding Monitors via Web Interface vs API - WebGUI differs from API Defaults

Post by jeremyb »

Hello again,

I'm writing a script to configure ZM and ran across some things to note.

I only wanted to send the basic amount of information through the api to setup a monitor like on the web interface. I determined these are the values most important for now:

curl -XPOST http://localhost/zm/api/monitors.json -d "Monitor[Name]=Office\
&Monitor[Id]=1\
&Monitor[Type]=Ffmpeg\
&Monitor[Function]=Mocord\
&Monitor[RefBlendPerc]=6\
&Monitor[AlarmRefBlendPerc]=6\
&Monitor[Method]=rtpRtsp\
&Monitor[Path]=rtsp://10.0.0.21:7447/645410d8e4b0db099c349744_0\
&Monitor[Width]=1280\
&Monitor[Height]=720\
&Monitor[SaveJPEGs]=0\
&Monitor[VideoWriter]=2\
&Monitor[RecordAudio]=1"

I did a comparison to the defaults used in the webgui vs the api. In order to get the same defaults the webgui uses, I had to add the additional parameters:

&Monitor[Colours]=4\
&Monitor[ServerId]=0\
&Monitor[V4LCapturesPerFrame]=1\
&Monitor[Encoder]=auto\
&Monitor[EncoderParameters]=crf=23\
&Monitor[RTSPDescribe]=false\
&Monitor[LabelFormat]=%N - %d\/%m\/%y %H:%M:%S\
&Monitor[PreEventCount]=5\
&Monitor[PostEventCount]=5\
&Monitor[FPSReportInterval]=100\
&Monitor[ControlAddress]=user:port@ip\
&Monitor[DefaultScale]=0\
&Monitor[WebColour]=#7563cc\
&Monitor[Sequence]=1"

This is a list of the default API settings that differ from the webgui:

"Notes":null,
"ServerId":null,
"Device":"''",
"V4LCapturesPerFrame":null,
"Colours":"1",
"Encoder":null,
"EncoderParameters":null,
"RTSPDescribe":null,
"LabelFormat":null,
"PreEventCount":"10",
"PostEventCount":"10",
"FPSReportInterval":"250",
"ControlAddress":null,
"DefaultScale":"100",
"SignalCheckColour":"#0000BE",
"WebColour":"red",
"Sequence":null,

Looks like the api doesn't assign random "webcolour" either and I'll need to specify for each camera.

I'll be diving into each setting that's not obvious for myself later. Yes, I know some don't really matter, but wanted to make a note, as I may help in making this more efficient later. I also wanted feedback from anyone that sees an issue here and more familiar with the options.
jeremyb
Posts: 18
Joined: Mon May 29, 2023 10:28 pm

Re: Adding Monitors via Web Interface vs API - WebGUI differs from API Defaults

Post by jeremyb »

*** Skip this post for the next one ***

Just working through this. Will update as I find my answers.


With my personal perception of logic, uniformity and commonality, then applied to my understanding thus far:


"Notes":null, #Null will not effect / Null is correct

"ServerId":null, #Null will not effect?

"Device":"''", # " is being placed here and not Null

"V4LCapturesPerFrame":null, #Find out what value 1 does in place of null

"Colours":"1", #API default should be 4 and not 1

"Encoder":null, #Determine what auto does in place of null, then determine when and why enabled

"EncoderParameters":null, #crf=23 is default / comments should be removed as they are in the web help / active when encoder is enabled

"RTSPDescribe":null, #Determine what false does in place of null, then determine when and why

"LabelFormat":null, #Determine if Null still generates default timestamp

"PreEventCount":"10", #Determine most common setting between value 5 and 10 and when active

"PostEventCount":"10", #Determine most common setting between value 5 and 10 and when active

"FPSReportInterval":"250", #Determine most common setting between the value 100 and 250

"ControlAddress":null, #Believe this should be Null as default and web should expressed syntax in the help

"DefaultScale":"100", #Determine most common setting between the value 0 and 100

"SignalCheckColour":"#0000BE", #Character case difference / not important

"WebColour":"red", #Look into API auto creating unique colors to remove reliance on front-end GUI code

"Sequence":null, #Determine what sequence is used for and importance
Last edited by jeremyb on Fri Jun 02, 2023 1:05 am, edited 1 time in total.
jeremyb
Posts: 18
Joined: Mon May 29, 2023 10:28 pm

Re: Adding Monitors via Web Interface vs API - WebGUI differs from API Defaults

Post by jeremyb »

With my personal perception of uniformity and commonality, then applied to my understanding thus far:


"Notes":null, #Null will not effect / Null is correct / WebGUI should be placing Null

"ServerId":null, ##ServerId is a parameter used when setting up multiple ZoneMinder servers that share the same database and use a shared file share for all event data. #Null will not effect? Thinking this should always be null until more than one server is added.

"Device":"''", # " is being placed here and not Null

"V4LCapturesPerFrame":null, ##V4LCapturesPerFrame is a configuration parameter in ZoneMinder that can be found under options >> config. It is used when you have cameras attached to a video capture card which forces multiple inputs to share one capture chip. In this case, it can sometimes produce images with interlaced frames reversed resulting in poor image quality and a distinctive comb edge appearance. Changing the value of V4LCapturesPerFrame to a value such as 2 or 4 can help improve the image quality. # This should be null unless using local device

"Colours":"1", #API default should be 4 and not 1 to be common and uniform

"Encoder":null, ##Determine what auto does in place of null #I'm having issues finding information on available options for this key and it's format at the moment. There are two fields for encoder options in the WebGUI. I'm thinking this should be auto only when enabled. Developer style choice of course.

"EncoderParameters":null, #crf=23 is default / comments should be removed as they are in the web help / active when encoder is enabled / Should be placed in "encoder" dropdown menu on webgui when encoder is selected?

"RTSPDescribe":null, ##Having issues finding information on this field. Will look back later #Determine what false does in place of null, then determine when and why

"LabelFormat":null, #Should be Null and the example "%N - %d\/%m\/%y %H:%M:%S" shown under a help in the WebGUI. This could also be shown as a drop down with null as default, then custom with additional input field, then common format presets.

"PreEventCount":"10", ##PreEventCount is a configuration parameter in ZoneMinder that determines the number of images that are stored before an event is triggered. This allows you to see what happened leading up to the event. The number of pre-event images should not exceed half of the Image Buffer Size. #Default Image buffer size is 3. Needs to be 1.5 at most based on this. #Determining most common setting between the default value 5 and 10 is at a loss. Image buffer size must be increased to comply with PreEventCount defaults.

"PostEventCount":"10", ##PostEventCount is a configuration parameter in ZoneMinder that determines the number of images that are stored after an event has ended. This allows you to see what happened after the event. You can change the value of PostEventCount to increase or decrease the number of images stored after an event. #PostEventCount and Image Buffer Size are two separate configuration parameters in ZoneMinder. PostEventCount determines the number of images that are stored after an event has ended, while Image Buffer Size determines the maximum number of images that can be stored in the buffer. The number of pre-event images, determined by the PreEventCount parameter, should not exceed half of the Image Buffer Size, but there is no such restriction for PostEventCount #With determining most common setting between value 5 and 10, I'd choose the lesser value of 5 for this and PreEventCount while also changing the ImageBufferSize default to 10. Suggestions? I guess having ImageBuffer to 2 and Pre and PostEvents to 1 as the default could work as well with being minimalistic at first.

"FPSReportInterval":"250", ##FPSReportInterval is a configuration parameter in ZoneMinder that determines how often the current performance in terms of Frames Per Second (FPS) is output to the system log. This setting controls how often the Capturing at and Analyzing at messages appear in the system log. It is not used in any functional way, so you can set it to a high value such as 1000 if you don’t want to see these messages too often. #Determine most common setting between the value 100 and 250? IDK.. haha. 1000 or null seems like a better default. I might just always change this. Might also look into having performace information kept and displayed seperate from error and warning logs.

"ControlAddress":null, #Believe this should be Null as default, and web should expressed syntax in the help

"DefaultScale":"100", ##DefaultScale is an option in ZoneMinder that allows you to configure the size of the live or event streams. Normally, ZoneMinder will display these streams in their native size. However, if you have monitors with large dimensions or a slow link, you may prefer to reduce this size. Alternatively, for small monitors, you can enlarge it 1. This option is available in High (WEB_H_DEFAULT_SCALE), Medium (WEB_M_DEFAULT_SCALE), and Low (WEB_L_DEFAULT_SCALE) bandwidth modes 1. #Is there a functional difference between the value 0 and 100 for this? Thinking default should be Null or 100, as 0 would cause image to not exist. ha.

"SignalCheckColour":"#0000BE", #Character case difference / not important

"WebColour":"red", #Look into having the API auto create unique colors when this is not specified to remove reliance on WebGUI front-end code

"Sequence":null, #Determine what sequence is used for and importance #I'm having difficulties finding information on this field. Does this have something to do with the Cycle option?


Is there a full blueprint for the API that I can look at? Information I found is limited. I guess I'll head over to github next.

Ultimately, I think adding a section under Options in the WebGUI and also the API, to then have default settings stored and changed when adding monitors will be beneficial. Figuring this out first though.

Another note: Zoneminder webGUI isn't clearing prior settings; only changing values if they are different (on some things I've noticed). I'm going to look deeper at the code and see how I'm going to attack this.
Post Reply