kyriesent / node-rtsp-stream

Stream any RTSP stream and output to websocket for consumption by jsmpeg (https://github.com/phoboslab/jsmpeg). HTML5 streaming video! Requires ffmpeg.
MIT License
451 stars 166 forks source link

'RTSP stream exited with error' when trying to use rtsp via public ip #74

Closed EverlyScott closed 8 months ago

EverlyScott commented 3 years ago

I'm trying to allow my app to view an rtsp stream through my public ip instead of locally. My current code is:

const Stream = require('node-rtsp-stream')

createStream('rtsp://my.public.ip.address:51/cam1/mpeg4', 9991)

function createStream(url, port, fps = 25) {
  const camera = new Stream({
    name: "Camera",
    streamUrl: url,
    wsPort: port,
    ffmpegOptions: {
      '-r': fps
    }
  })
}

and when running that, I get the following error:

[rtsp @ 0x5597a2917300] UDP timeout, retrying with TCP
[rtsp @ 0x5597a2917300] Nonmatching transport in server reply
[rtsp @ 0x5597a2917300] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, rtsp, from 'rtsp://my.public.ip.address:51/cam1/mpeg4':
  Metadata:
    title           : mpeg4
    comment         : mpeg4
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: h264, none, 90k tbr, 90k tbn, 180k tbc
Output #0, mpegts, to 'pipe:':
Output file #0 does not contain any stream
RTSP stream exited with error

When entering the same URL into VLC Player on the same computer, it plays just fine, also using the local ip address (rtsp://192.168.1.51/cam1/mpeg4) works fine

EverlyScott commented 3 years ago

This seems like an issue with ffmpeg. Modifying the node-rtsp-stream code to console log the args and then running ffmpeg with those args produces the same issue.

AlejandroAguilar99 commented 8 months ago

Hey, did you find a solution for this? I can get my app to stream a video

EverlyScott commented 8 months ago

I think I did but I don't remember. I might still have the source code for the app I can check in a bit.

EverlyScott commented 8 months ago

@AlejandroAguilar99 This is my function for creating the stream. It's a little different than the one I provided when I made the issue so it could be something that fixed it, I'm not sure...

function createStream(url, port, fps = 25) {
  var options

  if (platform.isWin()) {
    options = {
      name: "Camera Viewer",
      streamUrl: url,
      wsPort: port,
      ffmpegPath: `${__dirname}\\..\\..\\bin\\ffmpeg.exe`,
      ffmpegOptions: {
        '-r': fps,
        '-fflags': 'discardcorrupt'
      }
    }
  } else if (platform.isMac()) {
    options = {
      name: "Camera Viewer",
      streamUrl: url,
      wsPort: port,
      ffmpegPath: `${__dirname}/../../bin/ffmpeg-osx`,
      ffmpegOptions: {
        '-r': fps
      }
    }
  } else if (platform.isLinux()) {
    options = {
      name: "Camera Viewer",
      streamUrl: url,
      wsPort: port,
      ffmpegPath: `${__dirname}/../../bin/ffmpeg-lin`,
      ffmpegOptions: {
        '-r': fps
      }
    }
  } else if (platform.isOther()) {
    console.log('YOUR PLATFORM IS NOT SUPPORTED!')
    process.exit()
  }

  const camera = new Stream(options)
}
AlejandroAguilar99 commented 8 months ago

@EverlyScott thanks a lot man, i'll check it out

EverlyScott commented 8 months ago

Yeah of course

EverlyScott commented 8 months ago

I'm gonna close this bc it's solved for me at least

tuanth89 commented 6 months ago

ffmpegPath:${__dirname}/../../bin/ffmpeg-lin, @EverlyScott Could you send me this library ? I get problem when run on Ubuntu 20.04. It's works on Windows

EverlyScott commented 6 months ago

i don't actually have the library anymore but from what i can remember it was just downloaded from the ffmpeg website