From 10761e740e3eb71c77359d0072b1f5362b46237a Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 21 Dec 2020 11:17:49 +0100 Subject: [PATCH] add option to activate text from file --- ffplayout/filters/default.py | 15 +++++++++++---- ffplayout/filters/v_drawtext.py | 3 ++- ffplayout/utils.py | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ffplayout/filters/default.py b/ffplayout/filters/default.py index c3f9eeb9..3dc97ad6 100644 --- a/ffplayout/filters/default.py +++ b/ffplayout/filters/default.py @@ -256,7 +256,10 @@ def custom_filter(probe, type): for filter in glob(os.path.join(filter_dir, f'{type}_*')): filter = os.path.splitext(os.path.basename(filter))[0] filter_func = locate(f'ffplayout.filters.{filter}.filter') - filters.append(filter_func(probe)) + link = filter_func(probe) + + if link is not None: + filters.append(link) return filters @@ -272,26 +275,30 @@ def build_filtergraph(duration, seek, out, ad, ad_last, ad_next, probe, msg): seek = 0 if probe.video[0]: + custom_v_filter = custom_filter(probe, 'v') video_chain += text_filter() video_chain += deinterlace_filter(probe) video_chain += pad_filter(probe) video_chain += fps_filter(probe) video_chain += scale_filter(probe) video_chain += extend_video(probe, duration, out - seek) - video_chain += custom_filter(probe, 'v') + if custom_v_filter: + video_chain += custom_v_filter video_chain += fade_filter(duration, seek, out) audio_chain += add_audio(probe, out - seek, msg) if not audio_chain: + custom_a_filter = custom_filter(probe, 'a') + audio_chain.append('[0:a]anull') audio_chain += add_loudnorm(probe) audio_chain += extend_audio(probe, out - seek) - audio_chain += custom_filter(probe, 'a') + if custom_a_filter: + audio_chain += custom_a_filter audio_chain += fade_filter(duration, seek, out, 'a') if video_chain: - print(video_chain) video_filter = '{}[v]'.format(','.join(video_chain)) else: video_filter = 'null[v]' diff --git a/ffplayout/filters/v_drawtext.py b/ffplayout/filters/v_drawtext.py index fd921e82..76dcb222 100644 --- a/ffplayout/filters/v_drawtext.py +++ b/ffplayout/filters/v_drawtext.py @@ -16,4 +16,5 @@ def filter(probe): if _text.fontfile and os.path.isfile(_text.fontfile): font = f":fontfile='{_text.fontfile}'" - return f"drawtext=text='{title}':{_text.style}{font}" + if _text.text_from_filename: + return f"drawtext=text='{title}':{_text.style}{font}" diff --git a/ffplayout/utils.py b/ffplayout/utils.py index 02aaa4ef..5f1a0a9e 100644 --- a/ffplayout/utils.py +++ b/ffplayout/utils.py @@ -206,6 +206,7 @@ def load_config(): _text.over_pre = cfg['text']['over_pre'] _text.address = cfg['text']['bind_address'] _text.fontfile = cfg['text']['fontfile'] + _text.text_from_filename = cfg['text']['text_from_filename'] _text.style = cfg['text']['style'] _text.regex = cfg['text']['regex']