brutella / hkcam

Open-Source HomeKit Surveillance Camera
https://hochgatterer.me/hkcam/
Apache License 2.0
925 stars 141 forks source link

hundreds of defunct ffmpeg processes over night #45

Closed chrismarquardt closed 3 years ago

chrismarquardt commented 5 years ago

Yesterday I've updated my two hkcams to 0.0.9 and had them run over night, with Apple's Home app running on my Mac, displaying the output of both cameras. Today, live video wouldn't start on both hkcams, while the regular snapshots would still come in.

I ssh-ed into the systems to find a large number of defunct ffmpeg processes:

root      1397   464  0 00:39 ?        00:00:02 [ffmpeg] <defunct>
root      1399   464  0 00:40 ?        00:00:02 [ffmpeg] <defunct>
root      1401   464  0 00:40 ?        00:00:02 [ffmpeg] <defunct>
root      1403   464  0 00:40 ?        00:00:02 [ffmpeg] <defunct>
root      1405   464  0 00:40 ?        00:00:02 [ffmpeg] <defunct>
root      1408   464  0 00:41 ?        00:00:02 [ffmpeg] <defunct>
root      1410   464  0 00:41 ?        00:00:02 [ffmpeg] <defunct>

In case of one camera, within 11 hours, there were over 500 of these.

Parent of those defunct processes is hkcam --data_dir=/var/lib/hkcam/data --verbose=true

Here's my configuration:

wpa_supplicant.conf:

country=DE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="MYSSID"
scan_ssid=1
psk="MYPASSWORD"
key_mgmt=WPA-PSK
}

/etc/sv/hkcam/run:

#!/bin/sh -e
exec 2>&1
v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=YU12
exec hkcam --min_video_bitrate=500 --data_dir=/var/lib/hkcam/data --verbose=true

I thought the min bitrate setting was the culprit, but removing --min_video_bitrate=500 from /etc/sv/hkcam/run and rebooting didn't seem to have an effect on the growth rate of defunct ffmpeg processes.

The number of ffmpeg defunct processes only seems to grow if I poll the camera snapshots via an app. (Apple's home app or other doesn't matter). The number will not grow if nothing asks for camera output.

Let me know if you'd like any debug information.

emiellensink commented 4 years ago

Same issue here, with all settings left default.

brutella commented 3 years ago

Should be fixed now with c20bcd1