zmNinja - low fps on liveview

Discussion topics related to mobile applications and ZoneMinder Event Server (including machine learning)
Post Reply
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

zmNinja - low fps on liveview

Post by Bluemax »

Hallo,
i'm using zmNinja 1.3.061 on Android and everything works fine so far but the liveview just updates with maybe 12-15fps (guessed). It's clearly not 25fps that the camera and the ZM console provides (1024x576, Hikvision, rtsp/x264).
Can you add an fps overlay in liveview to provide more infos about performance? The mobile device is on Android 9 and should have enough power.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

Are you on multi-port? If not, that is why.
https://zmninja.readthedocs.io/en/lates ... zm-console
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zmNinja - low fps on liveview

Post by Bluemax »

I'm not talking about 'montage view' but the single camera full screen view. I know that the rendering backend (sequential jpgs in browser/webview) is not optimal for high framerates or smooth motion and Zoneminder console also shows some minor microjitter now and then but it mostly can hold the 25fps steadily whereas zmNinja is clearly way lower (near stroboscopic). Frames are missing/skipped. Maybe its even exactly 1/2 (12.5fps). That's why i think an fps rate element/overlay (or debug view) could be helpful here (like on ZM console) to see how it behaves on different devices.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

I see. Well, zmNinja does not enforce an FP
Here is the URL it uses in live view on single monitor view:
<img id="singlemonitor" style="width:100vw; height:100vh;" image-spinner-loader="lines" image-spinner-src="https://myserver:30004/zm/cgi-bin/nph-z ... nkey=61589"">
so it is just an image tag HTML element pointed at ZMS. ZMS is controlling the rate/etc.

I'll look into how ZM is displaying FPS and I can do that too.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

I just asked Isaac - he mentioned that the FPS that is displayed in ZM is not the streaming FPS, but the capturing FPS (the FPS that ZM is capturing frames at from the camera). So not sure if that will really help - it adds an extra API that I have to call every few seconds.

Note that even if your phone is very capable, sometimes, the network from the phone to the server may be the bottle neck. Not saying that is the issue here, but I don't feel adding that FPS value will give you any more insight.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zmNinja - low fps on liveview

Post by Bluemax »

asker wrote: Thu Jun 13, 2019 8:33 pm it is just an image tag HTML element pointed at ZMS. ZMS is controlling the rate/etc.
An <img> tag might just display one frame. The question is how often is that tag updated/rendered on screen? Can you influence or benchmark it (count the updates per second)?

I've taken another closer look and i think the render rate is just around 10fps or so (if at all). Timing is consistent and steady, not fluctuating. Throughput is around 360KB/s. Not a problem for Android/Wifi.

The initial idea behind the FPS display was just so we could talk somewhat more technical here (instead of "its stuttering"). But the FPS counter is not important at all. The whole thing is rather about to figure out if there's a possibility to improve the update rate (getting more fps - close to 25fps). Maybe its an individual thing on my side (Android 9 ?) or Cordova in general, i don't know. That's what i'm trying to figure out. I think this low update rate is suspicious/untypical and maybe fixable with reasonable effort. Would it be possible to get the x264 passthrough stream from ZMS for a html5 video tag (if there's no way to improve the <img> method)?
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

An <img> tag might just display one frame. The question is how often is that tag updated/rendered on screen? Can you influence or benchmark it (count the updates per second)?
no. It displays continuously. Try it yourself with a zms url. That is why I’ve said zmNinja doesn’t control FPS.
Would it be possible to get the x264 passthrough stream from ZMS for a html5 video tag
Video tags don’t support live video streamed as 264. They only support fully formed videos (like mp4 events). Live requires something like DASH or HLS neither of which are supported by ZM. You will need a server side restreamer
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

So here are my observations, comparing the zmNinja desktop version and ZM web console:

1. When I first ran both together, I noticed the web console go faster than zmNinja (single live)
2. I realized that ZM is using `&buffer=1000` while zmNinja was not in the URL. When I added that, it seems the performance was comparable
3. However, zmNinja's montage screen does use `&buffer=1000` so if you are on multi-port, you should see comparable performance (do you? only if you are on multi port)
4. It also seems ZM resizes the image based on your display size. zmNinja doesn't (mobile phones are typically much higher dpi). I am not inclined to change this.

I'd like to see if modifying item 2 makes it comparable for you. Would you mind shooting me an email ? I can send you a test apk.
pliablepixels@gmail
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zmNinja - low fps on liveview

Post by Bluemax »

I've found it. You're missing 'maxfps=30' parameter. The default value seems much smaller.
On zmNinja the bandwidth significantly goes up though (see below). It might be a wise choice to make it optional/variable.

Edit:
asker wrote: Fri Jun 14, 2019 12:24 am Live requires something like DASH or HLS neither of which are supported by ZM. You will need a server side restreamer
I did a quick test with ffmpeg HLS. It works natively on mobile browsers.

Throughput for 1024x576x25fps stream:
zmNinja (standard/lowfps) - 350KB/s
zmNinja (maxfps=30) - 1600KB/s
Firefox/mobile (720x576 passthrough RTSP/h264/HLS) - 88KB/s

not bad... it works out of the box with the standard ffmpeg binary.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

Ok, yes I saw that was missing, but I also saw good performance just with buffer=
Did that make a difference?
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
Bluemax
Posts: 121
Joined: Wed Jun 12, 2019 5:15 pm

Re: zmNinja - low fps on liveview

Post by Bluemax »

No, it doesn't help here.
I've seen unreliable behavior on mobile browsers though (chrome) in case you're testing there. After some time it was stuck on low fps no matter what parameter was set and also once had high fps with buffer=1000 (on first run). But i cannot reproduce that. Desktop browser (Firefox) acts sane every time. zmNinja/mobile seems to work properly as well so far.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: zmNinja - low fps on liveview

Post by asker »

Okay. I've added an FPS option in dev settings. Will be av. in .062
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Post Reply