make ingest input more generic, add correct filtering to server

This commit is contained in:
jb-alvarado 2022-01-24 21:34:02 +01:00
parent bf02aeaae7
commit e9f565ed60
3 changed files with 19 additions and 10 deletions

View File

@ -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'

View File

@ -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:

View File

@ -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']