types: make streamVideoOnly more readable

This commit is contained in:
wukko 2023-11-06 06:53:54 +06:00 committed by dumbmoron
parent b662f472dd
commit 4a9e4cd915
No known key found for this signature in database
GPG key ID: C59997C76C6A8E5F

View file

@ -90,6 +90,7 @@ export async function streamLiveRender(streamInfo, res) {
'pipe', 'pipe'
],
});
const [,,, audioInput, muxOutput] = process.stdio;
res.setHeader('Connection', 'keep-alive');
@ -140,7 +141,9 @@ export function streamAudioOnly(streamInfo, res) {
'pipe'
],
});
const [,,, muxOutput] = process.stdio;
res.setHeader('Connection', 'keep-alive');
res.setHeader('Content-Disposition', contentDisposition(`${streamInfo.filename}.${streamInfo.audioFormat}`));
@ -156,7 +159,7 @@ export function streamVideoOnly(streamInfo, res) {
const shutdown = () => (killProcess(process), closeResponse(res));
try {
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
let args = [
'-loglevel', '-8',
'-threads', `${getThreads()}`,
'-i', streamInfo.urls,
@ -164,8 +167,11 @@ export function streamVideoOnly(streamInfo, res) {
]
if (streamInfo.mute) args.push('-an');
if (streamInfo.service === "vimeo" || streamInfo.service === "rutube") args.push('-bsf:a', 'aac_adtstoasc');
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1];
if (format === "mp4") args.push('-movflags', 'faststart+frag_keyframe+empty_moov');
args.push('-f', format, 'pipe:3');
process = spawn(ffmpeg, args, {
windowsHide: true,
stdio: [
@ -173,7 +179,9 @@ export function streamVideoOnly(streamInfo, res) {
'pipe'
],
});
const [,,, muxOutput] = process.stdio;
res.setHeader('Connection', 'keep-alive');
res.setHeader('Content-Disposition', contentDisposition(streamInfo.filename));