moritzmhmk / homebridge-camera-rpi

raspberry pi camera plugin for homebridge
MIT License
159 stars 29 forks source link

Multiple video device support #51

Open milmber opened 5 years ago

milmber commented 5 years ago

Support for multiple people to view streams using v4l2loopback

Iterate over multiple video devices if the first device is not available.

E.g. Try /dev/video1, if busy try /dev/video2, if busy try /dev/video3, etc.

This may be possible by adding the video device in use for streaming in the ongoingSessions array ? https://github.com/moritzmhmk/homebridge-camera-rpi/blob/4474cf5485ae43d98d3fdc6a406b7a0857ba9aad/CameraSource.js#L193

moritzmhmk commented 5 years ago

Great idea! Did you have any success so far?

milmber commented 5 years ago

Great idea! Did you have any success so far?

Struggling to find a way to detect if a video device is already in use. Any ideas?

moritzmhmk commented 5 years ago

as noted in #50 I do consider to aim for optimal Pi zero support from now on. The reason is that using h264_omx seems to be the better solution on newer Pis.

While with h264_omx one would redirect the raw stream to multiple video device endpoints we would need to redirect the h264 stream from the camera. This would require setting the resolution and for all clients to receive that same resolution (e.g. 720p).

Keeping track of the used video devices could be done with another array that just holds a boolean value and is set when stream starts/stops on a specific device. If you take a look at the develop branch on wich I did some refactoring you will see that there now is a separate StreamDelegate object which could be assigned a specific video device and make tracking them unnecessary.

jankais3r commented 5 years ago

This would require setting the resolution and for all clients to receive that same resolution (e.g. 720p).

What is prohibiting us running this multiplied stream through ffmpeg with corresponding parameters to resize the stream to match every device's requirements?

moritzmhmk commented 5 years ago

Check https://github.com/moritzmhmk/homebridge-camera-rpi/tree/feature-loopback for a possible solution.

Resizing each stream would cause a lot of cpu usage... might still work on a pi model 3