Webcam On-Off Option

It would be nice if the admin could have a control to turn the webcam on/off. This would allow control / privacy without having to plug or unplug the webcam from the Pi while still supporting low cost webcams.

Just a simple and intuitive On/Off pair like the Fan buttons in the General section should be easy to implement.

4 Likes

I was thinking it would be nice to have a "Stop Web Streaming" and a "Start MJPG Streamer" in the System Menu. Is that doable @foosel? Or is that something that has to be set up in OctoPi jointly?

More info can be found here on the Webcam setup.

2 Likes

OctoPrint doesn't control the webcam. People might be using an external IP camera, or some other webcam server or whatnot. So adding that stock OctoPrint wouldn't make sense. Shipping a custom config with OctoPi that includes that however would be possible.

I understand that. Shutting down the MJPG Streamer is certainly not as severe as rebooting the whole RasPi. The Script could certainly check to see if others are logged in and using the webcam and give an appropriate warning.

I agree that this could/should be a custom config with OctoPi.
Does OctoPrint installed on a Mac or Windows machine have the "Reboot System" or "Shut Down" menu items or is that specific to the RasPi?

Is this something that could be done thru the "System Command Editor". That plug-in doesn't work on a Mac for some reason. I tried 3 different browsers.

The reboot/shutdown menu items are available (on macOS at least), they're just not preconfigured like on OctoPi. You can set the shell commands for these options manually in the OctoPrint settings under the 'Server' heading.

System Command Editor works for me, Safari 11.1 on 10.12.6 Sierra, albeit with the double scroll bar rendering glitch. Are you using any content blockers or similar?

1 Like

Like @lbell mentions, if you use system command editor you can set the commands to

sudo service webcamd stop for stopping the webcam service

and

sudo service webcamd start for starting the service.

Of course webcamd in the commands above have to match the name of the service you add. That name is specific to OctoPi.

3 Likes

Hi, It worked for me adding in the system command editor:

turn on: sudo /etc/init.d/webcamd start
turn off: sudo /etc/init.d/webcamd stop

Keep in mind that activating the webcam takes about 30 or 40 seconds to activate the service

4 Likes

Nube here. I get am error when executing these command after I entered them, because sudo is requesting the root password.

And would this be on an OctoPi-imaged OctoPrint on a Raspberry Pi? If so, then Guy would have taken care of all this since his image rocks.

See lines 134-136 for what he did to allow pi to quietly do things like shutdown, for example.

I started over, re-imaged, updated, and now the control commands are working. Very nice. Thank you!.

Is there any way to trigger system commands on events, like the GCODE Scripts section does? I'd like to make the camera automatically turn on when a print is queued and turn off when it's done.

1 Like
  1. Take the scripts which jneilliii has provided above
  2. Turn them into Gcode System Commands as, say, 900 and 901
  3. Add the OCTO900 and OCTO901 as appropriate into your OctoPrint Gcode scripts as if they were GCODE
2 Likes

Is it possible to connect xioami Dafang wiwfiweb camera to raspberry pi with octoprint

I realize this is rather old, but anyways I am using the actual Octopi image 1.5.2.
There is no webcamd script in that installation and it seems octopi is doing the webcam stuff by itself.
How would I shutdown the wbcam there and possibly restart it?
Wouldn't it be much better, if Octopy would handle that by itself? Maybe just starting the webcam if someone connects to the webinterface?
What am I missing?
Cheers

I think you might be confused between what OctoPi is and what OctoPrint is - your post contradicts itself.

You can control webcamd using sudo service webcamd {start|stop|restart}. Starting the camera when someone connects could be done with a plugin that ran this command for you, but it is not built in because webcam streaming is not provided by OctoPrint, it is only getting an MJPG stream from the URL and so cannot control it.

Thanks Charlie,

I realize the difference between Pi and Print. Nevertheless atleast the Octoprint settings menue has options to controll some things about the webcam. I know it's basically what to do with the stream but what would be the harm in setting those start and stop service commands in that section and running them when necessary?

Anyways thanks to you help, I used the system command plugin to make the corresponding system menue entries and it works - not automatically. At least I now have control over the webcam using Octoprint's system menue.

Thanks again for you help
Cheers

try this:

turn on: sudo service webcamd start
turn off: sudo service webcamd stop

2 Likes

I did this by using GCODE System Commands plugin with two command definitions:

OCTO910 sudo service webcamd start
OCTO911 sudo service webcamd stop

Then inserted these codes to GCODE Scripts:

"After connection to printer is established"
OCTO910

and

"Before connection to printer is closed"
OCTO911

Now the camera goes on when printer powers on and connection to Octoprint is established.
When printer power is lost and Octoprint connection is cut the camera goes off.
I'm using Tasmota plugin to control the printer power but Octopi is always powered on.

5 Likes

I am just starting in 3D printing and have probably spent more money than I needed to for how often I will use it :slight_smile:
Anyway, I found this looking for the ability to turn webcam off on Octoprint and wanted to say thank you for all the information. It only takes a few seconds for the service to stop / start now rather than 30 seconds plus, but apart from that all information is still relevant now.
Now to work out how to turn the printer power off at the end of a print :slight_smile:

1 Like


hyptechdev2015

jlester42

Jan '21

essaye ça:

activer : sudo service webcamd start
désactiver : sudo service webcamd stop

Bonjour,
je suis intéressé par la commande on/off
mais ou doit on écrire cela dans Putty, comment accéder à l'éditeur de commande, je ne voudrais pas mettre le bazar dans mon Raspi, je sais ouvrir et rentrer ID et MP mais qu'écrire pour arriver dans éditeur de commande
si quelqu'un ou quelqu'une peut m'aider, d'avance merci