From 44b33b7bcc27ba1d48942a1f5d2541d7afcdf1bb Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 21 Mar 2022 20:51:36 +0100 Subject: [PATCH] revert to string instead of list --- ffplayout.yml | 64 +++++++++++++++++++------------------- ffplayout/ingest_server.py | 2 +- ffplayout/output/hls.py | 2 +- ffplayout/output/null.py | 2 +- ffplayout/output/stream.py | 2 +- ffplayout/utils.py | 20 ++++++------ 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/ffplayout.yml b/ffplayout.yml index 8e74470c..a01fdcb2 100644 --- a/ffplayout.yml +++ b/ffplayout.yml @@ -64,7 +64,7 @@ ingest: 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. enable: false - stream_input: [-f, live_flv, -listen, 1, -i, rtmp://localhost:1936/live/stream] + input_param: -f live_flv -listen 1 -i rtmp://localhost:1936/live/stream playlist: helptext: > @@ -115,34 +115,34 @@ out: inside. 'preview' works only in streaming output and creates a separate preview stream. mode: 'stream' preview: false - preview_param: - [-s, 512x288, - -c:v, libx264, - -crf, 24, - -x264-params, keyint=50:min-keyint=25:scenecut=-1, - -maxrate, 800k, - -bufsize, 1600k, - -preset, ultrafast, - -tune, zerolatency, - -profile:v, Main, - -level, 3.1, - -c:a, aac, - -ar, 44100, - -b:a, 128k, - -flags, +global_header, - -f, flv, rtmp://preview.local/live/stream] - stream_param: - [-c:v, libx264, - -crf, 23, - -x264-params, keyint=50:min-keyint=25:scenecut=-1, - -maxrate, 1300k, - -bufsize, 2600k, - -preset, faster, - -tune, zerolatency, - -profile:v, Main, - -level, 3.1, - -c:a, aac, - -ar, 44100, - -b:a, 128k, - -flags, +global_header, - -f, flv, rtmp://localhost/live/stream] + preview_param: >- + -s 512x288 + -c:v libx264 + -crf 24 + -x264-params keyint=50:min-keyint=25:scenecut=-1 + -maxrate 800k + -bufsize 1600k + -preset ultrafast + -tune zerolatency + -profile:v Main + -level 3.1 + -c:a aac + -ar 44100 + -b:a 128k + -flags +global_header + -f flv rtmp://preview.local/live/stream + output_param: >- + -c:v libx264 + -crf 23 + -x264-params keyint=50:min-keyint=25:scenecut=-1 + -maxrate 1300k + -bufsize 2600k + -preset faster + -tune zerolatency + -profile:v Main + -level 3.1 + -c:a aac + -ar 44100 + -b:a 128k + -flags +global_header + -f flv rtmp://localhost/live/stream diff --git a/ffplayout/ingest_server.py b/ffplayout/ingest_server.py index ad083bbb..bc181bca 100644 --- a/ffplayout/ingest_server.py +++ b/ffplayout/ingest_server.py @@ -36,7 +36,7 @@ def listener(que): server_cmd = [ 'ffmpeg', '-hide_banner', '-nostats', '-v', 'level+error' - ] + ingest.stream_input + [ + ] + ingest.input_param + [ '-filter_complex', f'{filter_}[vout1]', '-map', '[vout1]', '-map', '0:a' ] + pre.settings diff --git a/ffplayout/output/hls.py b/ffplayout/output/hls.py index 1d1d8197..2f676f0a 100644 --- a/ffplayout/output/hls.py +++ b/ffplayout/output/hls.py @@ -87,7 +87,7 @@ def output(): cmd = [ 'ffmpeg', '-v', f'level+{log.ff_level}', '-hide_banner', '-nostats' - ] + node['src_cmd'] + node['filter'] + playout.stream_param + ] + node['src_cmd'] + node['filter'] + playout.output_param messenger.debug(f'Encoder CMD: "{" ".join(cmd)}"') diff --git a/ffplayout/output/null.py b/ffplayout/output/null.py index e3dcbf50..233d7c89 100644 --- a/ffplayout/output/null.py +++ b/ffplayout/output/null.py @@ -45,7 +45,7 @@ def output(): enc_cmd = [ 'ffmpeg', '-v', f'level+{log.ff_level}', '-hide_banner', '-nostats', '-re', '-thread_queue_size', '160', '-i', 'pipe:0' - ] + playout.stream_param[:-3] + ['-f', 'null', '-'] + ] + playout.output_param[:-3] + ['-f', 'null', '-'] messenger.debug(f'Encoder CMD: "{" ".join(enc_cmd)}"') diff --git a/ffplayout/output/stream.py b/ffplayout/output/stream.py index 9840c14f..8f2d21de 100644 --- a/ffplayout/output/stream.py +++ b/ffplayout/output/stream.py @@ -66,7 +66,7 @@ def output(): enc_cmd = [ 'ffmpeg', '-v', f'level+{log.ff_level}', '-hide_banner', '-nostats', '-re', '-thread_queue_size', '160', '-i', 'pipe:0' - ] + filtering + preview + playout.stream_param + ] + filtering + preview + playout.output_param messenger.debug(f'Encoder CMD: "{" ".join(enc_cmd)}"') diff --git a/ffplayout/utils.py b/ffplayout/utils.py index 0c343bd6..0bef4e1b 100644 --- a/ffplayout/utils.py +++ b/ffplayout/utils.py @@ -23,6 +23,7 @@ import json import logging import math import re +import shlex import signal import smtplib import socket @@ -258,9 +259,9 @@ if playlist.start is None: playlist.start = get_time('full_sec') if stdin_args.length: - playlist.length = str_to_sec(stdin_args.length) + playlist.length = str_to_sec(stdin_args.length) else: - playlist.length = str_to_sec(_cfg['playlist']['length']) + playlist.length = str_to_sec(_cfg['playlist']['length']) if stdin_args.loop: playlist.loop = stdin_args.loop @@ -287,7 +288,7 @@ def pre_audio_codec(): ingest.enable = _cfg['ingest']['enable'] -ingest.stream_input = [str(e) for e in _cfg['ingest']['stream_input']] +ingest.input_param = shlex.split(_cfg['ingest']['input_param']) if stdin_args.play_mode: pre.mode = stdin_args.play_mode @@ -310,7 +311,7 @@ pre.settings = [ '-minrate', f'{pre.v_bitrate}k', '-maxrate', f'{pre.v_bitrate}k', '-bufsize', f'{pre.v_bufsize}k' - ] + pre_audio_codec() + ['-f', 'mpegts', '-'] +] + pre_audio_codec() + ['-f', 'mpegts', '-'] if stdin_args.output: playout.mode = stdin_args.output @@ -318,8 +319,8 @@ else: playout.mode = _cfg['out']['mode'] playout.preview = _cfg['out']['preview'] -playout.preview_param = [str(e) for e in _cfg['out']['preview_param']] -playout.stream_param = [str(e) for e in _cfg['out']['stream_param']] +playout.preview_param =shlex.split(_cfg['out']['preview_param']) +playout.output_param = shlex.split(_cfg['out']['output_param']) # ------------------------------------------------------------------------------ @@ -947,7 +948,7 @@ def src_or_dummy(node): f'Seek in remote source "{node.get("source")}" not supported!') node['src_cmd'] = [ '-i', node['source'] - ] + set_length(86400, node['seek'], node['out']) + ] + set_length(86400, node['seek'], node['out']) elif node.get('source') and Path(node['source']).is_file(): if probe.format.get('duration') and not math.isclose( probe.format['duration'], node['duration'], abs_tol=3): @@ -962,8 +963,8 @@ def src_or_dummy(node): f'Seek in looped source "{node["source"]}" not supported!') node['src_cmd'] = [ '-i', node['source'] - ] + set_length(node['duration'], node['seek'], - node['out'] - node['seek']) + ] + set_length(node['duration'], node['seek'], + node['out'] - node['seek']) else: # when list starts with looped clip, # the logo length will be wrong @@ -979,4 +980,3 @@ def src_or_dummy(node): node = gen_filler(node) return node -