Replies: 1 comment 4 replies
-
It looks like you can use ffmpeg's import glob
import os
import shutil
import sys
import subprocess
IDENTIFIER = "max_volume: "
if len(sys.argv) != 4:
print(f"Usage: {sys.argv[0]} path/to/videos path/to/output 100.5")
exit(1)
source_dir = os.path.abspath(sys.argv[1])
dest_dir = os.path.abspath(sys.argv[2])
threshold = float(sys.argv[3])
os.makedirs(dest_dir, exist_ok=True)
for file in glob.glob(os.path.join(source_dir, "*")):
output = subprocess.run(["ffmpeg", "-v", "info", "-i", file, "-filter:a", "volumedetect", "-f", "null", "-"], capture_output=True, text=True)
if output.returncode != 0:
continue
start = output.stderr.find(IDENTIFIER)
if start < 0:
continue
start += len(IDENTIFIER)
end = output.stderr.find(" ", start)
volume = float(output.stderr[start:end])
print(f"{os.path.basename(file)} volume: {volume} dB")
if volume > threshold:
shutil.copyfile(file, os.path.join(dest_dir, os.path.basename(file))) If you're unable to get something working feel free to reach out or file a feature request for this. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am proving that the traffic noise outside my house is too loud. DVR-Scan is awesome for breaking down all the vehicle activity into bite-sized videos. But then I have to go through them all manually to find the 5-10% that are super loud. So it would be great if you could add a noise filter that only saves all videos where the sound is greater than 80DB for example - and also goes on for more than say 3 seconds. I think it would be a great addition to an already excellent tool. It could no doubt be applied to many other applications too.
Beta Was this translation helpful? Give feedback.
All reactions