Generates an MJPEG stream from png graphics distributed as a binary payload via MQTT.
MQTTImageStreamer is designed to send still images, snapshots or automatic screenshots as a moving image stream to camera endpoints. This allows still images to be displayed in front ends for video footage.
- Still images are graphics that are updated or replaced at (in)regular intervals. An example are exports of generated dashboard graphics like charts or graphs of time.
- Snapshots are often created by inexpensive security cameras on motion and are accessible via urls or distributed to clients using FTP.
- Screenshots generated by surveillance or monitoring tools at regular intervals. For example, from IoTLink or HASS.Agent.
Techstack:
- Docker with minimal Alpine 3.14 base
- Streameye a simple MJPEG streamer for Linux with an integrated webserver
- The fabulous Imagemagick
- Mosquitto-Client for Linux
- A pinch of bash magic
MQTTImageStreamer is configured using environment variables.
SCREENSHOT_SIZE
Sets the size of the stream. Defaults to 1440x900 pixels.
SCREENSHOT_NOT_UPDATED_MSG
Defines the text that will be streamed if within {TIMEOUT} seconds the topic has not been updated. In memory of Windows 95, the default is "It's now safe to turn off your computer." - Of course, the font is orange on dark gray.
MQTT_BROKER
The broker host. Use host.docker.internal
instead of 'localhost' when the broker is hosted on the docker host. At least until now, the default port of MQTT (1883) is always being used.
MQTT_TOPIC
Send to this topic also the image you want to see in the stream. For this you send raw the binary png or jpeg data. No JSON wrapper or other encoding!
You could try this out for testing purposes:
cat example.jpg | mosquitto_pub -h localhost -t "computer/status/display/0/screen" -s
STREAM_TIMEOUT
If no update has been sent to the topic after this number of seconds, the SCREENSHOT_NOT_UPDATED_MSG
text is rendered into the stream.
STREAM_FPM
The abbreviation for 'Frames per Minute'. The FPS (Frames per Second) of the stream is calculated from this value. The default value is 30, which is translated to 2 FPS.
Customize the configuration in the docker-compose.yml
file by defining the values for the environment.
Start the build with docker-compose build
and run the docker container with docker-compose up
.
Alternatively, you can also start the Docker container via console.
To establish a MQTT-Connection to the Docker Host (localhost is in fact the docker instance itself) use host.docker.internal
to describe the host within the environment variable.