Pause button appears not to work in live streaming

Discussions related to the 1.36.x series of ZoneMinder
Tiggy
Posts: 62
Joined: Tue Mar 11, 2008 7:47 pm
Location: Belgium

Re: Pause button appears not to work in live streaming

Post by Tiggy »

My problems are almost the same as the original poster. I just have them when looking at past events, not the live one. The weird thing is I am not getting any error at all in the console except the one posted above. (Didn’t try to pause life)

Reviewing events as it is now is impossible unless you watch them from beginning to the end at regular speed.

Everything else works fine so I assume the js used for playback might be the problem?
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

I too am seeing this behaviour on Gentoo Linux. Impacts both live and event videos. Pause button looks "clicked" from gui but video continues to play.

Downgraded to 1.36.15 resolved, was running 1.36.18. Can step upgrade to find the break point in releases, as I was not QA checking this feature when point release upgrading to .16 and .17
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

1.36.16 also worked fine for me.

It looks like something changed in 1.36.17 to break pause/video controls. I am also observing the video flicker during frame play back, also flickering on the zone edit pages. Thank you :)
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

The timeline of this thread doesn't make sense, as the previous reports of the same symptom don't appear related.

These errors are logged for me when clicking pause or play:

Code: Select all

web_php [Unable to get semaphore.] at /usr/share/zoneminder/www/includes/functions.php line 1907
web_js [getCmdResponse%20stream%20error%3A%20Unable%20to%20get%20semaphore.%20-%20checkStreamForErrors()]
Semaphore changes were included in the 1.36.17 release

Hope this helps
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Re: Pause button appears not to work in live streaming

Post by lyallp »

Still a problem for me, versions have moved on.
I suspect it's a configuration item somewhere, .htaccess?
Would someone mind posting their .htaccess if their system works, so I can compare.
Last time I had issues it was a .htaccess problem and my API didn't work.
Gentoo Linux Chrome 102.0.5005.61
Zone Minder 1.37.16 (bleeding edge development)
apache 2.4.53
php 8.0
I even remotely access from Windows 10 using Windows as the client, still no go.
I have gotten used to the controls not working.
...Lyall
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

lyallp- can you tweak your /usr/share/zoneminder/www/ajax/stream.php file please?

I just did a partial revert of the semaphore retry change and I have playback controls again on 1.36.18

Code: Select all

diff --git a/web/ajax/stream.php b/web/ajax/stream.php
index 6d03ad5..e1b7231 100644
--- a/web/ajax/stream.php
+++ b/web/ajax/stream.php
@@ -15,17 +15,8 @@ mkdir(ZM_PATH_SOCKS);
 # The file that we point ftok to has to exist, and only exist if zms is running, so we are pointing it at the .sock
 $key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf('%06d', $_REQUEST['connkey']).'s.sock', 'Z');
 $semaphore = sem_get($key, 1);
-$semaphore_tries = 10;
-$have_semaphore = false;
-
-while ($semaphore_tries) {
-  $have_semaphore = sem_acquire($semaphore, 1);
-  if ($have_semaphore !== false) break;
-  ZM\Debug('Failed to get semaphore, trying again');
-  usleep(100000);
-  $semaphore_tries -= 1;
-}
-if ($have_semaphore) {
+
+if ( sem_acquire($semaphore,1) !== false ) {
   if ( !($socket = @socket_create(AF_UNIX, SOCK_DGRAM, 0)) ) {
     ajaxError('socket_create() failed: '.socket_strerror(socket_last_error()));
   }
It looks like Implement semaphore retry was merged into the main branch a while ago. so maybe the timeline for you does make sense after all :D I can clean this up in a patch for our gentoo ebuilds if this works for you.
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

While disabling the semaphore retry logic resolved my problem, there appears to be boolean issue introduced.

https://github.com/ZoneMinder/zoneminder/pull/3501

My system does not have System V semaphore support compiled into PHP. I am working on correcting that, not sure how much of a variable that factored into these results. Anyway. Hope this helps, and that I didn't miss interpret the intent.
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Re: Pause button appears not to work in live streaming

Post by lyallp »

no visible change. :(

Looking at the code, I don't see change making any difference, other than speeding things up a bit in a worst case scenario (no usleep), in a best case scenario, the result is the same.

I will admit I am not familiar with the pedantics of PHP true and false, is !== false really true? Can it be NULL which is not false but not true either?

There appear to be no error diagnostics in the apache nor zm logs, other than the 500 responses in the access log
(ever so slightly tweaked to remove obvious identifying data)

Code: Select all

IP_ADDRESS - - [07/Jun/2022:16:49:36 +0930] "GET /zm/cgi-bin/nph-zms?mode=jpeg&frame=1&scale=75&rate=100&maxfps=30&replay=none&source=event&event=54205&connkey=586952&rand=1654586376&auth=auth_text HTTP/1.1" 200 -
IP_ADDRESS - - [07/Jun/2022:16:51:08 +0930] "GET /zm/index.php?command=99&auth=auth_text&connkey=665370&view=request&request=stream HTTP/1.1" 500 -
IP_ADDRESS - - [07/Jun/2022:16:51:09 +0930] "GET /zm/index.php?command=1&auth=auth_text&connkey=665370&view=request&request=stream HTTP/1.1" 500 -
IP_ADDRESS - - [07/Jun/2022:16:51:13 +0930] "GET /zm/index.php?command=2&auth=auth_text&connkey=665370&view=request&request=stream HTTP/1.1" 500 -
the request headers are as follows,

Code: Select all

GET /zm/index.php?command=1&auth=auth_text&connkey=566937&view=request&request=stream HTTP/1.1
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Connection: keep-alive
Cookie: zmSkin=classic; zmCSS=dark; zmEventsTable.bs.table.columns=%5B%22Id%22%2C%22Name%22%2C%22Monitor%22%2C%22Cause%22%2C%22StartDateTime%22%2C%22EndDateTime%22%2C%22Length%22%2C%22Frames%22%2C%22AlarmFrames%22%2C%22TotScore%22%2C%22AvgScore%22%2C%22MaxScore%22%2C%22Storage%22%2C%22DiskSpace%22%2C%22Thumbnail%22%5D; zmEventsTable.bs.table.searchText=; zmEventsTable.bs.table.pageNumber=1; zmFramesTable.bs.table.columns=%5B%22FrameId%22%2C%22Type%22%2C%22TimeStamp%22%2C%22Delta%22%2C%22Score%22%2C%22Thumbnail%22%5D; zmFramesTable.bs.table.pageList=100; zmControlTable.bs.table.columns=%5B%22Name%22%2C%22Type%22%2C%22Protocol%22%2C%22CanMove%22%2C%22CanZoom%22%2C%22CanFocus%22%2C%22CanIris%22%2C%22CanWhiteBal%22%2C%22HasPresets%22%5D; zmFramesTable.bs.table.pageNumber=4; zmEventsTable.bs.table.pageList=All; zmEventStats=on; zmWatchScale2=0; zmCycleScale=0; zmCycleWidth=auto; zmCycleHeight=auto; zmEventScaleundefined=100; _ga=GA1.1.830513229.1643799974; _ga_2SSGMHY3NP=GS1.1.1643799973.1.1.1643800338.0; zmWatchScale=0; zmFrameStats=on; zmEventScale2=75; zmHeaderFlip=up; ttrss_sid=k8fdetektc0lb7pdcrbmrfjtft; zmEventShowZones2=1; ZMSESSID=tarbsu3pdua5ihpqac8ji2ui3e
Host: somewhere.com
Referer: https://somewhere.com/zm/index.php?view=event&eid=54134&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Battr%5D=StartDateTime&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Bop%5D=%3E%3D&filter%5BQuery%5D%5Bterms%5D%5B0%5D%5Bval%5D=-1+day&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bcnj%5D=and&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Battr%5D=MonitorId&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bop%5D=%3D&filter%5BQuery%5D%5Bterms%5D%5B1%5D%5Bval%5D=2&filter%5BQuery%5D%5Bsort_asc%5D=0&filter%5BQuery%5D%5Bsort_field%5D=StartDateTime&filter%5BQuery%5D%5Bskip_locked%5D=&filter%5BQuery%5D%5Blimit%5D=0&sort_field=StartDateTime&sort_asc=
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36
X-Requested-With: XMLHttpRequest
sec-ch-ua: " Not A;Brand";v="99", "Chromium";v="102"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Linux"
Response headers are

Code: Select all

HTTP/1.0 500 Internal Server Error
Date: Tue, 07 Jun 2022 07:09:51 GMT
Server: Apache
X-Powered-By: PHP/8.0.16
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Content-Length: 0
Connection: close
Content-Type: text/html; charset=UTF-8
...Lyall
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Re: Pause button appears not to work in live streaming

Post by lyallp »

I have a working (sort of) pause button!

It appears I did not have sysvipc enabled in PHP!

However, when I press pause, and then play, the event zooms (as in fast forwards) to the place I would have been had I not pressed pause.

I also note that when I press pause, the video advances 1 frame, 5 seconds after the pause click - coincidentally, the same amount of time that the 'semaphore retry loop' does 10 x 0.5 second usleeps.

It's an improvement. Not perfect, but better than before. :)
...Lyall
nabbi
Posts: 7
Joined: Mon Jun 06, 2022 7:12 pm

Re: Pause button appears not to work in live streaming

Post by nabbi »

I too see that jumpy resume behaviour after pausing. Present in both 1.36.16 and 1.36.18 for me.
Tiggy
Posts: 62
Joined: Tue Mar 11, 2008 7:47 pm
Location: Belgium

Re: Pause button appears not to work in live streaming

Post by Tiggy »

That zoom thing happens to me too.

How did you enable that sysvipc? In the php.ini?

Do you guys also have problems when watching a recorded event? When clicking somewhere (for example middle of the vid) to skip forward it continues playing but in slow motion. Anyone has that too?
lyallp wrote: Tue Jun 07, 2022 11:28 pm I have a working (sort of) pause button!

It appears I did not have sysvipc enabled in PHP!

However, when I press pause, and then play, the event zooms (as in fast forwards) to the place I would have been had I not pressed pause.

I also note that when I press pause, the video advances 1 frame, 5 seconds after the pause click - coincidentally, the same amount of time that the 'semaphore retry loop' does 10 x 0.5 second usleeps.

It's an improvement. Not perfect, but better than before. :)
User avatar
lyallp
Posts: 137
Joined: Fri Nov 26, 2010 2:36 am
Location: Adelaide, Australia

Re: Pause button appears not to work in live streaming

Post by lyallp »

I use a linux distribution called Gentoo, which builds almost everything from source, rather than download binary packages.
Firstly, I browsed to a phpinfo.php file which contains

Code: Select all

<?php
    phpinfo();
?>
to see if my PHP had sysvipc enabled.
You are looking for something like this...
sysvipc-build.gif
sysvipc-build.gif (33.1 KiB) Viewed 1633 times
sysvipc.gif
sysvipc.gif (3.54 KiB) Viewed 1633 times
Given I found my PHP did *not* have these showing, I knew my PHP needed to be rebuilt.
On Gentoo, it was a matter of creating/update /etc/portage/package.use/php with contents similar to the following

Code: Select all

dev-lang/php		    gmp bcmath gd exif fpm xmlreader sqlite curl pdo mysqli mysql zip xmlwriter apache2 truetype intl pcntl sodium sysvipc
Then I simply emerge --update --newuse dev-lang/php
I have no idea how it's done on any other linux distribution, I guess you need to see if sysvipc is enabled in the binary package.
...Lyall
Tiggy
Posts: 62
Joined: Tue Mar 11, 2008 7:47 pm
Location: Belgium

Re: Pause button appears not to work in live streaming

Post by Tiggy »

I didn't find time to check that sysv thing yet, but I don't think that my problem is the same.

Also that jump thing when pauzing is a normal thing I think; in the "MISC" section of the monitor, in the "BUFFER" part there is a "Stream Replay Image Buffer" setting, I think you ll have to play with that to make it work, BUT I did read in the docs that this might affect cpu usage.

I wonder if all the problems I am having with the playback buttons aren't due to some buffer problem

//EDIT
sysvmsg, sysvsem & sysvshm are enabled on my system.
jimrif
Posts: 2
Joined: Sun Jun 12, 2022 3:58 am

Re: Pause button appears not to work in live streaming

Post by jimrif »

I ran into the pause button not working problem with 1.36.16 or might have been 1.36.17 on a Rocky linux machine as well. I too was missing the sysv stuff in php, where Installing the "php-process" package fixed that. Another thing this fixed was the fps numbers were missing in in the live view window.
radiusman
Posts: 1
Joined: Sat Jul 30, 2022 9:42 pm

Re: Pause button appears not to work in live streaming

Post by radiusman »

I am running zoneminder in a truenas jail and the out of the box system was having the same issues as described above. Specifically the ajax calls when viewing a monitor to update the frames per second of the video were failing with a 500 error.

It looks like the current version of the plugin (as of the date of this posting) does not have the sysvmsg, sysvsem, and sysvshm packages installed for PHP. Installing them, and enabling the "allow_sysvipc" option in the jail fixed it.

If you run into this issue do the following:

At the jail's prompt, install the missing packages using pkg:
pkg install php80-sysvshm-8.0.20
pkg install php80-sysvsem-8.0.20
pkg install php80-sysvmsg-8.0.20

It's possible the version numbers may not be the same by the time you read this. You can check for the correct packages by doing the command:
pkg search php80-sys

Then shut down the jail, edit the jail's settings. Within "Jail Properties" there is an option to "allow_sysvipc", and make sure to enable that.

The start the jail again, and you shouldn't see this issue anymore.

Hope this helps!
Post Reply