29 lines
1.7 KiB
Python
29 lines
1.7 KiB
Python
"""보존한 v0.2.3 WAV와 새 WAV를 생성기와 독립된 필터 호출로 재측정한다."""
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / 'tests/python'))
|
|
from test_loudness_audio import independent_measure
|
|
|
|
# 기준 통계는 동일 도구/필터의 input_i이다. 별도 ebur128 진단값도 숨기지 않고 저장한다.
|
|
report = {'ffmpeg': subprocess.check_output(['ffmpeg', '-version'], text=True).splitlines()[0],
|
|
'contractMeter': 'FFmpeg loudnorm input_i/input_tp, dual_mono=false', 'targetLUFS': -32, 'ceilingDBTP': -6}
|
|
for label, directory in [('before', Path(__file__).parent / 'baseline/ambience'), ('after', ROOT / 'public/ambience')]:
|
|
rows = []
|
|
for path in sorted(directory.glob('*.wav')):
|
|
rows.append({'environmentId': path.stem, 'sha256': hashlib.sha256(path.read_bytes()).hexdigest(),
|
|
'bytes': path.stat().st_size, **independent_measure(path)})
|
|
levels = [row['input_i'] for row in rows]
|
|
diagnostics = [row['ebur128_i'] for row in rows]
|
|
report[label] = {'minimumLUFS': min(levels), 'maximumLUFS': max(levels), 'spreadLU': round(max(levels)-min(levels),2),
|
|
'ebur128DiagnosticSpreadLU': round(max(diagnostics)-min(diagnostics),2), 'files': rows}
|
|
assert report['before']['spreadLU'] == 16.49
|
|
assert report['after']['spreadLU'] <= 0.4
|
|
assert all(abs(row['input_i'] + 32) <= 0.2 and row['input_tp'] <= -6 for row in report['after']['files'])
|
|
(Path(__file__).parent / 'independent-loudness.json').write_text(json.dumps(report, indent=2)+'\n')
|
|
print(json.dumps({label: {k:v for k,v in report[label].items() if k!='files'} for label in ('before','after')}, indent=2))
|