refactor(analyzer): improve analyzer pipeline module (#1542)
* rename steps to pipeline module * move pipeline entrypoint to pipeline module * rename steps test module to pipeline * fix paths after renames * move step protocol to pipeline * create pipeline status enum * use Protocol from typing extensions * Fix linting
This commit is contained in:
parent
74c8d20284
commit
cba905e367
18 changed files with 34 additions and 26 deletions
27
analyzer/libretime_analyzer/pipeline/analyze_replaygain.py
Normal file
27
analyzer/libretime_analyzer/pipeline/analyze_replaygain.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from subprocess import CalledProcessError
|
||||
from typing import Any, Dict
|
||||
|
||||
from ..ffmpeg import compute_replaygain, probe_replaygain
|
||||
|
||||
|
||||
def analyze_replaygain(filepath: str, metadata: Dict[str, Any]):
|
||||
"""
|
||||
Extracts the Replaygain loudness normalization factor of a track using ffmpeg.
|
||||
"""
|
||||
try:
|
||||
# First probe for existing replaygain metadata.
|
||||
track_gain = probe_replaygain(filepath)
|
||||
if track_gain is not None:
|
||||
metadata["replay_gain"] = track_gain
|
||||
return metadata
|
||||
except (CalledProcessError, OSError):
|
||||
pass
|
||||
|
||||
try:
|
||||
track_gain = compute_replaygain(filepath)
|
||||
if track_gain is not None:
|
||||
metadata["replay_gain"] = track_gain
|
||||
except (CalledProcessError, OSError):
|
||||
pass
|
||||
|
||||
return metadata
|
Loading…
Add table
Add a link
Reference in a new issue