Skip to content

Xiaomi C400 (chuangmi.camera.039a04) - laggy/stuttering stream, HEVC decoding errors #2030

@piqusy

Description

@piqusy

Xiaomi C400 (chuangmi.camera.039a04) - laggy/stuttering stream, HEVC decoding errors

Camera Info

Field Value
Name Xiaomi Smart Camera C400
Model ID chuangmi.camera.039a04
Codecs HEVC + OPUS
go2rtc version 1.9.13

Problem

Stream is laggy/stuttering when viewed via go2rtc, but plays smoothly in the Xiaomi/Mi Home app.

Setup

  • Home Assistant OS on Proxmox
  • go2rtc add-on (v1.9.13)
  • Camera on 2.4GHz WiFi with excellent signal:
    • RSSI: -41
    • Signal strength: 80%
    • Packet loss: 0%

Stream URL

xiaomi://USER_ID:[email protected]?did=DEVICE_ID&model=chuangmi.camera.039a04

What I tried

Mode Result
MSE Works but laggy/stuttering
MSE with &subtype=sd Same lag as HD
WebRTC Blank display
HLS Nothing displays
MJPEG Codec mismatch error: codecs not matched: video:H265, audio:OPUS => video:JPEG, video:RAW
Adding &stream=0 or &stream=1 No improvement

Comparison with Mi360 2K Pro

On the exact same setup, the Mi 360° Home Security Camera 2K Pro (chuangmi.camera.021a04) works perfectly with smooth streaming via MSE. Both cameras are on the same 2.4GHz network, same go2rtc instance, same dashboard.

Camera Model ID Codecs Result
Mi360 2K Pro chuangmi.camera.021a04 HEVC + PCMA Smooth
C400 chuangmi.camera.039a04 HEVC + OPUS Laggy

Root Cause: HEVC Decoding Errors

ffplay RTSP test

ffplay -fflags nobuffer -flags low_delay -rtsp_transport tcp "rtsp://192.168.178.88:8554/camera_xiaomi_c400_sd"

Output shows repeated HEVC decoding errors:

[hevc @ 0x7fce36336340] Could not find ref with POC 12
[hevc @ 0x7fce36336340] Error constructing the frame RPS.
[hevc @ 0x7fce36336340] Skipping invalid undecodable NALU: 1
[hevc @ 0x7fce36336340] Could not find ref with POC 13
[hevc @ 0x7fce36336340] Error constructing the frame RPS.
[hevc @ 0x7fce36336340] Skipping invalid undecodable NALU: 1
...

This repeats for every frame (POC 12, 13, 14, 15...), indicating missing reference frames / corrupted NAL units in the HEVC stream.

go2rtc API info

GET /api/streams?src=camera_xiaomi_c400_sd&video=all&audio=all:

{
  "producers": [
    {
      "format_name": "xiaomi",
      "protocol": "cs2+udp",
      "remote_addr": "192.168.178.37:29319",
      "medias": [
        "video, recvonly, H265",
        "audio, recvonly, OPUS/48000/2",
        "audio, sendonly, OPUS/48000/2"
      ]
    }
  ],
  "consumers": [
    {
      "format_name": "mse/fmp4",
      "protocol": "ws",
      "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:146.0) Gecko/20100101 Firefox/146.0",
      "medias": [
        "video, sendonly, H264, H265",
        "audio, sendonly, MPEG4-GENERIC, PCMA, PCMU, L16, PCML, OPUS"
      ]
    }
  ]
}

Analysis

The HEVC stream from the C400 appears to be missing keyframes or has corrupted NAL unit structure. This causes:

  1. Lag/stuttering in MSE - decoder recovers but with delays
  2. Blank display in WebRTC - can't establish proper stream
  3. Nothing in HLS - segmenter fails on corrupted frames

The Mi360 2K Pro (chuangmi.camera.021a04) on the same setup works perfectly, suggesting the issue is specific to how go2rtc handles the C400 model's stream.

Notes

  • Your Known Xiaomi cameras list shows chuangmi.camera.039c04 as supported, but my model is 039a04 (different suffix - possibly regional variant with different firmware?)
  • The Xiaomi/Mi Home app streams this camera smoothly, confirming it's not a WiFi/network issue
  • The camera is a 2024 model, newer than the Mi360 2K Pro (2020) which works perfectly

Logs from go2rtc

warn undefined error=miss: read raw: i/o timeout url=xiaomi://...&model=chuangmi.camera.039a04&subtype=sd

Environment

  • Home Assistant: OS (latest)
  • Platform: Proxmox
  • go2rtc: Add-on v1.9.13
  • Network: FritzBox 6660 Cable router
  • Camera WiFi: 2.4GHz (NNI-2.4)

Expected behavior

Stream should play smoothly via MSE like the Mi360 2K Pro does, with proper HEVC keyframe handling.

Additional context

Happy to provide additional logs, packet captures, test different configurations, or help debug if needed. The ffplay errors strongly suggest the issue is in how go2rtc receives/forwards the C400's HEVC stream rather than client-side decoding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions