samemory / homebridge-eufy-security

Work in progress
Apache License 2.0
97 stars 14 forks source link

[Bug]: FFmpeg exited with code: 1 and signal: null (Error) Doorbell #295

Closed SteveW25561 closed 2 years ago

SteveW25561 commented 2 years ago

What happened?

Eufy doorbell (2K wired) is paired with Homebase 2. The iOS Eufy app works perfectly, and the Homekit native support works for the 2 cameras also associated with the Homebase2. I was really wanting the doorbell so I installed this plugin under Homebridge.

I've tried installing the plugin under homebridge running as a Docker on Synology but also a fresh install on my Mac, and no matter which install I do, I get this error when trying to use the Doorbell camera:

[12/5/2021, 12:59:08 AM] [EufySecurity] Adding new accessory: Homebase [12/5/2021, 12:59:08 AM] [EufySecurity] Adding new accessory: Doorbell [12/5/2021, 12:59:45 AM] [EufySecurity] Starting video stream: 1280 x 720, 30 fps, 299 kbps (AAC-eld) Doorbell [12/5/2021, 12:59:45 AM] [EufySecurity] FFmpeg exited with code: 1 and signal: null (Error) Doorbell [12/5/2021, 12:59:45 AM] [EufySecurity] Stopped video stream. Doorbell [12/5/2021, 12:59:52 AM] [EufySecurity] Starting video stream: 1280 x 720, 30 fps, 299 kbps (AAC-eld) Doorbell [12/5/2021, 12:59:52 AM] [EufySecurity] FFmpeg exited with code: 1 and signal: null (Error) Doorbell [12/5/2021, 12:59:52 AM] [EufySecurity] Stopped video stream. Doorbell

The thumbnail shows an old image from the last motion event but touching it just gives a spinner and these errors.

I reinstalled/installed ffmpeg on my M1Pro Macbook Pro using brew install ffmpeg and sudo npm i ffmpeg-for-homebridge -g

Device Type

Doorbell (Supported)

Plugin Version

v1.0.x (Supported)

HomeBridge Version

v1.3.x (Supported)

NodeJS Version

v16 (Supported)

Operating System

Mac OS X

Relevant log output

[12/5/2021, 12:59:07 AM] Homebridge v1.3.8 (HAP v0.9.7) (Homebridge xxx) is running on port 51731.
[12/5/2021, 12:59:08 AM] [EufySecurity] Adding new accessory: Homebase
[12/5/2021, 12:59:08 AM] [EufySecurity] Adding new accessory: Doorbell
[12/5/2021, 12:59:45 AM] [EufySecurity] Starting video stream: 1280 x 720, 30 fps, 299 kbps (AAC-eld) Doorbell
[12/5/2021, 12:59:45 AM] [EufySecurity] FFmpeg exited with code: 1 and signal: null (Error) Doorbell
[12/5/2021, 12:59:45 AM] [EufySecurity] Stopped video stream. Doorbell
[12/5/2021, 12:59:52 AM] [EufySecurity] Starting video stream: 1280 x 720, 30 fps, 299 kbps (AAC-eld) Doorbell
[12/5/2021, 12:59:52 AM] [EufySecurity] FFmpeg exited with code: 1 and signal: null (Error) Doorbell
[12/5/2021, 12:59:52 AM] [EufySecurity] Stopped video stream. Doorbell
github-actions[bot] commented 2 years ago

Did you check this Common Issues pages ?

SteveW25561 commented 2 years ago

Yes - unfortunately none of those worked - my doorbell is associated with the Homebase, but if I tell the plugin to ignore the Homebase, it strikes out the attached doorbell as well, then nothing shows up in Homekit.

As mentioned above for Livestream issues, I also did do sudo npm i ffmpeg-for-homebridge -g and still the same "FFmpeg exited with code: 1 and signal: null (Error) Doorbell" error.

So, in summary I tried both suggestions under the "Livestream" and "Wired Doorbell" sections.

agrieco commented 2 years ago

I'm having the same issue.

wearepixelate commented 2 years ago

Exact same issue for me, only other item of note for me at least is I'm running the latest version of node, it doesn't say on this plugin that it's supported though...

rafaelmagu commented 2 years ago

It appears to have started with the update to 1.0.6. I tried rolling back to 1.0.4 but now am getting the '204 No Content' error from Eufy's API that https://github.com/samemory/homebridge-eufy-security/commit/481e16f07ac2a2d4c24700efad5846aaf051df41 fixed.

rafaelmagu commented 2 years ago

It seems the error appears as soon as the plugin tries to run FFmpeg on the stream itself. I enabled debug logging and found the following command is called right before the error message appears:

