Skip to content

Instantly share code, notes, and snippets.

@crocandr
Last active May 2, 2022 09:58
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crocandr/6b333efc695fdec14a25e94d20a86934 to your computer and use it in GitHub Desktop.
Save crocandr/6b333efc695fdec14a25e94d20a86934 to your computer and use it in GitHub Desktop.
Motioneye with Digoo M1X camera

Digoo BB-M1X IP camera integration to Motioneye

Thank you to @felixsteghofer for the basic informations and the detailed informations.

Basic

I have a PC based and cheap home server. This servers runs Motioneye too in a docker container.

My docker-compose.yml file for motioneye:

version: '3'

services:
  motioneye:
    image: ccrisan/motioneye:master-amd64
    volumes:
      - '/etc/localtime:/etc/localtime:ro'
      - './lib:/var/lib/motioneye'
      - './etc:/etc/motioneye'
    restart: always
    network_mode: host

I've started the motioneye container with docker-compose up -d command.

The motioneye's web UI available on the 8765 port. Example: http://192.168.1.10:8123

But the question is: How can I integrate the new and cheap Digoo M1X IP camera?

Integration

Connnect the camera to the network

I can't setup the camera with the Digoo Cloud App (https://play.google.com/store/apps/details?id=com.ancloudDigooCloud.aws), so I've configured fully manually.

  1. step: Connect the Digoo Camera to the network with a LAN cable. Wait 1-3 minutes to the first boot. I've found Digoo's IP address with Fing APP on my phone (https://play.google.com/store/apps/details?id=com.overlook.android.fing) and/or checked my router DHCP leases table.

  2. step: I have to connect Digoo cam to the network with wireless. Connected to the camera with telnet console. (example: telnet 192.168.1.30) The user is root and without password. (little bit unsecure by default :( )

  3. step: I've changed the /rom/wpa_supplicant0.conf file with vi editor like this:

ctrl_interface=/etc/Wireless  
 network={ 
     ssid="MyWifiNetworkName"   
     psk="MyWifiPassword"
  }

(change the MyWifiNetworkName and MyWifiPassword with your valid wifi name and password)

  1. step: I've rebooted the camera with reboot command and waited 1-2 minutes to start.

  2. step: I've found the camera's new IP address like this:

  • checked my router DHCP leases list, little bit faster than a network scan again
  • but I can connect to the camera with telnet again and check the ip addr command output. The IP address on wlan0 interface is the new, wireless address

Integrate the camera to Motioneye

RTSP URLs:

  • rtsp://admin:20160404@192.168.1.30/onvif1 - 1280x960
  • rtsp://admin:20160404@192.168.1.30/onvif2 - 320x240

The admin is the default user and the 20160404 is the default access password to RTSP stream.

How can I added the camera to the Motioneye? I've opened the Motioneye Web UI and logged in with admin user (without password by default). I've added the camera with these parametes:

  • Camera type: "network camera"
  • URL: "rtsp://192.168.1.30/onvif1"
  • username: "admin"
  • password: "20160404"
  • camera: "rtsp/udp camera"

That's all, almost. I see the camera's video stream with Motioneye.

Pan Tilt - rotating the camera

Pan/Tilt is little bit tricky, because I have to post a short XML to the camera service URL. The usual method is "call an URL". So, I've made some script for this.

I've connected to your Motioneye server with SSH. I've stepped into motioneye's directory (example: /srv/motioneye). To the directory that contains motioneye's docker-compose.yml file. Created the digoo-rotate-template.xml file under the etc folder (etc/digoo-rotate-template.xml) and inserted these lines:

<v:Envelope
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:d="http://www.w3.org/2001/XMLSchema"
    xmlns:c="http://www.w3.org/2003/05/soap-encoding"
    xmlns:v="http://www.w3.org/2003/05/soap-envelope">
    <v:Body>
        <ContinuousMove
            xmlns="http://www.onvif.org/ver20/ptz/wsdl">
            <ProfileToken>IPCProfilesToken0</ProfileToken>
            <Velocity>
                <PanTilt
                    xmlns="http://www.onvif.org/ver10/schema" x="--X--" y="--Y--"/>
            </Velocity>
        </ContinuousMove>
    </v:Body>
</v:Envelope>

Created the digoo-rotate.sh file under the etc folder (etc/digoo-rotate.sh) and inserted these lines:

#!/bin/bash

IP=$1
DIRECTION=$2

ONVIF_PORT=5000
XML_TEMPLATE="$( dirname $0 )/digoo-rotate-template.xml"

TEMP_OUT="/tmp/digoo-rotate-temp.out"

#               x       y       Action
#               0.0     -1.0    move down
#               0.0     1.0     move up
#               1.0     0.0     move to the right
#               -1.0    0.0     move to the left

# ----------------

[ -e $XML_TEMPLATE ] || { echo "Template xml not found"; exit 1; }


case $DIRECTION in
  right|RIGHT )
#    echo "moving right..."
    DATA="$( cat $XML_TEMPLATE | sed s@--X--@1.0@g | sed s@--Y--@0.0@g )"
    ;;
  left|LEFT )
#    echo "moving left..."
    DATA="$( cat $XML_TEMPLATE | sed s@--X--@-1.0@g | sed s@--Y--@0.0@g )"
    ;;
  up|UP )
#    echo "moving up..."
    DATA="$( cat $XML_TEMPLATE | sed s@--X--@0.0@g | sed s@--Y--@1.0@g )"
    ;;
  down|DOWN )
#    echo "moving down..."
    DATA="$( cat $XML_TEMPLATE | sed s@--X--@0.0@g | sed s@--Y--@-1.0@g )"
    ;;
esac

curl -s -o $TEMP_OUT -H "Content-Type: application/soap+xml" -X POST -d "$DATA" http://$IP:$ONVIF_PORT/onvif/device_service || { cat $TEMP_OUT; exit 1; }

I've checked the "Camera ID" on the motioneye UI. Clicked on the Wrench icon and found the number in the "Camera ID" line. Example: 2 I've created some small scripts for directions under the etc folder. up_2 script (etc/up_2):

#!/bin/bash

$( dirname $0 )/digoo-rotate.sh "192.168.1.30" "up"

down_2 script (etc/down_2):

#!/bin/bash

$( dirname $0 )/digoo-rotate.sh "192.168.1.30" "down"

right_2 script (etc/right_2):

#!/bin/bash

$( dirname $0 )/digoo-rotate.sh "192.168.1.30" "right"

left_2 script (etc/left_2):

#!/bin/bash

$( dirname $0 )/digoo-rotate.sh "192.168.1.30" "left"

Modified the script permissions (executable permission):

chmod 755 etc/digoo*
chmod 755 etc/*_2

Restarted the motioneye with docker-compose restart command.

I was lucky, because works :) I hope you can use this little howto if You have a same camera and situation. Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment