error enoent when assigning path to ffmpeg

Viewed 11

I am trying to set up a relay from my rtmp server and I'm using an npm module called node-media-server. I have set up my rtmp protocol successfully but when I am trying to set up the relay it expects me to add a path my my ffmpeg library so i npm installed ffmpeg then supplied the node_module path to the relay but I keep on getting error uncaughtException Error: spawn C:\blah\blah\node_modules\ffmpeg ENOENT the ffmpeg library definitely exist at the specified location. Why is this happening? Thanks in advance.

Link to the module im using: https://www.npmjs.com/package/node-media-server

const NodeMediaServer = require('node-media-server');
const path = require('path')
const ffmpegPath = path.join(__dirname, '..', 'node_modules', 'ffmpeg')

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  },
  relay: {
    ffmpeg: ffmpegPath,
    tasks: [{
        app: 'live',
        mode: 'push',
        edge: 'rtmp://localhost:1936',
      },
      {
        app: 'live',
        mode: 'push',
        edge: 'rtmp://localhost:1937',
      }
    ]
  }
};

var nms = new NodeMediaServer(config)
nms.run();

1 Answers

It seems like the rtmp server is not finding a ffmpeg installation. I had to install node-ffmpeg-installer, a package that installs ffmpeg as a node-module. Then I just assigned ffmpeg.path to ffmpeg key in the relay config. Hope this helps.

const NodeMediaServer = require('node-media-server');
const ffmpeg = require('@ffmpeg-installer/ffmpeg');

const config = {
  rtmp: {
    port: 1935,
    chunk_size: 60000,
    gop_cache: true,
    ping: 30,
    ping_timeout: 60
  },
  http: {
    port: 8000,
    allow_origin: '*'
  },
  relay: {
    ffmpeg: ffmpeg.path,
    tasks: [{
        app: 'live',
        mode: 'push',
        edge: 'rtmp://localhost:1936',
      },
      {
        app: 'live',
        mode: 'push',
        edge: 'rtmp://localhost:1937',
      }
    ]
  }
};

var nms = new NodeMediaServer(config)
nms.run();

Related