MoeFwacky / vhstools

A set of python scripts with various video tools, including editing, automatic scene detection and splitting, and posting random clips to social media platforms
GNU General Public License v3.0
5 stars 0 forks source link

Feature Request - Detect low audio levels, use them for scene detection #10

Closed dege13 closed 1 year ago

dege13 commented 1 year ago

As we talked about in our Twitter messages, it would be nice to add sound level detection.

I assume the scanner would add db level to the JSON file for the splitter to use to detect scenes.

There will be more config values to tweak the overlap between black screen and no audio, as well as a length threshold like you have for black screen detection now.

It's probably best to make it an optional flag which is disabled by default until it can be tested and good values can be found for the config.

MoeFwacky commented 1 year ago

I've added audio detection into the scanner. This gives a loudness value and a Boolean for if silence is detected in the frame according to the value set in the config. It doesn't appear to greatly affect the processing time at all on my end. I'll be adding the check into the scene splitter function next to see how it works for cutting up commercials.

MoeFwacky commented 1 year ago

I've added audio level support to the scene splitter. So far in testing it's worked pretty well.

MoeFwacky commented 1 year ago

I've updated the audio level support and have set it up to determine the silence threshold at the 35th percentile of the min/max range (excluding -Infinity). It hit fairly accurate, but it does miss cuts in which audio plays over the fade. Still the margin of error appears to be less in testing so far. I have more files to run it through, but I think it's in pretty good shape.