thirtythreeforty / neolink

An RTSP bridge to Reolink IP cameras
https://www.thirtythreeforty.net/posts/2020/05/hacking-reolink-cameras-for-fun-and-profit/
GNU Affero General Public License v3.0
893 stars 151 forks source link

Still image stream #164

Open Viish opened 3 years ago

Viish commented 3 years ago

Describe the solution you'd like Hi,

It would be awesome to add an option to create a "still image" stream (a jpeg being saved from the video stream on a regular basis and save at some place, overridden when a new one is taken).

It would allow for perfect integration in home-assistant (https://www.home-assistant.io/integrations/generic/, still image URL is mandatory, currently I used a jpeg I took with the camera once but it isn't useful).

Thanks in advance.

thirtythreeforty commented 3 years ago

Hey thanks for the request! So -

If the cameras can do this, I am open to adding a "standardized" (read: HTTP) way to access the JPG preview. Do you know if this is possible? e.g. do official Reolink clients fetch a JPG preview?

If the camera can't do this, I would be inclined to consider this out of scope, and say lean on an NVR software to provide the functionality. Although I can maybe be persuaded.

Viish commented 3 years ago

I don't know how it's working but in the reolink apps you can take a snapshot during the preview.

twistedddx commented 3 years ago

Client to camera:

Baichuan IP Camera Protocol, <cropSnap>:230 message
    Baichuan Message Header, length: 24, type 230
        magic: 180150000
        messageId: 230 (<cropSnap>)
        messageLen: 159
        xmlEncryptionOffset: 0 (& 0xF == 0)
        channel_id: 0
        streamID: 0 HD (Clear)
        messageNumber: -22784
        messageClass: 25620 (modern)
        status_code: 0
        binOffset: 0
    Baichuan Message Body, modern, length: 159, type 230
        Main Payload
        Decrypted XML (in Main Payload)
        eXtensible Markup Language
            <?xml
            <body>
                <CropSnap
                    version="1.1">
                    <channelId>
                        0
                        </channelId>
                    <width>
                        1920
                        </width>
                    <heigth>
                        1080
                        </heigth>
                    </CropSnap>
                </body>

Camera to client: Packet #1

Baichuan IP Camera Protocol, <cropSnap>:230 message
    Baichuan Message Header, length: 24, type 230
        magic: 180150000
        messageId: 230 (<cropSnap>)
        messageLen: 151
        xmlEncryptionOffset: 0 (& 0xF == 0)
        channel_id: 0
        streamID: 0 HD (Clear)
        messageNumber: -22784
        messageClass: 0 (modern)
        status_code: 200
        binOffset: 0
    Baichuan Message Body, modern, length: 151, type 230
        Main Payload
        Decrypted XML (in Main Payload)
        eXtensible Markup Language
            <?xml
            <body>
                <cropSnap
                    version="1.1">
                    <channelId>
                        0
                        </channelId>
                    <pictureSize>
                        521019
                        </pictureSize>
                    </cropSnap>
                </body>

camera to client: Packet #2

Baichuan IP Camera Protocol, <cropSnap>:230 message
    Baichuan Message Header, length: 24, type 230
        magic: 180150000
        messageId: 230 (<cropSnap>)
        messageLen: 10106
        xmlEncryptionOffset: 0 (& 0xF == 0)
        channel_id: 0
        streamID: 0 HD (Clear)
        messageNumber: -22784
        messageClass: 0 (modern)
        status_code: 200
        binOffset: 106
    Baichuan Message Body, modern, length: 10106, type 230
        Extension Payload
        Decrypted XML (in Extension Payload)
        eXtensible Markup Language
            <?xml
            <Extension
                version="1.1">
                <binaryData>
                    1
                    </binaryData>
                </Extension>
        Main Payload
        Binary (in Main Payload)

The binary payload then continues for another 10 packets or so each with type 230 and with extension XML. At first check it doesn't appear the binary is just the jpg which the client saves to disk. I am unsure what format the binary data is.

twistedddx commented 3 years ago

There is also:


http://192.168.1.234/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=dfsew3e435ef&user=<user>&password=<pass>
Viish commented 3 years ago

There is also: http://192.168.1.234/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=dfsew3e435ef&user=&password=

Sadly as state on the Reolink support page (https://support.reolink.com/hc/en-us/articles/360007011233-How-to-Capture-Live-JPEG-Image-of-Reolink-Cameras-via-Web-Browsers) this doesn't work for Lumus cameras.