Real-time MQTT Status

OBS Python Real-time MQTT Status 1.0.1

This script will regularly publish real-time (JSON-encoded) OBS status information to the configured MQTT host, port, and channel at the specified interval. I wrote this is so I could make my own fully-automated IoT "RECORDING" sign:


Examples of what gets published:

Right when OBS starts up (if the script is enabled) or if you "Exit" OBS without first stopping any recording/streaming:
JSON:
{"recording": false, "streaming": false, "paused": false, "replay_buffer": false, "fps": 0, "frame_time_ns": 0, "frames": 0, "lagged_frames": 0}
It won't publish anything at all after that until you start recording or streaming (so it doesn't spam your MQTT server with unnecessary messages).

After recording starts:
JSON:
{"recording": true, "streaming": false, "paused": false, "replay_buffer": false, "fps": 60.0000024000001, "frame_time_ns": 4270780, "frames": 310, "lagged_frames": 2}
{"recording": true, "streaming": false, "paused": false, "replay_buffer": false, "fps": 60.0000024000001, "frame_time_ns": 4582892, "frames": 610, "lagged_frames": 2}
(repeats messages like that every <interval> seconds)

When recording stops:
JSON:
{"recording": false, "streaming": false, "paused": false, "replay_buffer": false, "fps": 60.0000024000001, "frame_time_ns": 6571491, "frames": 1511, "lagged_frames": 6}
Note that I tried to add support for TLS but OBS currently has a bug (https://github.com/obsproject/obs-studio/issues/2222) that prevents binary Python modules (like ssl) from working (they throw exceptions like
Code:
ImportError: /usr/lib/python3.8/lib-dynload/_ssl.cpython-38-x86_64-linux-gnu.so: undefined symbol: PyExc_OSError
). Once that's fixed I can add TLS support.
  • Like
Reactions: Luis Bordis
Author
riskable
Downloads
351
Views
1,989
First release
Last update
Rating
4.00 star(s) 1 ratings

Latest updates

  1. Fixed an issue where it wasn't auto-reconnecting if the MQTT client got disconnected

    Just a minor bugfix: If the MQTT client disconnected OBS would trudge on like nothing happened...

Latest reviews

Very useful script. I was able to use this as a starting point for implementing tally light updates over MQTT using the same infrastructure.

There are a few bugs to watch out for. Updating MQTT can cause the UI to freeze for a second while the MQTT process updates in the foreground, and because the updates are triggered by a 5 second periodic timer there is a slight delay before the message gets sent out.
Top