Proxy to enable xiaomi P2P only cameras to work with standard protocols.
Works without changing the firmware of the camera, MiHome cloud will continue to work.
Install dependency packages
sudo apt-get install build-essential git python3 python3-dev autoconf automake libtool liblivemedia-dev libjson-c-dev
Install https://github.com/rytilahti/python-miio
pip3 install python-miio
git clone https://github.com/miguelangel-nubla/videoP2Proxy.git
cd videoP2Proxy
./autogen.sh
make
sudo make install
videop2proxy --ip CAMERA_IP --token CAMERA_HEX_TOKEN --rtsp 8554
Example output running correctly:
Starting proxy...
Starting RTSP server on "rtsp://192.168.1.2:8554/"
(Using port 8000 for optional RTSP-over-HTTP tunneling.)
[P2P client] starting...
IOTC_Initialize2...
IOTC_Connect_ByUID_Parallel... SID:0
avClientStart2... userName: c8da138df16 passWord: a1c8da1df11a
avClientStart2 mAvIndex=0
startIOTC video ret=0
startIOTC audio ret=0
[P2P client] running
[ReceiveVideo] Running
[ReceiveAudio] Running
Simply add to your configuration.yaml
camera:
- platform: ffmpeg
input: -rtsp_transport tcp -i rtsp://192.168.1.2:8554/
$ videop2proxy --help
Usage: videop2proxy --ip CAMERA_IP --token CAMERA_HEX_TOKEN [...]
Options:
--ip IP [Required] Camera ip address.
--token HEX_TOKEN [Required] Camera miio token.
Modes:
--rtsp PORT Enable RTSP server.
--stdout Enable output to stdout.
If you don't already have the miio token for your device you can try:
Keep in mind that reseting and re-adding the device to MiHome app will change the token.
Starts a rtsp server on the specified port with live video data.
Dumps the raw h264 stream to stdout on realtime to allow usage to other programs via linux pipe.
Example use with a webRTC server running janus on a Raspberry Pi
videop2proxy --ip CAMERA_IP --token CAMERA_HEX_TOKEN --stdout \
| gst-launch-1.0 -v fdsrc ! h264parse ! rtph264pay config-interval=1 pt=96 ! udpsink host=127.0.0.1 port=8004
Was this useful to you? Consider donating
@PayPal: miguelangel.nubla@gmail.com
@bitcoin: bc1q2s5jdm7vem8ygv2fgxtfukmxuruyfsqjrexk3c