# How to integrate mjpeg stream into node red dashboard

**URL:** https://discourse.nodered.org/t/how-to-integrate-mjpeg-stream-into-node-red-dashboard/99299
**Category:** Dashboard
**Created:** [7 October 2025 13:34 UTC](https://discourse.nodered.org/t/how-to-integrate-mjpeg-stream-into-node-red-dashboard/99299 "2025-10-07T13:34:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ali](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@ali](https://discourse.nodered.org/u/ali)
#### Post date: [7 October 2025 13:34 UTC](https://discourse.nodered.org/t/how-to-integrate-mjpeg-stream-into-node-red-dashboard/99299/1 "2025-10-07T13:34:44Z")

</div>

I am running an mjpeg stream for my pi camera 3 using the following code :

```auto
import io
import logging
import socketserver
from http import server
from threading import Condition

from picamera2 import Picamera2
from picamera2.encoders import JpegEncoder
from picamera2.outputs import FileOutput

PAGE = """\
<html>
<head>
<title>picamera2 MJPEG streaming demo</title>
</head>
<body>
<h1>Picamera2 MJPEG Streaming Demo</h1>
<img src="stream.mjpg" width="640" height="480" />
</body>
</html>
"""

class StreamingOutput(io.BufferedIOBase):
    def __init__ (self):
        self.frame = None
        self.condition = Condition()

    def write(self, buf):
        with self.condition:
            self.frame = buf
            self.condition.notify_all()

class StreamingHandler(server.BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == '/':
            self.send_response(301)
            self.send_header('Location', '/index.html')
            self.end_headers()
        elif self.path == '/index.html':
            content = PAGE.encode('utf-8')
            self.send_response(200)
            self.send_header('Content-Type', 'text/html')
            self.send_header('Content-Length', len(content))
            self.end_headers()
            self.wfile.write(content)
        elif self.path == '/stream.mjpg':
            self.send_response(200)
            self.send_header('Age', 0)
            self.send_header('Cache-Control', 'no-cache, private')
            self.send_header('Pragma', 'no-cache')
            self.send_header('Content-Type', 'multipart/x-mixed-replace; boundary=FRAME')
            self.end_headers()
            try:
                while True:
                    with output.condition:
                        output.condition.wait()
                        frame = output.frame
                    self.wfile.write(b'--FRAME\r\n')
                    self.send_header('Content-Type', 'image/jpeg')
                    self.send_header('Content-Length', len(frame))
                    self.end_headers()
                    self.wfile.write(frame)
                    self.wfile.write(b'\r\n')
            except Exception as e:
                logging.warning(
                    'Removed streaming client %s: %s',
                    self.client_address, str(e))
        else:
            self.send_error(404)
            self.end_headers()

class StreamingServer(socketserver.ThreadingMixIn, server.HTTPServer):
    allow_reuse_address = True
    daemon_threads = True

picam2 = Picamera2()
picam2.configure(picam2.create_video_configuration(main={"size": (640, 480)}))
output = StreamingOutput()
picam2.start_recording(JpegEncoder(), FileOutput(output))

try:
    address = ('', 7123)
    server = StreamingServer(address, StreamingHandler)
    server.serve_forever()
finally:
    picam2.stop_recording()

```

The stream is running successfully and I have checked it through the browser on my laptop. Now I want to know how to integrate it into my Node-RED dashboard. I have tried a standalone ui template with pi4 ip and it did not work. I am very new to Node-Red and would appreciate some suggestions.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [6 November 2025 13:35 UTC](https://discourse.nodered.org/t/how-to-integrate-mjpeg-stream-into-node-red-dashboard/99299/2 "2025-11-06T13:35:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
