api/stream/types: add subtitles & metadata to remux

This commit is contained in:
wukko 2025-06-20 18:16:32 +06:00
parent 254ad961d3
commit a5838f3c05
No known key found for this signature in database
GPG Key ID: 3E30B3F26C7B4AA2

View File

@ -189,6 +189,8 @@ const remux = async (streamInfo, res) => {
); );
try { try {
const format = streamInfo.filename.split('.').pop();
let args = [ let args = [
'-loglevel', '-8', '-loglevel', '-8',
'-headers', toRawHeaders(getHeaders(streamInfo.service)), '-headers', toRawHeaders(getHeaders(streamInfo.service)),
@ -198,10 +200,16 @@ const remux = async (streamInfo, res) => {
args.push('-seekable', '0') args.push('-seekable', '0')
} }
args.push( args.push('-i', streamInfo.urls);
'-i', streamInfo.urls,
'-c:v', 'copy', if (streamInfo.subtitles) {
) args.push(
'-i', streamInfo.subtitles,
'-c:s', format === 'mp4' ? 'mov_text' : 'webvtt',
);
};
args.push('-c:v', 'copy');
if (streamInfo.type === "mute") { if (streamInfo.type === "mute") {
args.push('-an'); args.push('-an');
@ -214,11 +222,14 @@ const remux = async (streamInfo, res) => {
args.push('-bsf:a', 'aac_adtstoasc'); args.push('-bsf:a', 'aac_adtstoasc');
} }
let format = streamInfo.filename.split('.').pop();
if (format === "mp4") { if (format === "mp4") {
args.push('-movflags', 'faststart+frag_keyframe+empty_moov') args.push('-movflags', 'faststart+frag_keyframe+empty_moov')
} }
if (streamInfo.metadata) {
args = args.concat(convertMetadataToFFmpeg(streamInfo.metadata));
}
args.push('-f', format, 'pipe:3'); args.push('-f', format, 'pipe:3');
process = spawn(...getCommand(args), { process = spawn(...getCommand(args), {