From: Magnus Hagander Date: Fri, 12 Dec 2025 17:51:49 +0000 (+0100) Subject: Add small tool to check for broken audio in video files X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=refs%2Fremotes%2Fgithub%2Fmaster;p=pgeu-system.git Add small tool to check for broken audio in video files --- diff --git a/tools/videos/check/check_video_audio.py b/tools/videos/check/check_video_audio.py new file mode 100755 index 00000000..05da9d8c --- /dev/null +++ b/tools/videos/check/check_video_audio.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +import subprocess +import os +import sys + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print("Usage: check_video_audio.py [video_file2 ...]") + sys.exit(1) + + for v in sys.argv[1:]: + sys.stdout.write("{}: ".format(os.path.basename(v))) + sys.stdout.flush() + + r = subprocess.run([ + 'ffmpeg', + '-i', v, + '-map', '0:a:0', + '-af', 'astats', + '-f', 'null', + '-', + ], capture_output=True, check=True) + currchannel = 'unknown' + for line in r.stderr.decode().splitlines(): + if 'Channel: ' in line: + currchannel = line.split(':')[-1] + if 'RMS peak dB' in line: + val = line.split(':')[-1] + if 'inf' in val: + print("Channel {} is silent.".format(currchannel)) + break + else: + print("All channels have sound")