Error happened: 'spawn ffmpeg ENOENT', Node.js & FFmpeg

Viewed 1147

I'm really struggling to get ffmpeg working to read .webm data from a file and write that data to a .pcm file. I have ffmpeg at the file location and have made it executable with the sudo chmod +x ffmpeg command.

Does anyone have any idea how I can fix this? Thank you in advance!

       const ffmpeg = require('fluent-ffmpeg')
       const ffmpegPath = 'C:\\usr\\local\\bin\\ffmpeg.exe'
       ffmpeg.setFfmpegPath(ffmpegPath)

      // Now read from the test-video .webm file
        const inputFile = 'test-video.webm'
        var inputStream = fs.createReadStream(inputFile)
        inputStream.on('error', function(error) {
            console.log(`\tError with reading from input stream: ${error}`)
        })

        // And write that data to the .pcm audio file
        var outputFileName = 'test-extracted-audio.pcm'
        var outputStream = fs.createWriteStream(outputFileName)

        var ffmpeg = child_process.spawn('ffmpeg', ['-y', '-i', '-vn', '-ac', '1', '-ar', '16000', 'pcm_s16le'])
        inputStream.pipe(ffmpeg.stdin)
        ffmpeg.stdout.pipe(outputStream)

        ffmpeg.stderr.on('data', function (data) {
            // console.log(data.toString())
            console.log(`DATA FROM FFMPEG: ${data}`)
        })

        ffmpeg.stderr.on('end', function () {
            console.log('\tWebm -> PCM File has been converted succesfully')
        })
        
        ffmpeg.stderr.on('exit', function () {
            console.log('\tFFMPEG child process exited')
        })
        
        ffmpeg.stderr.on('close', function() {
            console.log('\t...Closing time! Bye')
        })

0 Answers
Related