mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2026-10-02 01:37:22 +00:00
24 lines
650 B
Python
24 lines
650 B
Python
import json
|
|
import os.path
|
|
import subprocess
|
|
|
|
FFPROBE = "ffprobe"
|
|
|
|
|
|
def ffprobe(path):
|
|
arguments = [FFPROBE, "-of", "json", "-show_format", "-show_streams", path]
|
|
process = subprocess.run(arguments, check=True, capture_output=True)
|
|
if process.returncode == 0:
|
|
output_str = process.stdout.decode("utf-8")
|
|
return json.loads(output_str)
|
|
else:
|
|
return None
|
|
|
|
|
|
def all_files():
|
|
for dirpath, _, filenames in os.walk("tests/test_files"):
|
|
for filename in filenames:
|
|
_, ext = os.path.splitext(filename)
|
|
if ext in [".wav", ".WAV"]:
|
|
yield os.path.join(dirpath, filename)
|