eufy-security-ws icon indicating copy to clipboard operation
eufy-security-ws copied to clipboard

How to download videos with audio?

Open ema-dev opened this issue 2 years ago • 3 comments

Ask your question

When I download a video using the "device.start_download" command, I only see "download video data" events and no "download audio data" events. I did some searching/Googling, but didn't find much of anything related to "download audio data" events besides what the documentation says, "This event is sent when audio data is received during a video download. It contains the metadata information and the video chunck."

Am I missing something or doing something wrong?

ema-dev avatar Apr 28 '22 16:04 ema-dev

Maybe due to the settings of your device no audio data is received or there is a bug ;) Either way, I can't help without debug logs.

bropat avatar May 15 '22 09:05 bropat

@bropat Can you provide instructions on how to obtain relevant logs?

ema-dev avatar May 15 '22 14:05 ema-dev

@bropat Here are some of the logs after download video events.

{
    "type": "event",
    "event": {
        "source": "driver",
        "event": "logging",
        "message": {
            "date": "2022-05-16T17:52:01.108Z",
            "logLevel": "debug",
            "logLevelId": 2,
            "filePath": "node_modules/eufy-security-client/src/p2p/session.ts",
            "fullFilePath": "/usr/src/app/node_modules/eufy-security-client/src/p2p/session.ts",
            "fileName": "session.ts",
            "lineNumber": 968,
            "columnNumber": 26,
            "isConstructor": false,
            "functionName": "parseDataMessage",
            "typeName": "P2PClientProtocol",
            "methodName": "parseDataMessage",
            "argumentsArray": [
                "Station redacted - Received data",
                "{ seqNo: 64716,\n  header: { commandId: 1301, bytesToRead: 293, channel: 3, signCode: 0, type: 0 },\n  bytesRead: 247,\n  bytesToRead: 293,\n  firstPartMessage: true,\n  messageSize: 1024 }"
            ]
        }
    }
}


{
    "type": "event",
    "event": {
        "source": "driver",
        "event": "logging",
        "message": {
            "date": "2022-05-16T17:52:01.108Z",
            "logLevel": "debug",
            "logLevelId": 2,
            "filePath": "node_modules/eufy-security-client/src/p2p/session.ts",
            "fullFilePath": "/usr/src/app/node_modules/eufy-security-client/src/p2p/session.ts",
            "fileName": "session.ts",
            "lineNumber": 802,
            "columnNumber": 30,
            "isConstructor": false,
            "functionName": "handleMsg",
            "typeName": "P2PClientProtocol",
            "methodName": "handleMsg",
            "argumentsArray": [
                "Station redacted - DATA BINARY - Received expected sequence (seqNo: 64716 queuedData.size: 0)"
            ]
        }
    }
}


{
    "type": "event",
    "event": {
        "source": "driver",
        "event": "logging",
        "message": {
            "date": "2022-05-16T17:52:01.108Z",
            "logLevel": "debug",
            "logLevelId": 2,
            "filePath": "node_modules/eufy-security-client/src/p2p/session.ts",
            "fullFilePath": "/usr/src/app/node_modules/eufy-security-client/src/p2p/session.ts",
            "fileName": "session.ts",
            "lineNumber": 788,
            "columnNumber": 26,
            "isConstructor": false,
            "functionName": "handleMsg",
            "typeName": "P2PClientProtocol",
            "methodName": "handleMsg",
            "argumentsArray": [
                "Station redacted - DATA BINARY - received from host redacted - Processing sequence 64717..."
            ]
        }
    }
}


{
    "type": "event",
    "event": {
        "source": "driver",
        "event": "logging",
        "message": {
            "date": "2022-05-16T17:52:01.109Z",
            "logLevel": "debug",
            "logLevelId": 2,
            "filePath": "node_modules/eufy-security-client/src/p2p/session.ts",
            "fullFilePath": "/usr/src/app/node_modules/eufy-security-client/src/p2p/session.ts",
            "fileName": "session.ts",
            "lineNumber": 968,
            "columnNumber": 26,
            "isConstructor": false,
            "functionName": "parseDataMessage",
            "typeName": "P2PClientProtocol",
            "methodName": "parseDataMessage",
            "argumentsArray": [
                "Station redacted - Received data",
                "{ seqNo: 64717,\n  header: { commandId: 1301, bytesToRead: 293, channel: 3, signCode: 0, type: 0 },\n  bytesRead: 293,\n  bytesToRead: 293,\n  firstPartMessage: false,\n  messageSize: 1024 }"
            ]
        }
    }
}


