Find objects missing LUFS values and scan.
This commit is contained in:
parent
e6031486ec
commit
a4e4df18a6
26
MosDb.py
26
MosDb.py
@ -112,3 +112,29 @@ class MosDb():
|
||||
|
||||
if objData["planningId"] != "":
|
||||
self.add_link(objData["objId"], objData["planningId"])
|
||||
|
||||
def get_missing_lufs(self):
|
||||
"""Finds matching objects without LUFS values
|
||||
"""
|
||||
self.c.execute(
|
||||
"SELECT mo.objId, mo.objPath \
|
||||
FROM mosobjects mo \
|
||||
LEFT JOIN moslufs lu ON mo.objId=lu.objId \
|
||||
LEFT JOIN mosservers ms ON mo.mosId=ms.mosId \
|
||||
LEFT JOIN mosgroups mg ON mo.groupId=mg.groupId \
|
||||
WHERE mo.isDeleted=0 \
|
||||
AND ms.mosServer LIKE \"StudioA%\" \
|
||||
AND mg.objGroup=\"OA Material\" \
|
||||
AND mo.objPath <> \"\" \
|
||||
AND lu.objId is NULL")
|
||||
result = []
|
||||
for row in self.c.fetchall():
|
||||
result.append( (row[0], row[1] ))
|
||||
return result
|
||||
|
||||
def set_lufs(self, obj_id, lufs, lra, ldiff):
|
||||
"""Adds given data to database
|
||||
"""
|
||||
self.db_insert_or_replace("moslufs", {"objId": obj_id, "lufs": lufs, "lra": lra, "ldiff": ldiff})
|
||||
self.commit()
|
||||
|
||||
|
68
analyse.py
Executable file
68
analyse.py
Executable file
@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from subprocess import check_output
|
||||
import configparser
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import MosDb
|
||||
|
||||
c = configparser.ConfigParser()
|
||||
c.read("config.ini")
|
||||
|
||||
LOUDNESS_SCANNER = c.get("Tools", "LOUDNESS_SCANNER")
|
||||
CLIP_PATH_TRANSFORM_FROM = c.get("MOS", "CLIP_PATH_TRANSFORM_FROM")
|
||||
CLIP_PATH_TRANSFORM_TO = c.get("MOS", "CLIP_PATH_TRANSFORM_TO")
|
||||
TARGET_LUFS = float(c.get("LUFS", "TARGET_VALUE"))
|
||||
|
||||
print("Loudness-Scanner: {}".format(LOUDNESS_SCANNER))
|
||||
print("Path transform FROM: {}".format(CLIP_PATH_TRANSFORM_FROM))
|
||||
print("Path transform TO : {}".format(CLIP_PATH_TRANSFORM_TO))
|
||||
|
||||
db = MosDb.MosDb()
|
||||
|
||||
todo = db.get_missing_lufs()
|
||||
|
||||
print("{} files to analyse.".format(len(todo)))
|
||||
devnull = open(os.devnull, "w")
|
||||
|
||||
for f in todo:
|
||||
objId = f[0]
|
||||
objPath = f[1]
|
||||
|
||||
objFile = objPath.replace(CLIP_PATH_TRANSFORM_FROM, CLIP_PATH_TRANSFORM_TO).replace("\\", "/")
|
||||
|
||||
cmd = [LOUDNESS_SCANNER, "scan", "-l", objFile]
|
||||
output = check_output(cmd, stderr=devnull)
|
||||
output = output.decode('utf-8')
|
||||
|
||||
lines = output.split("\n")
|
||||
valid = re.compile(r"^\s*(-.+) LUFS, (.+) LU, (.*)$")
|
||||
|
||||
have_lufs = False
|
||||
for l in lines:
|
||||
m = valid.match(l)
|
||||
if not m:
|
||||
continue
|
||||
lufs = m.group(1)
|
||||
lra = m.group(2)
|
||||
print("Found LUFS for {}: {} (LRA: {} LU)".format(objId, lufs, lra), end="")
|
||||
if lufs == "-inf":
|
||||
lufs = -99.0
|
||||
lra = 0.0
|
||||
ldiff = 99.0
|
||||
else:
|
||||
lufs = float(lufs)
|
||||
lra = float(lra)
|
||||
ldiff = abs(lufs - TARGET_LUFS)
|
||||
print(", diff to {}: {}".format(TARGET_LUFS, ldiff))
|
||||
db.set_lufs(objId, lufs, lra, ldiff)
|
||||
have_lufs = True
|
||||
break
|
||||
|
||||
if not have_lufs:
|
||||
print("ERROR analysing file for {}: {}".format(objId, objFile))
|
||||
|
||||
db.finish()
|
||||
|
@ -1,10 +1,9 @@
|
||||
[Tools]
|
||||
# https://github.com/jiixyj/loudness-scanner.git
|
||||
LOUDNESS_SCANNER = /opt/loudness-scanner/loudness
|
||||
|
||||
[MOS]
|
||||
XML_LOG_PATH = /mnt/sp-somosgw-01/
|
||||
CLIP_PATH_TRANSFORM_FROM = \\\\sp-soisilon-01\\sonaps\\intern
|
||||
CLIP_PATH_TRANSFORM_FROM = \\sp-soisilon-01\sonaps\intern
|
||||
CLIP_PATH_TRANSFORM_TO = /mnt/sp-soisilon-01
|
||||
|
||||
[LUFS]
|
||||
|
Loading…
x
Reference in New Issue
Block a user