From 44cc3213ca780bf274818b69c4b1999edbe8d165 Mon Sep 17 00:00:00 2001 From: knotteye Date: Mon, 12 Oct 2020 11:14:59 -0500 Subject: [PATCH] Tweak config changes, add functionality in server.ts Still needs an API and a UI, then good to go. --- install/config.example.yml | 6 +++++- src/config.ts | 3 ++- src/server.ts | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/install/config.example.yml b/install/config.example.yml index fe66753..c67d16b 100644 --- a/install/config.example.yml +++ b/install/config.example.yml @@ -60,4 +60,8 @@ chat: twitch_mirror: # enable to allow users to mirror video streams to twitch - enabled: false \ No newline at end of file +# for those with truly no bandwidth limits + enabled: false + # https://stream.twitch.tv/ingests/ + # do not include {stream_key} + ingest: 'rtmp://live-ord02.twitch.tv/app/ \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index d118a25..4bd6ec0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -83,7 +83,8 @@ const config: Object = { }, localconfig['chat']['twitch']) }, twitch_mirror: Object.assign({ - enabled: false + enabled: false, + ingest: null }, localconfig['twitch_mirror']) }; export { config }; \ No newline at end of file diff --git a/src/server.ts b/src/server.ts index dd58ee5..fcd409d 100644 --- a/src/server.ts +++ b/src/server.ts @@ -68,6 +68,15 @@ function init () { console.log('[NodeMediaServer] Skipping recording for stream:',id); } db.query('update user_meta set live=true where username=\''+results[0].username+'\' limit 1'); + db.query('SELECT twitch_key,enabled from twitch_mirror where username='+db.raw.escape(results[0].username)+' limit 1').then(async (tm) => { + if(!tm[0]['enabled'] || !config['twitch_mirror']['enabled'] || !config['twitch_mirror']['ingest']) return; + else + execFile(config['media']['ffmpeg'], ['-loglevel', 'fatal', '-i', 'rtmp://127.0.0.1:'+config['rtmp']['port']+'/'+config['media']['privateEndpoint']+'/'+key, '-vcodec', 'libx264', '-acodec', 'libaac', '-f', 'flv', config['twitch_mirror']['ingest']+tm[0]['twitch_key']], { + detached: true, + stdio : 'inherit', + maxBuffer: Infinity + }).unref(); + }); console.log('[NodeMediaServer] Stream key ok for stream:',id); } else{