You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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';
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',
}, []);
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' }}
));
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');
});
The text was updated successfully, but these errors were encountered: