[WIP] Multiple Webcam streams in Control (Multicam)

It sounds like you may need to add the webcam under the settings for multicam.

For my setup (also using C270 webcam) i have a second RPI running motionEyeOs which is basically just a webcam server for the cams, under the settings for multicam i use the rpi local ip with the port for the cam it will stream on. Then provide that url and port into the plugin settings.

Let me know how that works for you

The default button wont seem to do anything until other cams are adding through the settings, since the default is there just to return back to the original stream that is setup on your octoprint instance. Right now this plugin does not capture any cameras you may have attached to it and requires a little more setup to get working. My reason for this is because i noticed having more than one webcam on the same pi that is running octoprint can cause your prints to have some issues do to the overhead they create while running them.

It's plugged right into the RPi...

So, I guess I should be looking at /dev to find both of the addresses ?

you will need to input the full url of the stream. including http:// or else the stream will not update. You should be able to use the ip of the pi you have setup if you are wanting it directly on the same device. You might have to setup/install mjpg-streamer and figure out what port that is streaming your cams to, however i do not have much experience with that.

As for the first cam showing /webcam/?action=stream that is the default from the webcam & timelapse tab, so it may or may not work correctly. I forgot that was how the default stream was setup and will have to make some changes to get my plugin to work correctly with a url formatted that way.

Well, to answer your last query, the original C270 is working fine

I'm poking around trying to figure out some kind of address for the Creative

It should work fine for now, but as soon as you add a new webcam and try to switch back and forth you will definitely run into some issues since all my plugin does is update the image tag src, but from my test it seems if you forget the http:// it just appends what ever address you have onto the end. So as soon as you navigate to another url/port it will just add the /webcam/?action=stream onto the end of that url which would not change the stream. Ill look into this though and try to get it to add the ip from the local device if the http is not present, that should solve that problem. Definitely let me know how it goes though.

Local cameras may be something i look into for the future, however keep in mind what i mentioned before about the overhead. Running too many cams on the same pi can slow it down causing issues while printing. That was at least my experience with just one HD webcam on the same device i run octoprint on, i do however also have quite a few plugins running too.

Well, I also have a separate standalone camera

It's a foscam, but, I've not yet been able to just pluck out only the cam stream

I'll try adding the URL, and see what happens, but, I'm pretty sure I've already been down this road with this particular item

It may not be a mjpeg format. That seems to be the requirement at the moment for octoprint. I would like to add more support for other streams to my plugin in the future as well. However that is going to be way more work and might take some time to get it all setup correctly.

I can't seem to find the filetype at the moment. So I tried doing a send from the cam to the RPi, but, unfortunately, the cam is so old it only uploads via ftp. I tried changing the port to 22, but, it didn't like that either

I did find a MUX tho, but, sadly, it's a separate addon board

Lemme try a few more things...

Okay, first off, I can't see how my foscam will work, since you'd need username password just to get to it in the first place. Secondly, it looks like it's being output in cgi (I think)

But, I think I found some code to get 2 USB cams to load at the same time, and you should be able to switch between them with this...


But, instead of loading different streams from different IP's using the interface you created, you'll be using python to switch the streams internally to the PI itself, then outputting a single mjpeg from a single PI

Wanted to share that i just pushed a new version. However there seemed to be an issue with my migration code for a small addition to the data. If you are seeing errors in the console about a missing isButtonEnabled function you will either have to add 'isButtonEnabled: true' to each profile, or removing everything under multicam and reload octoprint, which will fix the issue. Anyone who is installing for the first time should not have this issue, uninstalling and reinstall does not fix it.

I took a look at how a few other plugins are handling migration to get an idea of how to fix this, however nothing seems to work. Anyone have any idea what may be going wrong? Here is a snipplet from my _init_.py to show what i already tried.

    def on_settings_migrate(self, target, current=None):
        if current is None or current < 1:
            # Reset plug settings to defaults.
            self._settings.set(['multicam_profiles'], self.get_settings_defaults()["multicam_profiles"])

    def get_settings_defaults(self):
        return dict(multicam_profiles=[{'name':'Default','URL':octoprint.settings.settings().get(["webcam","stream"]), 'isButtonEnabled':'true'}])

@Spyder hmm, ok. im going to have to work with python more. Most my issues seem to stem from not understanding how to use it completely. Im mostly work with html, php, and javascript at my company, so some of this is a little new to me.

It may be possible to hardcode the username/password in a pull from your foscam, maybe something like http://username:password@ or perhaps videostream.cgi?user=username&pwd=password.

I'll give that a shot in a little bit

Just did a nuke & pave on both printers and I haven't got my plugins plugged in yet

Okay, that was a good idea. Didn't work tho

And my nuke didn't seem to help my problem either.

I used to have the temp for the hotend and bed listed on the navbar, and they vanished after I installed the multicam plugin. I nuked them both, reinstalled the navbar temp plugins (without the multicam plugin) and it's still gone on both printers

I didn't do a restore from a saved copy, I did a fresh load with tonights daily 15.1 so I guess a restore is in order... once the current prints I've got going finish

Did you define get_settings_version in your init file? Something like this.


I had not, that seems to have fixed the issue though. Thank you!

@Spyder Im not sure if it was my plugin that caused that, but with the data migration issues there were quite a few issues in the console so its not impossible. The new update (0.2.2) should have that all fixed now though if you want to try to update and see if it fixes your issue before completely restoring. Otherwise you may have something else that is causing the problem.

I did a fresh load and didn't install your plugin. I'm not sure I see how your plugin could have affected the fresh load

I havent installed this plug in yet and am already thankful. Thanks so much for tackling this. You are awesome!

AHA !!

I got something. Now, it's not exactly a solution to the project you were working on, but, it does do something neat

Here's the setup... I have 2 printers
Each running Octopi and Octoprint
Each has it's own camera
I installed your plugin
Then I installed a program called "motion" ON THE REMOTE MACHINE (target)
(where's the "code" button ?)
sudo apt-get install motion
then, edit the motion.conf
sudo nano /etc/motion/motion.conf
We're editing this... DAEMON = OFF (change to ON)
Save, then we wanna edit this...
sudo nano /etc/default/motion
And you wanna change this start_motion_daemon = no (change to yes)
The default port is 8081, but, that's not what we really want. All we want is the stream from the camera, so we want port 8080

Now, here's an issue I ran into. I inputted the address into the multicam plugin by clicking on the plus sign, which gave me a new place to add another camera, and I plugged in the direct address to the camera stream, then clicked the save button.

BUT, for some reason, I don't know if it's the plugin, or an issue with Octoprint itself, but, it automatically added /webcam/?action/stream to the URL I typed, and that just wasn't what I wanted. BUT, I found out that if you enter the URL, then click on the plus sign again, it opens a new option to add another cam, but, it leaves the URL I typed in the first block alone.

After that, I can click save, and go back, and delete the empty slot

Whoo Hoo !

Now I can do this...

and this...

Not sure if you can tell from the pictures, but, that's two different printers on the same instance of Octoprint

Not exactly what you wanted, but, it's a step in the right direction :slight_smile:

I'm trying to get this working by adding a second mjpg_streamer instance, (which is working fine) but for some reason haproxy's config won't add a new forward to the second camera:

backend webcam
        reqrep ^([^\ :]*)\ /webcam/(.*)     \1\ /\2
        server webcam1
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

backend webcam-alt
        reqrep ^([^\ :]*)\ /webcam-alt/(.*)     \1\ /\2
        server webcam-alt
        errorfile 503 /etc/haproxy/errors/503-no-webcam.http

then I'm trying to access it with http://localhost/webcam-alt/?action=stream which doesnt work, however http://ip_of_octoprint:8081/?action=stream does work. Just to be clear I have restarted haproxy service multiple times while trying to figure this out