From e9f565ed60dad5bd66d8a8853871ba470498dfcd Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 24 Jan 2022 21:34:02 +0100 Subject: [PATCH] make ingest input more generic, add correct filtering to server --- ffplayout.yml | 6 ++++-- ffplayout/output/live_switch.py | 20 ++++++++++++++------ ffplayout/utils.py | 3 +-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ffplayout.yml b/ffplayout.yml index d9e938ea..953a3da5 100644 --- a/ffplayout.yml +++ b/ffplayout.yml @@ -61,8 +61,10 @@ ingest: helptext: Works only in combination with output -> mode = live_switch! Run a rtmp server for a ingest stream. This stream will override the normal streaming until is done. There is no authentication, this is up to you. The recommend way is to set address to localhost, stream to a local server with authentication and from there stream to this app. - address: localhost - port: 1936 + stream_input: >- + -f live_flv + -listen 1 + -i rtmp://localhost:1936/live/stream playlist: helptext: Set 'playlist_mode' to 'False' if you want to play clips from the 'storage' diff --git a/ffplayout/output/live_switch.py b/ffplayout/output/live_switch.py index 38b3b581..23a9bc64 100644 --- a/ffplayout/output/live_switch.py +++ b/ffplayout/output/live_switch.py @@ -22,6 +22,7 @@ from subprocess import PIPE, Popen from threading import Thread from time import sleep +from ..filters.default import overlay_filter from ..folder import GetSourceFromFolder, MediaStore, MediaWatcher from ..playlist import GetSourceFromPlaylist from ..utils import (ff_proc, ffmpeg_stderr_reader, get_date, get_time, ingest, @@ -32,13 +33,20 @@ COPY_BUFSIZE = 1024 * 1024 if system() == 'Windows' else 65424 def rtmp_server(que, pre_settings): - server_cmd = [ - 'ffmpeg', '-hide_banner', '-nostats', '-v', 'level+error', - '-f', 'live_flv', '-listen', '1', - '-i', f'rtmp://{ingest.address}:{ingest.port}/live/stream'] + pre_settings + filter_ = (f'[0:v]fps={str(pre.fps)},scale={pre.w}:{pre.h},' + + f'setdar=dar={pre.aspect}[v];') + filter_ += overlay_filter(0, False, False, False) - messenger.warning('Ingest stream is experimental, use it at your own risk!') - messenger.info(f'Start listening on "{ingest.address}:{ingest.port}"') + server_cmd = [ + 'ffmpeg', '-hide_banner', '-nostats', '-v', 'level+error' + ] + ingest.stream_input + [ + '-filter_complex', f'{filter_}[vout1]', + '-map', '[vout1]', '-map', '0:a' + ] + pre_settings + + messenger.warning( + 'Ingest stream is experimental, use it at your own risk!') + messenger.debug(f'Server CMD: "{" ".join(server_cmd)}"') while True: with Popen(server_cmd, stderr=PIPE, stdout=PIPE) as ff_proc.live: diff --git a/ffplayout/utils.py b/ffplayout/utils.py index 6a1b3b04..6d7ea699 100644 --- a/ffplayout/utils.py +++ b/ffplayout/utils.py @@ -273,8 +273,7 @@ pre.v_bitrate = _cfg['processing']['width'] * _cfg['processing']['height'] / 10 pre.v_bufsize = pre.v_bitrate / 2 pre.output_count = _cfg['processing']['output_count'] -ingest.address = _cfg['ingest']['address'] -ingest.port = _cfg['ingest']['port'] +ingest.stream_input = shlex.split(_cfg['ingest']['stream_input']) playout.mode = _cfg['out']['mode'] playout.name = _cfg['out']['service_name']