W
W
Wasya UK2019-04-30 00:09:43
JavaScript
Wasya UK, 2019-04-30 00:09:43

How to set path in process.child?

Is it possible to run ffmpeg from a .js file if it is in the program folder? I'm trying to run, but I don't know how to specify that I need to use ffmpeg.exe. How to use __dirname + '/ffmpeg/bin/ffmpeg.exe' instead of putting ffmpeg command in $PATH for command line?

const command = spawn('ffmpeg', [
    '-f', 'gdigrab',
    '-i', 'desktop',
    // '-f', 'dshow',
    // '-i', 'video=\"screen-capture-recorder\"',
    '-preset', 'ultrafast',
    '-vcodec', 'libx264',
    '-tune', 'zerolatency',
    '-b', '900k',
    '-c:a', 'aac',
    '-ar', '44100',
    '-f', 'flv',
    'rtmp://localhost/live/STREAM_NAME'
  ]);
  
  command.stdout.on('data', (data) => {
    console.log(`stdout: ${data}`);
  });
  
  command.stderr.on('data', (data) => {
    console.log(`stderr: ${data}`);
  });
  
  command.on('close', (code) => {
    console.log(`child process exited with code ${code}`);
  });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tex0, 2019-04-30
@dmc1989

Maybe so ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question