OctoPi and WebCam handling

What is the problem?

Hi,
I have some problems with my webcam configuration.
This is what I want:

  • webcam off by default
  • two entries in the system menu (webcam on/off)
  • automatically start/stop webcam via eventhook when PrintStarted/PrintDone

What did you already try to solve it?

  • I set the correct parameters in the /boot/octoprint.txt for the Logitech C270
    ** camera_usb_options="-r 1280x720 -f 30"
  • I set up the two action commands from the Cookbook: System-Commands
    ** But there is a note: "...may not work correctly with OctoPi..."
    ** Confirmed! This does not work
  • Same for the eventhook - not tried yet, but same note!

So what can I do to get these system actions and events working on OctoPi?

Kind regards,
Sternmiere

Additional information about your setup

OctoPi 0.15.1
OctoPrint 1.3.9
Logitech C270

Hi!
Actually the webcam is managed by FFMPEG that delivers the stream or snapshots to the Pi's IP. The Timelap plugins of OctoPrint tell FFMPEG to get images to create the video sequence.
AFAIK there is no option within FFMPEG to mute the camera, so it stays on as long it's plugged in. FFMPEG documentation

There's some way to toggle it ON/OFF because Robo has that in their fork.

I think, I found a solution:

sudo service webcamd {start|stop|restart}

I have added these two actions to the config and they work:

  - action: streamoff
    command: sudo service webcamd stop
    confirm: false
    name: Webcam aus
  - action: streamon
    command: sudo service webcamd start
    confirm: false
    name: Webcam an

And I added this to the event-section on PrintDone and PrintStarted event.

Now I just need to disable the webcamd by default.

2 Likes

Looks like Guy is doing it here in /etc/init.d/webcamd: webcamd

Docs for init.d-related files

This would be the command that you'd run in Ubuntu to disable autostart but to leave the entry in place for later controlling it: sudo update-rc.d webcamd disable. Researching a little more, I'm pretty sure that Raspbian uses this mechanism, too. In theory, it would update those lines at the top in the ### BEGIN INIT INFO section.

1 Like

My new actions/events in addition with sudo update-rc.d webcamd disable worked!

Thanks!

3 Likes

Just a note for everyone else: if you like the idea of programmatically toggling the webcam on/off as needed (with the option of being off on startup), this is a useful thread.

1 Like