Redis API quick start#
Redis-cli#
# List all keys
redis-cli KEYS '*'
# Read the current ISO value
redis-cli GET iso
# Start a recording (same as pressing the Rec button)
redis-cli SET is_recording 1
redis-cli PUBLISH cp_controls is_recording
You can also type:
redis-cli
This opens the Redis CLI.
cp_controls#
Both CinePi-raw and Cinemate write values and then publish the key name on the cp_controls channel. The supported control path is therefore:
SET <key> <value>PUBLISH cp_controls <key>
Any controllable key may be sent this way. For example, to adjust preview zoom:
redis-cli SET zoom 1.5
redis-cli PUBLISH cp_controls zoom
Recording uses two related keys:
is_recordingis the requested record state. This is the key you write from scripts, and it is edge-triggered:0 -> 1starts a take and1 -> 0stops it.recis a derived runtime state generated by Cinemate from liveframecountmovement. It flips to1when frames actually start increasing and back to0when they stop rising or reset to zero. Userecfor "is the recorder really active right now?" indicators.
During a storage warm-up, Cinemate also raises storage_preroll_active=1 so other components can ignore the temporary clip.
cp_stats#
Every frame, CinePi-raw sends a small JSON object containing live statistics.
Json::Value data;
Json::Value histo;
data["framerate"] = completed_request->framerate;
data["colorTemp"] = info.colorTemp;
data["focus"] = info.focus;
data["frameCount"] = app_->GetEncoder()->getFrameCount();
data["bufferSize"] = app_->GetEncoder()->bufferSize();
// per-camera timestamps in nanoseconds
data["timestamp"] = info.timestamp; // single sensor
data["timestamp_cam0"] = info.timestamp_cam0; // multi-sensor
data["timestamp_cam1"] = info.timestamp_cam1; // multi-sensor
redis_->publish(CHANNEL_STATS, data.toStyledString());
Cinemate's RedisListener parses these messages and updates keys such as:
framecount,buffer,buffer_size, andfps_actualtc_cam0andtc_cam1, derived from the nanosecond timestamps- drop-frame keys such as
drop_frame,drop_frame_count, anddrop_frame_during_last_take frames_in_sync, which flips to0during a real take as soon as live frame-slot sync drifts outside the configured live tolerance (default +/- 2 frames), andfps_correction_suggestionafter the take finishes and buffered frames have flushed. The final analysis uses the configured final tolerance (default +/- 1 frame). Storage pre-roll clips are excluded from this analysis.
Separately, the Redis controller starts a recording timer whenever rec=1. That timer updates:
recording_timeas elapsed secondsrecording_tc_recas elapsed record timecoderecording_time_todas time-of-day timecode
Controlling the camera from your own script#
Below is a very small example using redis-py.
import redis
r = redis.Redis(host='localhost', port=6379, db=0)
# toggle recording
current = r.get('is_recording')
new_value = b'0' if current == b'1' else b'1'
r.set('is_recording', new_value)
r.publish('cp_controls', 'is_recording')
Info
This is basically what Cinemate does: it keeps track of values coming from CinePi-raw, adds higher-level state of its own, and republishes control changes through Redis.