Animation created by the event server are black.

Discussions related to the 1.36.x series of ZoneMinder
Post Reply
Sparal
Posts: 6
Joined: Wed Nov 25, 2020 3:00 pm

Animation created by the event server are black.

Post by Sparal »

Hi,

I'm trying to use the "Animation" option wtih zm event server, but I'm unsuccessfull. An animation is created but is always black and is a couple of seconds long.

I run on Ubuntu 22.04.
ZM: version 1.36.33 / "apiversion":"2.0"
zmeventnotification last stable version v6.1.27.
Python 3.10.6
openCV version '4.7.0'
ffmpeg version 4.4.2

Objectconfig.ini:

[animation]
create_animation=yes
animation_types='mp4'
animation_width=640
animation_retry_sleep=15
animation_max_tries=4
fast_gif=no

Secrets.ini (I put it here, but I think this is not relevant, as the link is working, but the animation itself is not working)

[secrets]
ZMES_PICTURE_URL=http://*zmServeIP*/zm/index.php?view=image&eid=EVENTID&fid=objdetect_mp4&width=600

I know ZM run with the user www-data, but in order to test the behaviour, I have run the following command with sudo:

Code: Select all

sudo /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini  --eventid 2968 --monitorid 7 --debug
And at the end of the script, the animation should be created with image_manip.py:

Code: Select all

04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 zm_detect.py:481 [Prediction string JSON:{"labels": ["person"], "boxes": [[602, -1, 800, 531]], "frame_id": "snapshot", "confidences": [0.8874325752258301], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}}]
[s] detected:person:89% --SPLIT--{"labels": ["person"], "boxes": [[602, -1, 800, 531]], "frame_id": "snapshot", "confidences": [0.8874325752258301], "image_dimensions": {"original": [480, 640], "resized": [600, 800]}}
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 zm_detect.py:545 [animation: Creating burst...]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:37 [animation: Try:1 Getting http://*zmServeIP*/zm/api/events/2968.json?username=admin&password=***]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:74 [animation: Got 165 frames]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:83 [animation: event fps=12]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:88 [animation: anchor=snapshot start=45 end=165 skip=6]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:89 [animation: Grabbing frames...]
04/09/23 09:36:40 zmesdetect_m7[3130183] DBG1 image_manip.py:95 [Grabbing anchor frame: snapshot...]
04/09/23 09:36:41 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:45]
04/09/23 09:36:42 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:51]
04/09/23 09:36:43 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:57]
04/09/23 09:36:44 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:63]
04/09/23 09:36:44 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:69]
04/09/23 09:36:45 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:75]
04/09/23 09:36:46 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:81]
04/09/23 09:36:47 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:87]
04/09/23 09:36:48 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:93]
04/09/23 09:36:49 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:99]
04/09/23 09:36:50 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:105]
04/09/23 09:36:51 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:111]
04/09/23 09:36:52 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:117]
04/09/23 09:36:52 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:123]
04/09/23 09:36:53 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:129]
04/09/23 09:36:54 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:135]
04/09/23 09:36:55 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:141]
04/09/23 09:36:56 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:147]
04/09/23 09:36:57 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:153]
04/09/23 09:36:58 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:159]
04/09/23 09:36:59 zmesdetect_m7[3130183] DBG2 image_manip.py:106 [animation: Grabbing Frame:165]
04/09/23 09:37:00 zmesdetect_m7[3130183] DBG1 image_manip.py:112 [animation: Saving /objdetect...]
04/09/23 09:37:00 zmesdetect_m7[3130183] DBG1 image_manip.py:115 [Creating MP4...]
04/09/23 09:37:00 zmesdetect_m7[3130183] DBG1 image_manip.py:120 [animation: saved to /objdetect.mp4, size 2425 bytes, frames: 21]
04/09/23 09:37:00 zmesdetect_m7[3130183] DBG1 zm_detect.py:557 [Closing logs]
and then same result, the objdetect.mp4 is a 8 second long black screen video. Same result with GIF.
So I begin to search in image_manip.py (probably line 118 with imageio.mimwrite is doing something weird), but I can't figure it out. Could it be that the frame rate or the video size change make troubles when creating the animation?

Strangely enough, the option "Generate Video" on the zm Web UI works like a charm, mp4 and gif.

Any idea why the animation is not created properly by the Event Server?

Cheers

Alex
Sparal
Posts: 6
Joined: Wed Nov 25, 2020 3:00 pm

Re: Animation created by the event server are black.

Post by Sparal »

Hi,

I went further on my testing to try to isolate the issue.

I have written a small python script using imageio to create a gif:

Code: Select all

#!/usr/bin/python3
import imageio.v2 as imageio
images = [ ]
list = [1,3,5,7,9,11]
for i in list:
 p_url='http://[server ip]/zm/index.php?view=image&eid=7114&username=admin&password=XXX&fid={}&width=400'.format(i)
 images.append(imageio.imread(p_url))
imageio.mimsave('TestEvent7114.gif', images, duration = 0.5)
This works fine and I get the expected result, i.e. an animated gif. So imageio is not the issue.

In the script image_manip.py, I have created a new section at line 152, in order to test this script:

Code: Select all

        if 'fig' in types.lower():
            g.logger.Debug (1,'Creating GifTest...')
            images = [ ]
            list = [1,3,5,7,9,11]
            for i in list:
             p_url='http://[server ip]/zm/index.php?view=image&eid=7114&username=admin&password=XXX&fid={}&width=400'.format(i)
             images.append(imageio.imread(p_url))
            imageio.mimsave('TestEvent7114.gif', images, duration = 0.5)
 
In order to get this part executed, I have modified the objectconfig.ini as follow:

Code: Select all

 animation_types='fig'
 
Now I executethe zm_detect.py script again as follow

Code: Select all

 sudo /var/lib/zmeventnotification/bin/zm_detect.py --config /etc/zm/objectconfig.ini  --eventid 7114 --monitorid 2 --debug
 
Debug show no errors, but the gif created in this case is once again black. So the same working script executed from zm_detect.py is not giving the same result as "stand alone".
What do you think that I'm missing? Is there a kind of permission issue when executing the script (I gave full right access to everybody in the folder I'm testing this). I also run everything as sudo to have it working first, before to come back to normal www-data user.
Any idea would be appreciated.

Cheers

Alex
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Animation created by the event server are black.

Post by Magic919 »

Try posting it on the Slack channel.
-
Post Reply