From e8d1971686f8c72f5b10688bc8362406ef249fce Mon Sep 17 00:00:00 2001 From: Jonathan Baecker Date: Sun, 31 May 2020 11:47:18 +0200 Subject: [PATCH] make logo scale optional --- ffplayout.yml | 6 ++++-- ffplayout/filters.py | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ffplayout.yml b/ffplayout.yml index 2a1441c9..5ab3a632 100644 --- a/ffplayout.yml +++ b/ffplayout.yml @@ -34,7 +34,9 @@ logging: pre_compress: helptext: Settings for the pre-compression. All clips get prepared in that way, so the input for the final compression is unique. 'aspect' must be a float - number. 'logo' is only used if the path exist. With 'logo_opacity' logo can + number. 'logo' is only used if the path exist. 'logo_scale' scale the logo to + target size, leave it blank when no scaling is needed, format is 'number:number', + for example '100:-1' for proportional scaling. With 'logo_opacity' logo can become transparent. With 'logo_filter' 'overlay=W-w-12:12' you can modify the logo position. With 'use_loudnorm' you can activate single pass EBU R128 loudness normalization. 'loud_*' can adjust the loudnorm filter. [Output is @@ -45,7 +47,7 @@ pre_compress: fps: 25 add_logo: True logo: "docs/logo.png" - logo_scale: "100:-1" + logo_scale: logo_opacity: 0.7 logo_filter: "overlay=W-w-12:12" add_loudnorm: False diff --git a/ffplayout/filters.py b/ffplayout/filters.py index fa739091..3a93a97a 100644 --- a/ffplayout/filters.py +++ b/ffplayout/filters.py @@ -19,10 +19,10 @@ import math import os +import re from .utils import _pre_comp - # ------------------------------------------------------------------------------ # building filters, # when is needed add individuell filters to match output format @@ -116,14 +116,18 @@ def overlay_filter(duration, ad, ad_last, ad_next): when clip before was an ad fade logo in """ logo_filter = '[v]null[logo]' + scale_filter = '' if _pre_comp.add_logo and os.path.isfile(_pre_comp.logo) and not ad: logo_chain = [] - opacity = 'format=rgba,scale={},colorchannelmixer=aa={}'.format( - _pre_comp.logo_scale, _pre_comp.logo_opacity) + if _pre_comp.logo_scale and \ + re.match(r'\d+:-?\d+', _pre_comp.logo_scale): + scale_filter = 'scale={},'.format(_pre_comp.logo_scale) + logo_extras = 'format=rgba,{}colorchannelmixer=aa={}'.format( + scale_filter, _pre_comp.logo_opacity) loop = 'loop=loop=-1:size=1:start=0' logo_chain.append( - 'movie={},{},{}'.format(_pre_comp.logo, loop, opacity)) + 'movie={},{},{}'.format(_pre_comp.logo, loop, logo_extras)) if ad_last: logo_chain.append('fade=in:st=0:d=1.0:alpha=1') if ad_next: