Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue while getting streams on aws ec2 instance #213

Open
sanajavaidraja opened this issue Jun 13, 2023 · 1 comment
Open

Issue while getting streams on aws ec2 instance #213

sanajavaidraja opened this issue Jun 13, 2023 · 1 comment
Labels
question Further information is requested

Comments

@sanajavaidraja
Copy link

I want to display 2 rtsp camera streams simantaniously on a page .I can successfully streams these camera on my local but unable to get these streams on aws ec2 instance.I also enable 2000 port on aws scurity groups:

here is my react code:
import React, { useRef, useEffect } from 'react';
import { loadPlayer } from 'rtsp-relay/browser';

const App = () => {
const canvasRefs = useRef([]);

useEffect(() => {
const streamUrls = [
'ws://localhost:2000/api/stream/0',
'ws://localhost:2000/api/stream/1',

];

streamUrls.forEach((url, index) => {
  const playerOptions = {
    url,
    canvas: canvasRefs.current[index],
  };
  loadPlayer(playerOptions);
});

}, []);

const numCanvases = 2; // Set the desired number of canvas elements

// Generate the array of canvas elements
const canvases = Array.from({ length: numCanvases }, (_, index) => (
<canvas
key={canvas-${index}}
id={canvas-${index}}
ref={(el) => (canvasRefs.current[index] = el)}
style={{ height: '400px', width: '400px', objectFit: 'contain' }}

></canvas>

));

return <div style={{ display: 'flex' }}>{canvases};
};

export default App;

and here is code in express js:
const express = require('express');
const app = express();
const path = require("path");

const { proxy, scriptUrl } = require('rtsp-relay')(app);

const urls = [
"rtsp://adm...",
"rtsp://adm...",
];

let i = 0;
for (const url of urls) {
const handler = proxy({
url: url,
verbose: false,
transport: 'tcp'
});

app.ws('/api/stream/' + i, handler);
i++;
}

app.use(express.static(path.join(__dirname, "client/build")));
app.get('/*', function(req, res) {
res.sendFile(path.join(__dirname, 'client/build', 'index.html'));
});

app.listen(2000, () => {
console.log('Express server listening on port 2000');
});

@k-yle k-yle added the question Further information is requested label Jun 13, 2023
@tobitoi
Copy link

tobitoi commented Jul 28, 2023

make

make sure your ip camera have ip public or vpn to connect to local ip camera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants