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

Deploy on Heroku #63

Open lxtrungg opened 4 years ago

lxtrungg commented 4 years ago

Hello, I cannot deploy my stream server on Heroku, because it have issue with the ws Port. Heroku just allow one Port but I need 2 to (ws Port and Server Port) to play stream. Anyone can help me? Thank you so much!

rogeliozx commented 4 years ago

you need to create env var , let me check how they are done

lxtrungg commented 4 years ago

you need to create env var , let me check how they are done

Hello, this is basic code:

Server: `var express = require('express');

var app = express();

app.use(express.static('public'));

app.set('views', './views');

app.set('view engine', 'ejs');

var server = require('http').Server(app);

app.use('/camera1', (req, res) => res.render(camera1))

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

stream = new Stream({

name: 'Camera1',

streamUrl: 'rtsp://....',

wsPort: 4001,

ffmpegOptions: { // options ffmpeg flags

  '-stats': '', // an option with no neccessary value uses a blank string

  '-r': 30 // options with required values specify the value after the key

}

})

server.listen(process.env.PORT || 3000);`

Client: head meta(charset='UTF-8') meta(name='viewport', content='width=device-width, initial-scale=0.64') meta(http-equiv='X-UA-Compatible', content='ie=edge') title Surveillance Camera canvas#canvas(width='auto', height='auto') script(type='text/javascript', src='jsmpeg.min.js') script(type='text/javascript'). player = new JSMpeg.Player('ws://' + window.location.hostname + ':4001/', { canvas: document.getElementById('canvas'), autoplay:true, loop:true // Canvas should be a canvas DOM element })

Can you support me to deploy this project to Heroku. I'm a newbie. Thank you so much!

kyriesent commented 4 years ago

Unfortunately AFAIK Heroku only allows one port, meaning this project will only support one camera and nothing else.

You could try running two heroku apps, one for the browser and one for the camera stream.

If we end up going with a single-server model similar to #59 then that might solve this issue though.