{
    "type": "event",
    "event": {
        "source": "driver",
        "event": "logging",
        "message": {
            "date": "2022-05-16T17:52:01.109Z",
            "logLevel": "debug",
            "logLevelId": 2,
            "filePath": "node_modules/eufy-security-client/src/p2p/session.ts",
            "fullFilePath": "/usr/src/app/node_modules/eufy-security-client/src/p2p/session.ts",
            "fileName": "session.ts",
            "lineNumber": 1229,
            "columnNumber": 30,
            "isConstructor": false,
            "functionName": "handleDataBinaryAndVideo",
            "typeName": "P2PClientProtocol",
            "methodName": "handleDataBinaryAndVideo",
            "argumentsArray": [
                "Station redacted - CMD_AUDIO_FRAME",
                "{ dataSize: 293,\n  metadata: { audioType: 0, audioSeqNo: 305, audioTimestamp: 20066, audioDataLength: 277 },\n  audioDataSize: 277 }"
            ]
        }
    }
}

ema-dev avatar May 16 '22 18:05 ema-dev

@bropat I upgraded to... { "type": "version", "driverVersion": "2.2.0", "serverVersion": "1.0.0", "minSchemaVersion": 0, "maxSchemaVersion": 13 }

and after I start listening and set the API schema... { "command": "set_api_schema", "messageId": 1, "schemaVersion": 13 }

I send the start download command... { "messageId": 1, "command": "device.start_download", "serialNumber": "serialnumber", "path": "path/to/file", "cipherId": # }

I receive the following response... { "type": "result", "success": true, "messageId": 1, "result": { "async": true } }

When I downgrade to... { "type": "version", "driverVersion": "2.1.2", "serverVersion": "0.9.4", "minSchemaVersion": 0, "maxSchemaVersion": 12 }

set the API schema to 12 and send the same download command as above, I receive the following responses... { "type": "event", "event": { "source": "device", "event": "command result", "serialNumber": "serialnumber", "command": "start_download", "returnCode": 0, "returnCodeName": "ERROR_PPCS_SUCCESSFUL" } }

followed by lots of "download video data" events as expected... { "type": "event", "event": { "source": "device", "event": "download video data", "serialNumber": "serialnumber", "buffer": { "type": "Buffer", "data": [data here] }, "metadata": { "videoCodec": "H265", "videoFPS": 10, "videoHeight": 1920, "videoWidth": 2560 } } }

Is there something I need to change for schema version 13 on driverVersion: 2.2.0 and serverVersion: 1.0.0 to receive the download video/audio events?

ema-dev avatar Nov 02 '22 17:11 ema-dev

@ema-dev No, you do not have to change anything for schema version 13. I think the problem is in the driver. Activate the debug mode and see if there are any errors.

bropat avatar Nov 02 '22 17:11 bropat

@bropat I activated debug mode. I couldn't find any errors. When I send the start download command nothing related to it shows in the container logs. Doing the same thing on the previous version works as expected and shows in the logs.

ema-dev avatar Nov 02 '22 18:11 ema-dev

@ema-dev

When I send the start download command nothing related to it shows in the container logs.

You mean no command is sent at all?

bropat avatar Nov 02 '22 20:11 bropat

@bropat I'm using Postman to connect and send commands. When I send a command using Postman I receive responses, as I've provided them above. When viewing the logs from the containers (previous and latest) while DEBUG=true, I do not see the commands I send via Postman showing up in the logs (not sure if they're supposed to). The container logs show when my Postman client connects and disconnects to both versions of the container (previous version and latest version...I'm not running them at the same time). The container with the previous version will show binary data being transferred when the download command is sent, but the latest version does not.

ema-dev avatar Nov 02 '22 20:11 ema-dev

I looked at the code of eufy-security-client, as nothing has been changed on eufy-security-ws that would be related to this, and found a regression that was introduced with the support of the new Homebase 3. I will fix this in the next version.

bropat avatar Nov 02 '22 22:11 bropat

@bropat Thank you!

ema-dev avatar Nov 02 '22 22:11 ema-dev