Skip to main content

pyibaby

An open-source client library for iBaby monitor cameras (M6S / M7 / M7T and relatives), reverse-engineered for interoperability so the cameras can be used without the vendor's Windows/Android app and with reduced dependence on the iBaby cloud.

The cameras are built on ThroughTek's PPCS/PPPP P2P stack. This project reimplements every layer needed to reach a camera in pure Python:

  • the iBaby cloud API (get-secret-key -> login -> device list);
  • decryption of each camera's per-device P2P password;
  • the generateP2Ppass login token (standard AES, recovered from the native library, no proprietary code required);
  • the PPPP transport (LAN discovery, handshake, reliable DRW channels);
  • the control channel (BABYCARE: login, media start/stop, PTZ, two-way audio) and the H.264 / G.711 media framing.

See docs/protocol.md for the full protocol write-up.

Status

Working end to end on the LAN. The cloud client, credential decryption, login-token generation, and protocol/codec parsing are validated against live traffic and two physical cameras. The LAN transport (pyibaby/pppp.py) performs discovery, handshake, login, and reliable video reception: tools/grab_frame.py connects to a camera with no vendor software involved and decodes live 1080p H.264. The intended end state is a small producer that exposes a camera as RTSP/WebRTC (via go2rtc) and ONVIF for NVRs, plus a V4L2 source and a Home Assistant integration.

This targets the p2p_provider != 0 (PPCS/PPPP) cameras. ThroughTek's other generation (provider == 0, TUTK IOTC) is handled directly by go2rtc's pkg/tutk and is out of scope here.

Layout

pyibaby/
  crypto.py     RNCryptor, account-password hashing, generate_p2p_token
  cloud.py      IBabyCloud: get-secret-key / login / camera_list
  protocol.py   PPPP framing, DID encoding, BABYCARE commands, AV frame header
  pppp.py       LAN transport: discovery, handshake, reliable DRW channels
  client.py     LANCamera: connect, control, pull video
  servers.py    init_string -> PPCS supernode list (WAN path)
  relay.py      ThroughTek relay fallback for symmetric-NAT pairs
docs/protocol.md        protocol reference
docs/nat-cloud-mode.md  remote access: hole-punching, NAT types, relay status
tests/            unit tests (crypto vectors, framing)

Remote access

The LAN path is the supported one. For reaching a camera from another network, use a WireGuard or Tailscale tunnel into the camera's LAN - everything here then works unchanged, nothing depends on ThroughTek staying online, and video never leaves infrastructure you control.

LANCamera.connect_wan() also implements the app's own mechanism: decode the cloud-provided init_string to ThroughTek's PPCS supernodes and UDP hole-punch to the camera. Direct punching works only when neither side is behind symmetric NAT, and raises SymmetricNatError (naming which side) otherwise - which is common on carrier NAT. For that case, connect_wan(allow_relay=True) falls back to a ThroughTek relay, which is validated end to end for control, sensors, and video. It is opt-in because the relay carries your camera's video through ThroughTek's servers.

See docs/nat-cloud-mode.md for the protocol detail, the live measurements, and what would be needed to finish the relay.

Usage (sketch)

from pyibaby import IBabyCloud, LANCamera

cloud = IBabyCloud()
cameras = cloud.login("you@example.com", "password")   # reads camera_list
cam = next(c for c in cameras if c.is_pppp)

lan = LANCamera(cam).connect()        # LAN discovery + handshake + login
lan.start_video()
lan.pump(2.0)                          # service the link for 2s
open("out.h264", "wb").write(lan.video_bitstream())
lan.close()

Credentials and camera UIDs are not stored in this repository; supply them at runtime (environment, a local untracked config, or a secret manager).

RTSP / WebRTC via go2rtc

pyibaby.bridge is a live producer that connects to a camera and writes raw Annex-B H.264 to stdout, which go2rtc ingests directly as an exec: source - no ffmpeg needed for video. go2rtc then re-serves the camera as RTSP / WebRTC / HLS / MJPEG and fans one camera session out to many consumers (NVRs, Frigate, VLC, Home Assistant, ...).

See examples/go2rtc.yaml. In short:

IBABY_EMAIL=you@example.com IBABY_PASSWORD=... go2rtc -config examples/go2rtc.yaml
# -> rtsp://127.0.0.1:8554/nursery

Validated end to end: camera -> pyibaby.bridge (PPPP) -> raw H.264 -> go2rtc -> RTSP, decoded back as 1080p with no vendor software in the loop.

RTSP server (pyibaby.rtspd)

pyibaby.bridge is an exec: producer (go2rtc spawns it). Some consumers can't spawn a process - notably Home Assistant's bundled go2rtc, which is locked to exec: allow_paths: [ffmpeg] and will not run Python. For those, pyibaby.rtspd runs as its own RTSP server: it holds one camera session and serves H.264 + G.711 u-law over RTSP (RTP interleaved on TCP), fanning the one session out to multiple local clients. It doubles as a plain RTSP source for any NVR.

IBABY_EMAIL=you@example.com IBABY_PASSWORD=... python -m pyibaby.rtspd --port 8554 --path /cam
# -> rtsp://127.0.0.1:8554/cam  (point go2rtc / an NVR / ffmpeg at this URL)

Validated end to end against go2rtc 1.9.14: it ingests the stream over rtsp+tcp and detects H264 High@4.0 video + PCMU/8000 audio. Two concurrent camera sessions are supported by the hardware, so the control/sensor path and the RTSP video path can run side by side.

Branching

master is the primary branch.

Licence

MPL-2.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyibaby-0.1.9.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyibaby-0.1.9-py3-none-any.whl (48.8 kB view details)

Uploaded Python 3

File details

Details for the file pyibaby-0.1.9.tar.gz.

File metadata

  • Download URL: pyibaby-0.1.9.tar.gz
  • Upload date:
  • Size: 55.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pyibaby-0.1.9.tar.gz
Algorithm Hash digest
SHA256 1b1f3fc317bf5bdb6f5230261e669aff0aec3e4c92a761f4cff9a9fe07e0dad9
MD5 d7e3c8015e82bf36ae1a8098cee9c19b
BLAKE2b-256 187c2cb65da5bd8122860cee391a3970797818488c7ec4b1f95e1ffce11f1cbc

See more details on using hashes here.

File details

Details for the file pyibaby-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: pyibaby-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 48.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for pyibaby-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 fba5f7b1fea82ee060db7492096948e6c4b7fe8a517691eb79299085e8df3b63
MD5 c5dced21cac2b8bc2e34bcd282ad4e3e
BLAKE2b-256 5bd4dc1f9ec8c8932ef34bcc73c1976ed1711b409dbf9747a144815a34a3048a

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.10

2 files

This release

0.1.9 This release

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page