brutella / hkcam

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

Wait until ffmpeg loopback feed is ready #60

Closed tkintscher closed 3 years ago

tkintscher commented 4 years ago

This patch will make loopback.Start() block until ffmpeg is actually feeding the loopback device.

I have a Logitech C270 connected to a Raspberry Pi 3B+ and the ffmpeg copy process sometimes takes several seconds to initialize. In cases where the hardcoded 1 second wait is too short, the subsequent ffmpeg rtp stream will fail. The PR fixes these issues for me.

brutella commented 3 years ago

I think your implementation has a memory issue by keeping writing into the buffer forever. I've done something similar in 333a744 but tried to keep the memory usage low.