brutella / hkcam

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

multiple video streams, loopback to video1 should be converted? #40

Closed mgoeller closed 4 years ago

mgoeller commented 5 years ago

As far as I understand, if the multiple video streams option is activated, the stream can be received from two devices at the same time. In this case the input /dev/video0 is loopbacked to /dev/video1 with the ffmpeg argument "-codec:v copy". When two devices access the stream now, the same data is converted two times in parallel to h264. Wouldn't it make more sense to convert the stream once (and continuously running in this case) to h264 and loop it back to /dev/video1 and provide this with the argument "-codec:v copy" then to multiple receivers? This would require less processing in my understanding.

looxonline commented 5 years ago

Are the encoding parameters guaranteed to be the same for both devices? E.G. does the apple watch not use a lower res encode. If the encode is always the same then this is a good strategy. I used it when I needed to stream a live program to an Akamai ingest point in 16 different languages. Encoded the video once and then piped that to another FFMPEG instance and mapped it to each audio stream.

brutella commented 5 years ago

There is no guarantee that the requested video stream has a specific resolution or bit rate. Apple Watch is a good point because it requests a low-res video stream.

That's the reason why I'm hesitant to implement the suggested improvement.