Marc
Marc

Reputation: 3924

node.js open additional pipes besides stdin/stdout/stderr

I found a question on here where additional pipes between node.js & ffmpeg are used (pipe4 & 5):

let vid = ytdl(ytvideoUrl, {filter: format => format.qualityLabel === '144p'})
let aud = ytdl(ytvideoUrl, { quality: 'lowestaudio' })

const ffmpegProcess = cp.spawn(ffmpeg, [
    '-loglevel', '8', '-hide_banner',
    '-progress', 'pipe:3',
    '-i', 'pipe:4',
    '-i', 'pipe:5',
    '-map', '0:a',
    '-map', '1:v',
    '-c:v', 'copy',
    `videoTitle.mp4`,
  ], {
    windowsHide: true,
    stdio: [
      'inherit', 'inherit', 'inherit',
      'pipe', 'pipe', 'pipe',
    ],
  })
ffmpegProcess.on('close', () => {
console.log("Merging Completed");
})
  
aud.pipe(ffmpegProcess.stdio[4]);
vid.pipe(ffmpegProcess.stdio[5]);

Merge Video and Audio using ffmpeg in Express Js

I wonder if and how its possible to tell node.js to open additional pipes so i can read&write to them like ffmpeg.

Pseudo code example:

// additional stream besides stdin/stdout/stderr
process.stdio[3].on("data", (chunk) => {
  console.log(chunk); // message from external process
});

process.stdio[4].write("To external process");

Upvotes: 1

Views: 107

Answers (0)

Related Questions