guysoft / OctoPi

Scripts to build OctoPi, a Raspberry PI distro for controlling 3D printers over the web
GNU General Public License v3.0
2.49k stars 369 forks source link

Possible PR proposal: Webcamd with support for multiple streaming implementations #782

Open cp2004 opened 2 years ago

cp2004 commented 2 years ago

a 'webcamd v2', if you like.

A while ago I had an idea, with a lot of talk around streaming software about on discord (adding ustreamer, webrtc etc.) that webcamd would need a bit of work to support multiple streamers.

Currently, it supports multiple webcams OK, but the code is a bit confusing (at least for me) so the thought of adding an extra dimension didn't make me feel that good. So I came up with this 'idea' that seemed to make sense to me.

Core webcamd

What is currently known as webcamd remains the main service. It iterates over the configuration files provided (both /boot/octopi.txt and /boot/octopi.conf.d/*.txt as it does now. Each file can have a new camera_streamer variable, that is either mjpg, hls, ustreamer, webrtc etc. etc.

It iterates through the files and calls a subscript, such as webcamd-mjpg, which handles the rest of the configuration and actually starting mjpg-streamer. This can be done for as many config files as there are.

Prototype

I also played around with this idea a few evenings ago. I have a concept here https://github.com/cp2004/OctoPi/commit/03228838fedf9677489d0afb32a9491a95e7d2fa - it does not completely work but I hope it illustrates the idea I'm working on

Benefits

Thoughts?

I don't have a huge amount of time to convert it into a working PR, but I thought I would post this issue to get some feedback on the idea, to see if it is worth me working on a proper implementation and submitting a PR in the future.

Of course, the answer could be 'no' as well 🙂 - that's why I'm asking before properly working on such a large rewrite of the setup.

guysoft commented 2 years ago

Looks cleaner, did you test it?

cp2004 commented 2 years ago

I haven't tried it with proper cameras connected as I only have one available at the moment. I got it up to the point of printing the mjpg-streamer line it would run if it could do so, and it looks OK.

cp2004 commented 2 years ago

I am working on this, but progress will be very slow until later in the summer. It is not far from being able to work flawlessly (I hope!), but I got distracted trying to integrate HLS as well. Branch is cp2004/OctoPi/webcamd-v2. Developing it with an actual camera attached now...

I may make a PR for the updated webcamd for just mjpg streamer initially, then follow up with adding HLS and also ustreamer. Eventually I would also like to add a webrtc stream option, but I haven't manged to get anything functional other than a slightly dodgy stream from aiortc.

guysoft commented 10 months ago

Guess this got stuck?