/homebridge/node_modules/homebridge-eufy-security/node_modules/ffmpeg-for-homebridge/ffmpeg -i  -an -sn -dn -codec:v libx264 -pix_fmt yuv420p -color_range mpeg -r 30 -f rawvideo -preset ultrafast -tune zerolatency -filter:v scale='min(1280,iw)':'min(720,ih)':force_original_aspect_ratio=decrease,scale=trunc(iw/2)*2:trunc(ih/2)*2 -b:v 299k -payload_type 99 -ssrc 4494580 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params some_hash_here srtp://172.16.1.101:52653?rtcpport=52653&pkt_size=1316 -vn -sn -dn -codec:a aac -profile:a aac_eld -flags +global_header -f null -ar 16k -b:a 24k -ac 1 -payload_type 110 -ssrc 2157077 -f rtp -srtp_out_suite AES_CM_128_HMAC_SHA1_80 -srtp_out_params some_other_hash_here srtp://172.16.1.101:54716?rtcpport=54716&pkt_size=188 -loglevel level -progress pipe:1

I stripped some hashes from the command above in case they're sensitive. Note that there's some extra space between -i and -an, where presumably a stream source would be. It looks like it is missing, given this piece of code:

https://github.com/samemory/homebridge-eufy-security/blob/master/src/accessories/streamingDelegate.ts#L349

After some careful editing of the command to include quotes around some arguments, I ran it manually and got the following FFmpeg error, also with an exit code of 1:

[error] -an: No such file or directory

I suspect that I'm missing something still, and am keen to continue debugging.

aklausing commented 2 years ago

The same issue here. HomeBridge in docker. Also tried to move back to an older version of the container image. No chance. Stream isn't working with 1.0.6 ... plugin is crashing with 1.1.1 beta.

fullphat commented 2 years ago

You're right about the double space between the -i and -an arguments. The RTMP stream url used to be there but for some reason it's now missing. I think this might be due to a move to P2P streaming that's doesn't seem to work when rolling the plugin back from some reason. I'm sure that why ffmpeg is giving the error you've pasted at least.

You might want to try the beta version - it doesn't work for me, but I only have the floodlight camera which doesn't seem to be properly supported yet.

njuart commented 2 years ago

You're right about the double space between the -i and -an arguments. The RTMP stream url used to be there but for some reason it's now missing. I think this might be due to a move to P2P streaming that's doesn't seem to work when rolling the plugin back from some reason. I'm sure that why ffmpeg is giving the error you've pasted at least.

You might want to try the beta version - it doesn't work for me, but I only have the floodlight camera which doesn't seem to be properly supported yet.

Beta actually works, at least on my 2k camera, stream starts, but after I stop stream HB restarts straight away. So as suggested somewhere above, really temporary and "some sort of working" solution can be to convert plugin to child bridge, so it won't break HB totally and will just quickly restart child bridge. Still not the best UX option.

chazeon commented 2 years ago

You're right about the double space between the -i and -an arguments. The RTMP stream url used to be there but for some reason it's now missing. I think this might be due to a move to P2P streaming that's doesn't seem to work when rolling the plugin back from some reason. I'm sure that why ffmpeg is giving the error you've pasted at least.

You might want to try the beta version - it doesn't work for me, but I only have the floodlight camera which doesn't seem to be properly supported yet.

I believe this is related to an upstream issue. See the following: https://github.com/bropat/eufy-security-client/issues/79

njuart commented 2 years ago

You're right about the double space between the -i and -an arguments. The RTMP stream url used to be there but for some reason it's now missing. I think this might be due to a move to P2P streaming that's doesn't seem to work when rolling the plugin back from some reason. I'm sure that why ffmpeg is giving the error you've pasted at least. You might want to try the beta version - it doesn't work for me, but I only have the floodlight camera which doesn't seem to be properly supported yet.

I believe this is related to an upstream issue. See the following: bropat/eufy-security-client#79

OMG, IT WORKS, at least just right after I've made a change I finally saw white Eufy preloader and stream! Just checked and used your workaround, removed "User-Agent": "okhttp/3.12.1". It worked like a charm. Thx a lot and much appreciated. Just in case, in my setup, file that I've tweaked is located here:

/usr/local/lib/node_modules/homebridge-eufy-security/node_modules/eufy-security-client/build/http/api.js

rafaelmagu commented 2 years ago

@njuart did you install the beta version, then edited the api.js file?

njuart commented 2 years ago

@njuart did you install the beta version, then edited the api.js file?

Nope, not related to beta, as beta uses local streaming, I've rolled back to 1.0.6 and tweaked file.

rafaelmagu commented 2 years ago

@njuart did you install the beta version, then edited the api.js file?

