bundles/voc-loudness-monitor: inital commit of sources units

This commit is contained in:
Franzi 2020-03-21 11:31:27 +00:00
parent b486548d63
commit 8abfe74c2b
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 118 additions and 0 deletions

View file

@ -0,0 +1,17 @@
[Unit]
Description=Loudness Monitor for ${url}
After=syslog.target
After=network.target
[Service]
RestartSec=30s
Type=simple
User=voc
Group=voc
WorkingDirectory=/opt/voc-loudness-monitor/
ExecStart=/opt/voc-loudness-monitor/loudness_${id}.sh
Restart=always
StartLimitInterval=0
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,25 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
ffmpeg \
-y \
-hide_banner \
-nostdin \
-re \
-loglevel warning \
-timeout 5 \
-i ${url} \
-filter_complex "[0:v] scale=w=640:h=360, fps=25 [scaled];
[0:a] ebur128=video=1:target=-16:gauge=shortterm:scale=relative:size=640x480[ebur][a1];
[ebur] fps=25 [v1];
[v1][scaled] vstack=inputs=2 [out];
[a1] anullsink" \
-map "[out]" \
-c:v mpeg2video \
-pix_fmt yuv420p \
-q:v 2 \
-keyint_min 0 \
-an \
-f rtp rtp://127.0.0.1:${port}

View file

@ -0,0 +1,67 @@
assert node.has_bundle('systemd')
streams = {
's1': {
'url': 'http://live.ber.c3voc.de:7999/s1',
'port': 15001,
},
's2': {
'url': 'http://live.ber.c3voc.de:7999/s2',
'port': 15002,
},
's3': {
'url': 'http://live.ber.c3voc.de:7999/s3',
'port': 15003,
},
's4': {
'url': 'http://live.ber.c3voc.de:7999/s4',
'port': 15004,
},
's5': {
'url': 'http://live.ber.c3voc.de:7999/s5',
'port': 15005,
},
's6': {
'url': 'http://live.ber.c3voc.de:7999/s6',
'port': 15006,
},
'sloop': {
'url': 'http://live.ber.c3voc.de:7999/sloop_h264',
'port': 15000,
},
}
files = {}
svc_systemd = {}
for stream_id, config in streams.items():
config['id'] = stream_id
files['/opt/voc-loudness-monitor/loudness_{}.sh'.format(stream_id)] = {
'source': 'loudness.sh',
'content_type': 'mako',
'context': config,
'mode': '0755',
'triggers': {
'svc_systemd:loudness_{}:restart'.format(stream_id),
},
}
files['/etc/systemd/system/loudness_{}.service'.format(stream_id)] = {
'source': 'loudness.service',
'content_type': 'mako',
'context': config,
'needs': {
'file:/opt/voc-loudness-monitor/loudness_{}.sh'.format(stream_id),
},
'triggers': {
'action:systemd-reload',
'svc_systemd:loudness_{}:restart'.format(stream_id),
},
}
svc_systemd['loudness_{}'.format(stream_id)] = {
'needs': {
'file:/etc/systemd/system/loudness_{}.service'.format(stream_id),
'action:systemd-reload',
},
}

View file

@ -0,0 +1,9 @@
@metadata_processor
def add_voc_user(metadata):
return {
'users': {
'voc': {
'home': '/opt/voc-loudness-monitor',
},
},
}, DEFAULTS, DONE