From a5838f3c05a3392a31c939c12f647739ef2a5544 Mon Sep 17 00:00:00 2001 From: wukko Date: Fri, 20 Jun 2025 18:16:32 +0600 Subject: [PATCH] api/stream/types: add subtitles & metadata to remux --- api/src/stream/types.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/api/src/stream/types.js b/api/src/stream/types.js index 0c71ae2d..7b5a5774 100644 --- a/api/src/stream/types.js +++ b/api/src/stream/types.js @@ -189,6 +189,8 @@ const remux = async (streamInfo, res) => { ); try { + const format = streamInfo.filename.split('.').pop(); + let args = [ '-loglevel', '-8', '-headers', toRawHeaders(getHeaders(streamInfo.service)), @@ -198,10 +200,16 @@ const remux = async (streamInfo, res) => { args.push('-seekable', '0') } - args.push( - '-i', streamInfo.urls, - '-c:v', 'copy', - ) + args.push('-i', streamInfo.urls); + + if (streamInfo.subtitles) { + args.push( + '-i', streamInfo.subtitles, + '-c:s', format === 'mp4' ? 'mov_text' : 'webvtt', + ); + }; + + args.push('-c:v', 'copy'); if (streamInfo.type === "mute") { args.push('-an'); @@ -214,11 +222,14 @@ const remux = async (streamInfo, res) => { args.push('-bsf:a', 'aac_adtstoasc'); } - let format = streamInfo.filename.split('.').pop(); if (format === "mp4") { args.push('-movflags', 'faststart+frag_keyframe+empty_moov') } + if (streamInfo.metadata) { + args = args.concat(convertMetadataToFFmpeg(streamInfo.metadata)); + } + args.push('-f', format, 'pipe:3'); process = spawn(...getCommand(args), {