0

I am trying to execute a child process command to convert a file from a format to another using FFmpeg. I have FFmpeg installed in my system and in the same code I am able to successfully merge a video and a file using cp.spawn. The next step would be to convert the file in the desired format, but the process is immediately exiting with code 1, without giving any errors or outputs.

Here's the code:

const cp = require('child_process');
const ffmpeg = require('ffmpeg-static');

const process = cp.spawn(ffmpeg, [
            '-loglevel', '8', '-hide_banner',
            '-i', 'output.webm', "output.ogg",
        ], {
            windowsHide: false,
        });

process.on('error', (err) => {
        console.log('Failed to start subprocess.', error);
    });

process.stdout.on('data', (data) => {
    console.log(`stdout: ${data}`);
  });

process.stderr.setEncoding("utf8")
process.stderr.on('data', (data) => {
    console.log(`stderr: ${data}`);
})

process.on('close', (code) => {
    console.log(`child process exited with code ${code}`);
});
    

The file "output.webm" is in the current working directory. The only output that I'm getting is: child process exited with code 1, and nothing else happens.

Daniel
  • 487
  • 4
  • 11

0 Answers0