rollback of previous commit + done some changes to piping
This commit is contained in:
parent
34b3c11bd5
commit
364ee37b83
2 changed files with 14 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "cobalt",
|
"name": "cobalt",
|
||||||
"description": "save what you love",
|
"description": "save what you love",
|
||||||
"version": "4.2",
|
"version": "4.2.1",
|
||||||
"author": "wukko",
|
"author": "wukko",
|
||||||
"exports": "./src/cobalt.js",
|
"exports": "./src/cobalt.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|
|
@ -28,23 +28,24 @@ export function streamLiveRender(streamInfo, res) {
|
||||||
if (streamInfo.urls.length === 2) {
|
if (streamInfo.urls.length === 2) {
|
||||||
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
|
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
|
||||||
'-loglevel', '-8',
|
'-loglevel', '-8',
|
||||||
'-i', streamInfo.urls[1],
|
|
||||||
'-i', streamInfo.urls[0],
|
'-i', streamInfo.urls[0],
|
||||||
'-map', '0:a',
|
'-i', streamInfo.urls[1],
|
||||||
'-map', '1:v',
|
'-map', '0:v',
|
||||||
|
'-map', '1:a',
|
||||||
];
|
];
|
||||||
args = args.concat(ffmpegArgs[format])
|
args = args.concat(ffmpegArgs[format])
|
||||||
if (streamInfo.time) args.push('-t', msToTime(streamInfo.time));
|
if (streamInfo.time) args.push('-t', msToTime(streamInfo.time));
|
||||||
args.push('-f', format, 'pipe:4');
|
args.push('-f', format, 'pipe:3');
|
||||||
const ffmpegProcess = spawn(ffmpeg, args, {
|
const ffmpegProcess = spawn(ffmpeg, args, {
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
stdio: [
|
stdio: [
|
||||||
'inherit', 'inherit', 'inherit',
|
'inherit', 'inherit', 'inherit',
|
||||||
'pipe', 'pipe',
|
'pipe'
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
res.setHeader('Connection', 'keep-alive');
|
||||||
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}"`);
|
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}"`);
|
||||||
ffmpegProcess.stdio[4].pipe(res);
|
ffmpegProcess.stdio[3].pipe(res);
|
||||||
|
|
||||||
ffmpegProcess.on('error', (err) => {
|
ffmpegProcess.on('error', (err) => {
|
||||||
ffmpegProcess.kill();
|
ffmpegProcess.kill();
|
||||||
|
@ -75,21 +76,22 @@ export function streamAudioOnly(streamInfo, res) {
|
||||||
args = args.concat(arg)
|
args = args.concat(arg)
|
||||||
if (streamInfo.metadata.cover) args.push("-c:v", "mjpeg")
|
if (streamInfo.metadata.cover) args.push("-c:v", "mjpeg")
|
||||||
if (ffmpegArgs[streamInfo.audioFormat]) args = args.concat(ffmpegArgs[streamInfo.audioFormat]);
|
if (ffmpegArgs[streamInfo.audioFormat]) args = args.concat(ffmpegArgs[streamInfo.audioFormat]);
|
||||||
args.push('-f', streamInfo.audioFormat === "m4a" ? "ipod" : streamInfo.audioFormat, 'pipe:4');
|
args.push('-f', streamInfo.audioFormat === "m4a" ? "ipod" : streamInfo.audioFormat, 'pipe:3');
|
||||||
const ffmpegProcess = spawn(ffmpeg, args, {
|
const ffmpegProcess = spawn(ffmpeg, args, {
|
||||||
windowsHide: true,
|
windowsHide: true,
|
||||||
stdio: [
|
stdio: [
|
||||||
'inherit', 'inherit', 'inherit',
|
'inherit', 'inherit', 'inherit',
|
||||||
'pipe', 'pipe'
|
'pipe'
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
res.setHeader('Connection', 'keep-alive');
|
||||||
|
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}.${streamInfo.audioFormat}"`);
|
||||||
|
ffmpegProcess.stdio[3].pipe(res);
|
||||||
|
|
||||||
ffmpegProcess.on('error', (err) => {
|
ffmpegProcess.on('error', (err) => {
|
||||||
ffmpegProcess.kill();
|
ffmpegProcess.kill();
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}.${streamInfo.audioFormat}"`);
|
|
||||||
ffmpegProcess.stdio[4].pipe(res);
|
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue