types: add processing priority
merge pull request #331 from wukko/processing-priority
This commit is contained in:
commit
00ef8cd288
1 changed files with 11 additions and 4 deletions
|
@ -35,6 +35,13 @@ function pipe(from, to, done) {
|
|||
from.pipe(to);
|
||||
}
|
||||
|
||||
function getCommand(args) {
|
||||
if (process.env.PROCESSING_PRIORITY && process.platform !== "win32") {
|
||||
return ['nice', ['-n', process.env.PROCESSING_PRIORITY, ffmpeg, ...args]]
|
||||
}
|
||||
return [ffmpeg, args]
|
||||
}
|
||||
|
||||
export async function streamDefault(streamInfo, res) {
|
||||
const abortController = new AbortController();
|
||||
const shutdown = () => (closeRequest(abortController), closeResponse(res));
|
||||
|
@ -91,7 +98,7 @@ export async function streamLiveRender(streamInfo, res) {
|
|||
}
|
||||
args.push('-f', format, 'pipe:4');
|
||||
|
||||
process = spawn(ffmpeg, args, {
|
||||
process = spawn(...getCommand(args), {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
'inherit', 'inherit', 'inherit',
|
||||
|
@ -143,7 +150,7 @@ export function streamAudioOnly(streamInfo, res) {
|
|||
}
|
||||
args.push('-f', streamInfo.audioFormat === "m4a" ? "ipod" : streamInfo.audioFormat, 'pipe:3');
|
||||
|
||||
process = spawn(ffmpeg, args, {
|
||||
process = spawn(...getCommand(args), {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
'inherit', 'inherit', 'inherit',
|
||||
|
@ -191,7 +198,7 @@ export function streamVideoOnly(streamInfo, res) {
|
|||
}
|
||||
args.push('-f', format, 'pipe:3');
|
||||
|
||||
process = spawn(ffmpeg, args, {
|
||||
process = spawn(...getCommand(args), {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
'inherit', 'inherit', 'inherit',
|
||||
|
@ -228,7 +235,7 @@ export function convertToGif(streamInfo, res) {
|
|||
args = args.concat(ffmpegArgs["gif"]);
|
||||
args.push('-f', "gif", 'pipe:3');
|
||||
|
||||
process = spawn(ffmpeg, args, {
|
||||
process = spawn(...getCommand(args), {
|
||||
windowsHide: true,
|
||||
stdio: [
|
||||
'inherit', 'inherit', 'inherit',
|
||||
|
|
Loading…
Reference in a new issue