AlexxIT/go2rtc · error
xiaomi: unsupported encryption
Error message
xiaomi: unsupported encryption
What it means
DecodeVideo can decrypt the standard encryption variant (data[8]==1) and pass through unencrypted frames, but frames with some other encryption byte are not supported. The library explicitly notes support could be added but such cameras are rare.
Solutions
- Update camera firmware to a version using the supported encryption scheme
- Patch DecodeVideo in pkg/xiaomi/legacy/client.go to implement the additional variant (data[8] values other than 0/1)
- Use a model/firmware combination known to produce standard frames
- Fall back to the camera's non-TUTK stream if available
Defensive patterns
Strategy: fallback
Validate before calling
// inspect frame encryption byte before decoding
if len(frame) > 8 && frame[8] != 0 && frame[8] != 1 {
return errors.New("unsupported frame encryption variant")
} Prevention
- Pin camera firmware to versions using the supported encryption scheme
- Handle unknown encryption bytes gracefully by skipping frames
- Track upstream support for additional variants
When it happens
Trigger: Calling DecodeVideo (directly or via ReadPacket) on a video frame whose 9th byte is neither 0 nor 1, indicating an unknown encryption variant.
Common situations: Using the library with a camera firmware that encrypts video with a different scheme; decoding streams recorded from a non-standard camera model.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/40438d5ff66f1f47.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/xiaomi/legacy/client.go:233
return fmt.Errorf("xiaomi: unsupported model: %s", c.model)
}
func (c *Client) StopMedia() error {
return errors.Join(
c.WriteCommandJSON(cmdVideoStop, `{}`),
c.WriteCommand(cmdVideoStop, make([]byte, 8)),
)
}
func DecodeVideo(data, key []byte) ([]byte, error) {
if string(data[:4]) == "\x00\x00\x00\x01" || data[8] == 0 {
return data, nil
}
if data[8] != 1 {
// Support could be added, but I haven't seen such cameras.
return nil, fmt.Errorf("xiaomi: unsupported encryption")
}
nonce8 := data[:8]
i1 := binary.LittleEndian.Uint32(data[9:])
i2 := binary.LittleEndian.Uint32(data[13:])
data = data[17:]
src := data[i1 : i1+i2]
for i := 32; i+16 < len(src); i += 160 {
dst, err := crypto.DecodeNonce(src[i:i+16], nonce8, key)
if err != nil {
return nil, err
}
copy(src[i:], dst) // copy result in same place
}
return data, nil
}View on GitHub (pinned to c245815e75)