Nope, not related to beta, as beta uses local streaming, I've rolled back to 1.0.6 and tweaked file.

I can confirm that, installing 1.0.6 and editing the api.js file as per https://github.com/bropat/eufy-security-client/issues/79 to remove the User-Agent key from the payload, then restarting Homebridge, works.

njuart commented 2 years ago

Also, plz note, that out of like 15-20 attempts I saw stream only 3 times, but it's a known issue. Just giving a heads up if after fix you won't see stream straight away, keep trying. Also error in HB logs disappeared.

MrTomAsh commented 2 years ago

I can't find the origin of this function:

 async startStream() {
        // Start the camera stream and return the RTSP URL.
        try {
            const response = await this.api.request("post", "v1/web/equipment/start_stream", {
                device_sn: this.rawDevice.device_sn,
                station_sn: this.rawDevice.station_sn,
                proto: 2
            }).catch(error => {
                this.log.error("Error:", error);
                return error;
            });
            this.log.debug("Response:", response.data);
            if (response.status == 200) {
                const result = response.data;
                if (result.code == 0) {
                    const dataresult = result.data;
                    this._isStreaming = true;
                    this.log.info(`Livestream of camera ${this.rawDevice.device_sn} started`);
                    return dataresult.url;
                }
                else {
                    this.log.error("Response code not ok", { code: result.code, msg: result.msg });
                }
            }
            else {
                this.log.error("Status return code not 200", { status: response.status, statusText: response.statusText });
            }
        }
        catch (error) {
            this.log.error("Generic Error:", error);
        }
        return "";
    }

And it seems to be causing all the problems with the stream.

I've tried another plugin and streaming works there as a charm. Can you guys help me find the location of the above? The thing in common is that both plugins receive a quite old snapshot. Is there any way to enforce eufy to refresh the snapshot before the call?

schliemann commented 2 years ago

New screenshot can only be achieved through local streaming which is in the beta. But not working reliably.

TimBroddin commented 2 years ago

editing api.js fixes the issue!

schliemann commented 2 years ago

I'll make a PR when bropat fixes the client library.

kunwarsethi commented 2 years ago

Worked for me on 1.0.6.

On the Homebridge Terminal Type:

  1. cd /usr/local/lib/node_modules/homebridge-eufy-security/node_modules/eufy-security-client/build/http/
  2. sudo nano api.js
  3. Use arrow keys to go down and remove the line "User-Agent": "okhttp/3.12.1"
  4. Ctrl + X to exit, Y for yes, Enter to save.
  5. Restart Homebridge, doorbell cam should work now.
qthatswho commented 2 years ago

Confirmed, this restored video stream from the doorbell for me following the steps above.

schliemann commented 2 years ago

Version 1.0.8 published. Resolved issue.

Rubl80 commented 2 years ago

Anybody else still experiencing issues, after updatting to 1.0.8??

I don't get the error any longer, and it does works intermittently.. But most of the time the live steam doesn't start, and the log says the following:

[22.12.2021 12.13.18] [EufySecurity] Starting video stream: 1280 x 720, 30 fps, 299 kbps (AAC-eld) Doorbell [22.12.2021 12.13.46] [EufySecurity] Stopped video stream. Doorbell

Also the thumbnail picture isn't updating every 10sec. For the first 10sec it stays on the last live stream image (when I manage to get a live stream), before going back to an older thumbnail picture.

Carniphage commented 2 years ago

Not sure what I am doing wrong, but I am seeing this as soon as I try to view a camera ...

[12/22/2021, 3:59:05 PM] [EufySecurity-1.0.8] DEBUG: Video stream requested: 1920 x 1080, 30 fps, 802 kbps Doorbell false
[12/22/2021, 3:59:05 PM] [EufySecurity-1.0.8] INFO:  Starting video stream: 1920 x 1080, 30 fps, 802 kbps (AAC-eld) Doorbell
[12/22/2021, 3:59:05 PM] [EufySecurity-1.0.8] DEBUG: Stream command: ffmpeg -i rtmp://p2p-vir-8.eufylife.com XXXX REDACTED XXX -loglevel level -progress pipe:1 Doorbell false
[12/22/2021, 3:59:07 PM] [EufySecurity-1.0.8] ERROR: FFmpeg exited with code: null and signal: SIGABRT (Unexpected) Doorbell
spanl commented 2 years ago

Not resolved for me :(

[12/22/2021, 2:13:49 PM] [EufySecurity-1.0.8] ERROR: FFmpeg process creation failed: spawn ffmpeg ENOENT Doorbell

OK, it turns out I have to install ffmpeg separately.

schliemann commented 2 years ago

Yeah. Also you should add --unsafe-pem when installing. Atleast it refused to install the ffmpeg binary otherwise.