I have a webpage up and running on localhost:5000 that I set up with node.js which is hosted by a Raspberry Pi running Raspbian OS.
I also have a USB webcam connected to the Raspberry Pi, which is working just fine after testing it with the cheese
package and correctly getting the feed.
In my webpage’s html file, I have an iframe element, which is setup like this:
<iframe src="https://localhost:5000/stream" height="200" width="300"</iframe>
My node.js server is handling the stream request of the webpage using the ffmpeg package like this:
// Handle video stream request
app.get('/stream', (req, res) => {
const ffmpeg = spawn('ffmpeg', [
'-f', 'v4l2',
'-i', '/dev/video0',
'-c:v', 'libx264',
'-preset', 'ultrafast',
'-tune', 'zerolatency',
'-f', 'flv',
'http://localhost:5000/stream'
]);
// Pipe ffmpeg output to HTTP response
ffmpeg.stdout.pipe(res);
When I start my server, I see the ffmpeg command running in the terminal and capturing frames correctly, but I have no feed in the iframe, neither at the link http://localhost:5000/stream. The browser console also displays zero errors.
What could be the problem?