Skip to content

Feat: Using audio motion analyzer#4393

Open
IgorA100 wants to merge 40 commits intoZoneMinder:masterfrom
IgorA100:patch-435415
Open

Feat: Using audio motion analyzer#4393
IgorA100 wants to merge 40 commits intoZoneMinder:masterfrom
IgorA100:patch-435415

Conversation

@IgorA100
Copy link
Copy Markdown
Contributor

@IgorA100 IgorA100 commented Jul 26, 2025

There are still some changes that need to be made to the BD:
ALTER TABLE `Monitors` ADD `WhatDisplay` enum('OnlyVideo','OnlyAudioVisualization','VideoAudioVisualization') NOT NULL DEFAULT 'OnlyVideo' AFTER `Decoding`;

@IgorA100
Copy link
Copy Markdown
Contributor Author

Watch page
1111

Monitor page
1112

Will these names be ok or do I need to change something?

@connortechnology
Copy link
Copy Markdown
Member

I guess it's ok. I would have gone with a toggle for video and a toggle for analysis, but either way gets the job done.

@IgorA100
Copy link
Copy Markdown
Contributor Author

I would have gone with a toggle for video and a toggle for analysis,

Yes, I wanted to do it that way.
But, for example, for the Monitor page we will have to add another field to the DB to disable ZMS JPEG, for example "ZMSEnabled".
I have some sketches. For example, it could look like this:
1
2
3

This is a multi select in which you can select the necessary players or disable them all.
The checkboxes will be in the "disabled" state, but the "tick" will be automatically checked or unchecked depending on whether the player is selected in the multi select or not.
If you agree, I will do this as a separate PR.

@IgorA100
Copy link
Copy Markdown
Contributor Author

I would have gone with a toggle for video

I've done a lot already, but... I came to the conclusion that Player = None is wrong. To play only audio, we still need a player. It can be either go2rtc or rtsp2web.
We can't turn off the player completely, because in this case nothing will be played at all.
I'll have to stop at the option: #4393 (comment)
I can make a PR regarding this switch #4393 (comment)
But without the "None" option. Should I make a PR or leave everything as it is now?

@connortechnology
Copy link
Copy Markdown
Member

Let's leave the player issues aside. I disagree with adding options to disable zms playback, as that is the fallback when all else fails. People get confused when there are too many options to configure.
I think for now this PR should simply add the Show audio visualisation feature. Leave the rest for another day.
I am targetting Christmas for release now, so we could get this in soon.

@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Nov 2, 2025

I disagree with adding options to disable zms playback,

I don't want to disable ZMS either.
I'm just busy with my main job right now and have put off working on this PR for a bit.
But I hope to finish this PR soon.

- Clear IconMute when executing destroyVolumeSlider()
- Added the ability to clear the icon state to changeStateIconMute()

MonitorStream.js
- Set #volumeControls to "disabled" instead of "hidden"
- Don't execute controlMute() when executing createVolumeSlider()

Added:
audioMotionAnalyzer.js
@IgorA100
Copy link
Copy Markdown
Contributor Author

@connortechnology
I've completed this PR.
Please review it.

If this PR is approved, I'll create a settings page for the visualizer later.

@IgorA100 IgorA100 marked this pull request as ready for review March 19, 2026 09:51
@IgorA100
Copy link
Copy Markdown
Contributor Author

IgorA100 commented Mar 20, 2026

@connortechnology
I made a small change.

Run changeWhatDisplay() without refreshing on Watch page

It's almost invisible to the naked eye, but it does impact performance.
@IgorA100
Copy link
Copy Markdown
Contributor Author

@connortechnology
Please run Copilot, maybe it will find something.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an “audio motion analyzer” visualization to classic skin streaming views, controlled by a new per-monitor WhatDisplay setting (and a user override via cookie), enabling video-only, audio-visualization-only, or both.

Changes:

  • Introduces WhatDisplay monitor option and exposes it in Monitor settings + Watch/Montage/Event view controls.
  • Adds an <audio-motion> web component backed by the vendored audioMotion-analyzer library, plus JS glue to connect it to captured MediaStreams and volume controls.
  • Updates montage/watch/event behaviors and CSS to optionally hide video while keeping streams running.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 16 comments.

Show a summary per file
File Description
web/skins/classic/views/watch.php Adds “What display” selector to Watch controls.
web/skins/classic/views/montage.php Adds “What display” selector and conditional audio control panel rendering.
web/skins/classic/views/monitor.php Adds WhatDisplay field to monitor “viewing” settings.
web/skins/classic/views/js/watch.js.php Exposes monitor whatDisplay in per-monitor JS data.
web/skins/classic/views/js/watch.js Implements controlWhatDisplay() and hooks audio visualization lifecycle into Watch flow.
web/skins/classic/views/js/montage.js.php Exposes monitor whatDisplay in montage JS data.
web/skins/classic/views/js/montage.js Adds montage-specific handling for no-video mode, observers, and global volume controls.
web/skins/classic/views/js/event.js.php Exposes whatDisplay for event playback.
web/skins/classic/views/js/event.js Hooks audio visualization init/pause into Event playback and adds “What display” reload handler.
web/skins/classic/views/event.php Adds “What display” selector, data attribute for video hiding, and <audio-motion> markup.
web/skins/classic/js/skin.js Adds shared helpers for connecting/destroying audio visualization and refactors volume slider/mute behavior.
web/skins/classic/js/audioMotionAnalyzer.js New module defining <audio-motion> custom element and integrating analyzer behavior.
web/skins/classic/includes/functions.php Loads the new module script from xhtmlFooter().
web/skins/classic/includes/config.php Defines $whatDisplay options array for Monitor settings.
web/skins/classic/css/base/skin.css Adds CSS for audio visualization layout and “hide video but keep stream alive” behavior.
web/skins/classic/assets/version Documents the newly vendored library version.
web/skins/classic/assets/audioMotion-analyzer/src/audioMotion-analyzer.js Adds vendored upstream analyzer library source.
web/js/MonitorStream.js Plumbs whatDisplay, integrates audio visualization and refactors volume control helpers.
web/includes/Monitor.php Adds default WhatDisplay, emits data-not-display-video, and appends <audio-motion> markup per stream.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'AnalysisImage' => 'FullColour',
'Enabled' => array('type'=>'boolean','default'=>1),
'Decoding' => 'Always',
'WhatDisplay' => 'OnlyVideo',
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds a new WhatDisplay monitor field in defaults and UI, but the PR doesn’t include a DB migration/update SQL in db/ to add the Monitors.WhatDisplay column. Without an update script, installs/upgrades will hit SQL/ORM errors when accessing $monitor->WhatDisplay(). Add a db/zm_update-*.sql entry (and/or schema update) as part of this change.

Suggested change
'WhatDisplay' => 'OnlyVideo',

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to break anything, so I didn't add the SQL migration to the code.
You need to add the following code:
ALTER TABLE MonitorsADDWhatDisplayenum('OnlyVideo','OnlyAudioVisualization','VideoAudioVisualization') NOT NULL DEFAULT 'OnlyVideo' AFTERDecoding;

IgorA100 and others added 11 commits March 21, 2026 21:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@IgorA100 IgorA100 marked this pull request as draft March 21, 2026 20:58
@IgorA100 IgorA100 marked this pull request as ready for review March 21, 2026 21:38
@IgorA100
Copy link
Copy Markdown
Contributor Author

@connortechnology
I've made the changes.
I've left a comment under each of Copilot's suggestions.
I consider this PR complete.
You can begin testing it.
I'll be awaiting your decision.

@IgorA100
Copy link
Copy Markdown
Contributor Author

Isaac, have you checked this PR yet?
I'm curious to know your opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants