Skip to main content

Media Routes Overview

Media routes enable processing of visual data including barcode scanning and video streaming. These routes bridge the gap between image/video sources and your MQTT infrastructure.
Like adding eyes to your broker. Media routes let your MQTT broker see and interpret visual data — scanning barcodes off a camera feed or streaming video to a dashboard — without any external processing code.
In this page:
  • Barcode — Encode and decode barcodes (QR, Code128, EAN, etc.)
  • Video Input — Capture from RTSP, webcams, and files
  • Video Output — Stream to HTTP, RTSP, UDP, TCP

Barcode Route

The BARCODE route enables encoding and decoding of various barcode formats including QR codes, Code 128, EAN-13, and more.

Basic Syntax

DEFINE ROUTE BarcodeProcessor WITH TYPE BARCODE
    ADD BARCODE_CONFIG
        WITH SUPPORTED_FORMATS "QR_CODE, CODE_128, EAN_13"
    ADD EVENT DecodeBarcode
        WITH SOURCE_TOPIC "barcode/scan"
        WITH DESTINATION_TOPIC "barcode/result"
        WITH MODE "DECODE"

Configuration Parameters

SUPPORTED_FORMATS
string
Comma-separated barcode formats to support (e.g., QR_CODE, CODE_128, EAN_13).

Event Parameters

SOURCE_TOPIC
string
MQTT topic with barcode image (base64) or data to encode.
DESTINATION_TOPIC
string
MQTT topic to publish barcode results.
MODE
string
Operation mode: ENCODE (create barcode) or DECODE (read barcode).
ENABLE_ANNOTATION
boolean
Annotate decoded barcode location on image. Default: false.
ANNOTATED_IMAGE_TOPIC
string
Topic to publish annotated image (for DECODE mode).

Supported Formats

FormatDescription
QR_CODEQR Code (2D)
CODE_128Code 128 (1D)
CODE_39Code 39 (1D)
EAN_13EAN-13 (1D retail)
EAN_8EAN-8 (1D retail)
UPC_AUPC-A (1D retail)
UPC_EUPC-E (1D retail)
DATA_MATRIXData Matrix (2D)
PDF_417PDF417 (2D stacked)

Barcode Examples

Scan barcodes from images:
DEFINE ROUTE BarcodeScanner WITH TYPE BARCODE
    ADD BARCODE_CONFIG
        WITH SUPPORTED_FORMATS "QR_CODE, CODE_128, EAN_13, UPC_A"
    ADD EVENT ScanBarcode
        WITH SOURCE_TOPIC "camera/frame"
        WITH DESTINATION_TOPIC "barcode/decoded"
        WITH MODE "DECODE"
        WITH ENABLE_ANNOTATION "true"
        WITH ANNOTATED_IMAGE_TOPIC "barcode/annotated"
Input: Base64-encoded image on camera/frameOutput: JSON with decoded data on barcode/decoded:
{
  "format": "QR_CODE",
  "data": "https://example.com",
  "timestamp": "2024-01-15T10:30:00Z"
}

Video Input Route

The VIDEO_INPUT route captures video frames from RTSP streams, webcams, or video files and publishes them to MQTT topics.

Basic Syntax

DEFINE ROUTE VideoCapture WITH TYPE VIDEO_INPUT
    ADD VIDEO_INPUT_CONFIG
        WITH SOURCE "rtsp://192.168.1.100:554/stream"
        WITH DESTINATION_TOPIC "video/frames"
        WITH FORMAT "JPEG"
        WITH FRAME_RATE '10'

Configuration Parameters

SOURCE
string
Video source: RTSP URL, webcam identifier, or file path.
DESTINATION_TOPIC
string
MQTT topic to publish video frames.
FORMAT
string
Output format: JPEG, MJPEG, H264, H265, MP4, MPEGTS.
FRAME_RATE
integer
Frame rate for capture (1-60 fps).
WIDTH
integer
Frame width in pixels.
HEIGHT
integer
Frame height in pixels.
QUALITY
integer
JPEG quality (1-100).

Event Parameters

SOURCE_TOPIC
string
MQTT topic to control video capture.
QUERY
string
Control command: START, STOP, or CAPTURE <duration>.

Video Input Examples

Capture from IP camera:
DEFINE ROUTE IPCamera WITH TYPE VIDEO_INPUT
    ADD VIDEO_INPUT_CONFIG
        WITH SOURCE "rtsp://admin:password@192.168.1.100:554/stream1"
        WITH DESTINATION_TOPIC "camera/entrance/frames"
        WITH FORMAT "JPEG"
        WITH FRAME_RATE '5'
        WITH WIDTH '1280'
        WITH HEIGHT '720'
        WITH QUALITY '80'
    ADD EVENT CameraControl
        WITH SOURCE_TOPIC "camera/entrance/control"
        WITH QUERY "START"

Video Output Route

The VIDEO_OUTPUT route streams video frames from MQTT to various output protocols.

Basic Syntax

DEFINE ROUTE VideoStreamer WITH TYPE VIDEO_OUTPUT
    ADD VIDEO_OUTPUT_CONFIG
        WITH SOURCE_TOPIC "video/frames"
        WITH OUTPUT_PROTOCOL "HTTP"
        WITH OUTPUT_PATH "/stream"

Configuration Parameters

SOURCE_TOPIC
string
MQTT topic with video frames (base64).
OUTPUT_PROTOCOL
string
Output protocol: HTTP, RTSP, UDP, TCP.
OUTPUT_PATH
string
Output path or port for streaming.

Event Parameters

QUERY
string
Control command: START or STOP.

Video Output Examples

Stream via HTTP (MJPEG):
DEFINE ROUTE HTTPStream WITH TYPE VIDEO_OUTPUT
    ADD VIDEO_OUTPUT_CONFIG
        WITH SOURCE_TOPIC "camera/frames"
        WITH OUTPUT_PROTOCOL "HTTP"
        WITH OUTPUT_PATH ":8081/video"
    ADD EVENT StreamControl
        WITH QUERY "START"
Access stream at: http://broker-ip:8081/video

Complete Example: Vision System

A complete vision system with camera input, barcode scanning, and video streaming:
// Camera input
DEFINE ROUTE InspectionCamera WITH TYPE VIDEO_INPUT
    ADD VIDEO_INPUT_CONFIG
        WITH SOURCE "rtsp://192.168.1.100:554/stream"
        WITH DESTINATION_TOPIC "inspection/camera/raw"
        WITH FORMAT "JPEG"
        WITH FRAME_RATE '10'
        WITH WIDTH '1920'
        WITH HEIGHT '1080'
        WITH QUALITY '90'
    ADD EVENT CameraControl
        WITH SOURCE_TOPIC "inspection/camera/control"
        WITH QUERY "START"

// Barcode scanning
DEFINE ROUTE ProductScanner WITH TYPE BARCODE
    ADD BARCODE_CONFIG
        WITH SUPPORTED_FORMATS "CODE_128, DATA_MATRIX, QR_CODE"
    ADD EVENT ScanProduct
        WITH SOURCE_TOPIC "inspection/camera/raw"
        WITH DESTINATION_TOPIC "inspection/barcode/result"
        WITH MODE "DECODE"
        WITH ENABLE_ANNOTATION "true"
        WITH ANNOTATED_IMAGE_TOPIC "inspection/camera/annotated"

// Live stream for operators
DEFINE ROUTE OperatorStream WITH TYPE VIDEO_OUTPUT
    ADD VIDEO_OUTPUT_CONFIG
        WITH SOURCE_TOPIC "inspection/camera/annotated"
        WITH OUTPUT_PROTOCOL "HTTP"
        WITH OUTPUT_PATH ":8080/inspection"
    ADD EVENT StreamControl
        WITH QUERY "START"

Best Practices

Use lower frame rates for bandwidth efficiency:
  • Monitoring: 1-5 fps
  • Motion detection: 2-5 fps
  • Barcode scanning: 5-10 fps
  • Live viewing: 15-30 fps
Balance quality and performance:
  • Barcode scanning: 640x480 to 1280x720
  • Monitoring: 1280x720
  • High detail: 1920x1080
JPEG format is ideal for MQTT transport:
  • Reasonable file sizes
  • Wide compatibility
  • Adjustable quality (60-90 recommended)
Configure reconnection for RTSP streams and monitor connection status.

Troubleshooting

  • Verify RTSP URL format and credentials
  • Check camera is accessible on network
  • Ensure port is not blocked by firewall
  • Try alternative RTSP paths (check camera documentation)
  • Ensure image quality is sufficient
  • Check barcode format is in SUPPORTED_FORMATS
  • Verify barcode is properly visible in image
  • Try higher resolution capture
  • Reduce frame rate
  • Lower resolution
  • Decrease JPEG quality
  • Process fewer simultaneous streams
  • Use UDP for lowest latency
  • Reduce frame size and quality
  • Check network bandwidth
  • Use local network when possible

Next Steps

Industrial Routes

Connect to PLCs and industrial equipment.

Route Examples

See complete route configuration examples.