Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not detect disconnects #46

Open
paulz opened this issue Jan 16, 2019 · 6 comments
Open

Does not detect disconnects #46

paulz opened this issue Jan 16, 2019 · 6 comments

Comments

@paulz
Copy link

paulz commented Jan 16, 2019

Thank you for the great component!

When HomeKit connection is lost the video stream is still getting sent. This prevents me from reconnecting to the camera, as the camera device is already busy.

How to test:

  1. Connect the Raspberry Pi over ssh to monitor logs:
    journalctl --follow -u hap-camera-rpi.service -b
  2. Connect to the camera on iPhone and see LIVE orange sign in the corner indicating the live stream
  3. Observe that log is showing ffmpeg decoded frames like:
Jan 16 19:55:20 cameraberry node[700]: ffmpeg frame=16489 fps= 30 q=-1.0 size=   20211kB time=00:09:09.27 bitrate= 301.4kbits/s speed=   1x
Jan 16 19:55:21 cameraberry node[700]: ffmpeg frame=16505 fps= 30 q=-1.0 size=   20262kB time=00:09:09.80 bitrate= 301.9kbits/s speed=   1x
Jan 16 19:55:21 cameraberry node[700]: ffmpeg frame=16520 fps= 30 q=-1.0 size=   20266kB time=00:09:10.30 bitrate= 301.7kbits/s speed=   1x
Jan 16 19:55:22 cameraberry node[700]: ffmpeg frame=16535 fps= 30 q=-1.0 size=   20271kB time=00:09:10.80 bitrate= 301.5kbits/s speed=   1x
Jan 16 19:55:22 cameraberry node[700]: ffmpeg frame=16550 fps= 30 q=-1.0 size=   20286kB time=00:09:11.30 bitrate= 301.4kbits/s speed=   1x
  1. Put iPhone into the airplane mode, naturally video stream stops.
  2. Observe that log is still showing frames output even there is no connection to the iPhone
  3. Turn airplane mode off on iPhone
  4. Open camera on iPhone HomeKit and notice "No Response" message - "This camera is not responding"

What I was expecting after the iPhone goes offline frames stop and when iPhone goes back online video stream resumes.

@paulz
Copy link
Author

paulz commented Jan 16, 2019

Also notice that log is showing that the device is busy when trying to watch the camera again:
Jan 16 19:59:29 cameraberry node[700]: ffmpeg /dev/video0: Device or resource busy

@paulz
Copy link
Author

paulz commented Jan 16, 2019

To workaround hanging video stream issue I have to ssh to the raspberry pi and restart the service:

sudo systemctl stop hap-camera-rpi
sudo systemctl start hap-camera-rpi

@paulz
Copy link
Author

paulz commented Jan 16, 2019

To give more context I am using standalone mode on Raspberry Pi Zero W, following instructions on wiki.

I've tried both versions of ffmpeg:

  1. sudo apt install ffmpeg
  2. Rebuild ffmpeg using hardware acceleration using these instructions: https://github.com/legotheboss/YouTube-files/wiki/(RPi)-Compile-FFmpeg-with-the-OpenMAX-H.264-GPU-acceleration which gave me much better CPU utilization (from 60% down to 5%)

@paulz
Copy link
Author

paulz commented Jan 17, 2019

The same issue of hanging unused video stream can also be reproduced for me by walking with iPhone between access points, even on the same network. Similar to what is described in #28

@paulz
Copy link
Author

paulz commented Jan 17, 2019

As a workaround, I am restarting the standalone service every 5 minutes to stop hanging video stream:
by adding RuntimeMaxSec=300 parameter.

cat /etc/systemd/system/hap-camera-rpi.service

[Unit]
Description=HAP Camera RPi

[Service]
ExecStart=/usr/local/bin/node /opt/homebridge-camera-rpi/standalone.js -c /etc/homebridge-camera-rpi.conf.json
WorkingDirectory=/opt/homebridge-camera-rpi
Restart=always
RestartSec=10
RuntimeMaxSec=300
User=pi

[Install]
WantedBy=multi-user.target

@michaelbublat
Copy link

Same issue here. With the homebridge (not standalone) version. This bug makes this (very nice plugin) almost unusable :/

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

No branches or pull requests

3 participants