beginning of 2.2
- added download popup to solve the issue with downloads on ios - merged big and small popups into one - made buttons in donation menu act like buttons - began to clean up localisation - added ability to embed repo url into localisation strings - moved ffmpeg args to config for more flexibility (and hopefully future changes) - removed error response in stream that could result in a crash - removed notice for ios users from about cause it's no longer relevant - made error popup look and act like the rest - a tiny bit of clean up - ill do better changelog tomorrow i think
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { spawn } from "child_process";
|
||||
import ffmpeg from "ffmpeg-static";
|
||||
import got from "got";
|
||||
import { genericUserAgent } from "../config.js";
|
||||
import { ffmpegArgs, genericUserAgent } from "../config.js";
|
||||
import { msToTime } from "../sub/api-helper.js";
|
||||
import { internalError } from "../sub/errors.js";
|
||||
import loc from "../sub/loc.js";
|
||||
@@ -16,11 +16,9 @@ export async function streamDefault(streamInfo, res) {
|
||||
isStream: true
|
||||
});
|
||||
stream.pipe(res).on('error', (err) => {
|
||||
internalError(res);
|
||||
throw Error("File stream pipe error.");
|
||||
});
|
||||
stream.on('error', (err) => {
|
||||
internalError(res);
|
||||
throw Error("File stream error.")
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -42,18 +40,9 @@ export async function streamLiveRender(streamInfo, res) {
|
||||
'-i', 'pipe:4',
|
||||
'-map', '0:v',
|
||||
'-map', '1:a',
|
||||
'-c:v', 'copy',
|
||||
'-c:a', 'copy',
|
||||
];
|
||||
if (format == 'mp4') {
|
||||
args.push('-movflags', 'frag_keyframe+empty_moov');
|
||||
if (streamInfo.service == "youtube") {
|
||||
args.push('-t', msToTime(streamInfo.time));
|
||||
}
|
||||
} else if (format == 'webm') {
|
||||
args.push('-t', msToTime(streamInfo.time));
|
||||
}
|
||||
args.push('-f', format, 'pipe:5');
|
||||
args = args.concat(ffmpegArgs[format])
|
||||
args.push('-t', msToTime(streamInfo.time), '-f', format, 'pipe:5');
|
||||
const ffmpegProcess = spawn(ffmpeg, args, {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
@@ -63,25 +52,20 @@ export async function streamLiveRender(streamInfo, res) {
|
||||
});
|
||||
ffmpegProcess.on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
audio.on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
video.on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}"`);
|
||||
ffmpegProcess.stdio[5].pipe(res);
|
||||
video.pipe(ffmpegProcess.stdio[3]).on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
audio.pipe(ffmpegProcess.stdio[4]).on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
} else {
|
||||
res.status(400).json({ status: "error", text: loc('en', 'apiError', 'corruptedVideo') });
|
||||
@@ -113,17 +97,14 @@ export async function streamAudioOnly(streamInfo, res) {
|
||||
});
|
||||
ffmpegProcess.on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
audio.on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
res.setHeader('Content-Disposition', `attachment; filename="${streamInfo.filename}"`);
|
||||
ffmpegProcess.stdio[4].pipe(res);
|
||||
audio.pipe(ffmpegProcess.stdio[3]).on('error', (err) => {
|
||||
ffmpegProcess.kill();
|
||||
internalError(res);
|
||||
});
|
||||
} catch (e) {
|
||||
internalError(res);
|
||||
|
||||
Reference in New Issue
Block a user