Detect volume changes (commercials) in streaming audio/video?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 17:21

When streaming video, I notice that the volume during commercials is boosted. This is obnoxious. Is there any way to auto-detect these volume changes? If so, it seems it would be a simple next step to mute on this volume boost and unmute when volume drops back to normal.
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 17:41

In the past it was possible to identify a commercial break with a check for the channel logo.
Question - how would you detect that "volume drops back to normal" once you've muted it?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 18:10

I don't know if this resource is what you need. I haven't used these functions.

https://autohotkey.com/board/topic/2198 ... /?p=143564 -- the links in here are broken, however.

I was able to find a github uploaded by someone named G33kDude, who seems to be GeekDude here on the forums, as a mirror. I cannot verify these are the original functions by Lexikos, but they probably are. (And searching GeekDude's post, he does link to another github upload that has that username G33kDude.)

https://github.com/ahkscript/VistaAudio

Documentation link is a bit hidden in the top right corner on that page: https://ahkscript.github.io/VistaAudio/

There is a function in there called VA_GetAudioMeter(). I don't know for sure, but it sounded like the meter is how high the volume goes. Like if I'm playing a youtube file in my Firefox (so HTML5 video), Firefox's audio on the Volume Mixer (sndvol.exe; click on the speaker icon in the system tray (By your clock) and then click on Mixer) goes up part way to the max I set. See this image: https://i.imgur.com/ryx5oJE.png

Image

I don't know for sure that Meter is what that image demonstrates with the green bar. I may be entirely wrong.

Even if it is right, or if we find the way to access that Meter, the approach to detecting when the volume got louder than the actual video can be tough. Maybe the actual video did spike in volume; you may still want to decrease the volume anyway because it's so high above baseline. But then the trick is detecting baseline, which would probably deal with capturing a bunch of datapoints and then doing some sort of calculation to find the appropriate peak or volume. Or you can set a hard baseline if you want, possibly, if the meter is reporting like I'm hoping. If the sound in a video or commercial at any point jumps too high, so you drop the max slider. Alternatively, you may detect the video getting too quiet and increase the slider.

A good implementation for this sounds like it goes beyond even knowing the code for detecting and reacting -- how to react seems like a subjective issue.
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

Re: Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 19:59

BoBo wrote:In the past it was possible to identify a commercial break with a check for the channel logo.
Question - how would you detect that "volume drops back to normal" once you've muted it?
The channel logo isn't very consistent in this case. Typically it appears during the content, but not always. And while it usually doesn't appear during commercials, sometimes it does.

That said, the channel logo might be the easiest way to get a rough implementation of a commercial mute.

I guess the idea is the script performs an image search in a loop, i.e., redo image search every x seconds. When the image (channel logo) is not detected, mute. And continue image searching, and when it is detected, unmute. But I'd also want to allow for manual override - i.e., if there is content but no channel logo, I'd manually unmute and wouldn't want the script to mute again because it detects no channel logo.
redrum
Posts: 83
Joined: 25 Jan 2015, 22:57

Re: Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 20:00

Exaskryz wrote: Even if it is right, or if we find the way to access that Meter, the approach to detecting when the volume got louder than the actual video can be tough. Maybe the actual video did spike in volume; you may still want to decrease the volume anyway because it's so high above baseline. But then the trick is detecting baseline, which would probably deal with capturing a bunch of datapoints and then doing some sort of calculation to find the appropriate peak or volume. Or you can set a hard baseline if you want, possibly, if the meter is reporting like I'm hoping. If the sound in a video or commercial at any point jumps too high, so you drop the max slider. Alternatively, you may detect the video getting too quiet and increase the slider.

A good implementation for this sounds like it goes beyond even knowing the code for detecting and reacting -- how to react seems like a subjective issue.
Yeah, this sounds like it would be fairly involved, and subject to lots of false positives and false negatives.
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Detect volume changes (commercials) in streaming audio/video?

18 Oct 2017, 21:01

I use this to check if the system is outputting audio.

Code: Select all

q:: ;check if current audio output is silent or not
vAudioMeter := VA_GetAudioMeter()
VA_IAudioMeterInformation_GetPeakValue(vAudioMeter, vPeakValue)
MsgBox, % vPeakValue
return
Links:
Vista Audio Control Functions - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/2198 ... functions/
autohotkey-scripts/VA.ahk at master · vrillusions/autohotkey-scripts · GitHub
https://github.com/vrillusions/autohotk ... Lib/VA.ahk
[Same code as in this post:]
Do action when speak into mic - AutoHotkey Community
https://autohotkey.com/boards/viewtopic ... 82#p175382
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Insanibaccha, PsysimSV and 205 guests