OctoPi/OctoPrint 3D Printer Server


OctoPrint is a great tool for monitoring and controlling your 3D printer.

Add the OctoLapse plugin and you can make really amazing time lapses.

But it is a little tweaky, and the recommended installation on a RaspberryPi (OctoPi) makes some assumptions that may not work for you.

It’s not the clearest to figure out what to change.

OctoPi Installation Notes

  • follow the good documentation at Octoprint’s download page
  • create SD card using etcher
  • on windows, you will see some errors, and possibly “unformated disk” errors/warnings- ignore them!
    • image has two partitions; a boot which can be seen from Windows/non Linux, and a main Linux partition
  • can edit some setup config files that are in the boot partition- eg WiFi settings. Follow the good documentation’s advice and use a Linux friendly text editor!
  • assumes you are using WiFi over DHCP. Can configure WiFi, but not easy to set a static IP address (for either WiFi or wired). Ok for a quick start, but problematic if you want to have several setup
  • sets up bonjour and UPNP, but especially on windows this “friendliness” leads to issues, especially with the live webcam feed (more below)
  • once installed, go through the web interface and set up a user
  • then go to settings -> updates and update
  • then login to a shell and sudo aptitude. Update the system, and also search for uvcdynctrl and install it too. Reboot.

Default OctoPi System Overview

HAProxy is used to make everything accessible on ports 80 & 443 (standard web ports) of the RaspberryPi.

Note, that on Linux, only root privileged applications can open ports below 1024. And an app with root privileges has access to everything.

So it makes good sense to have all the OctoPrint pieces behind HAProxy:

  • HAProxy does a bunch of things to try and be secure
  • OctoPrint is a set of Python scripts. It’s not security audited. It runs on a user port >> 1024
  • mjpeg_streamer may not be securely written either. It usually uses port 8080.
  • OctoPrints web interface doesn’t serve the video preview; instead it embeds the mjpeg_streamer video stream. Octoprint has to give the users web browser a URL that it can reach. So it’s a lot easier to use a relative URL (“go get the video stream from the same server ip address and port that you loaded me from”)

You get much easier initial configuration, security, and flexibility. For example HAProxy can be configured to serve multiple instances of OctoPrint, so one machine can host and control several printers.

BUT for some people HAProxy seems to add a random 1-30 sec delay in the video stream in the control tab!

Important Note- this delay only affects the control tab preview. For timelapse snapshots, with default settings, OctoPrint (and OctoLapse) go directly to mjpeg_streamer.

Tweaked OctoPi Config to Minimize Preview Video Lag

To do this, you must know the IP address of the OctoPi. Best if this is static.

Just go to settings-> webcam & timelapse, and change the stream URL to be something like http://<ip address>:8080/?action=stream and test it.

Notice that the snapshot URL is something like - which is a special IP address that means “this computer”- ie avoiding HAProxy!

This should eliminate the preview lag.

Fixing WebCam Issues

Resolution, Framerate, and Compression

Webcams are annoying. They often have odd requirements for how they have to be configured to get what you want.

Typically we want a compressed video stream from the camera to not overload the data capacity of the USB bus. The compression is usually MJPG- motion JPEG, which is one JPEG image sent one after the other. Newer cameras may have MP4.

A lot of USB cameras support (to some extent) the USB Video standard: UVC. That driver, plus some others, feed into the Video4Linux2 API (V4L2).

V4L2 devices usually appear as a special videoXX files in /dev- eg /dev/video0.

There are commands that will list and control a webcams features that use the V4L API, and some that use the UVC API.

Most of the following is from: https://superuser.com/questions/639738/how-can-i-list-the-available-video-modes-for-a-usb-webcam-in-linux

To list camera modes:

v4l2-ctl --list-formats

uvcdynctrl -f

You are looking for modes that have a MJPG (or MP4?) picture format. This will be a combination of both resolution and framerate.

Once you have a candidate, you need to restart mjpg_streamer and test it. In my case I think 1920x1080 at 10 fps is a MJPG configuration to try. Low framerate but high res- should be ok for monitoring, and the maximum res the camera can do for taking the timelapse frames.

Unfortunately for testing, OctoPi will detect if mjpg_streamer crashes and restart it.

So we have to kill mjpg and restart it before OctoPi notices.

Using ssh or a keyboard and monitor, log into OctoPi.

Then cd mjpg-streamer

First, find the Process ID (PID) of the running mjpg_streamer:

ps aux | grep mjpg

The PID will be a number.

And then:

kill <PID> && ./mjpg_streamer -o "output_http.so -w ./www-octopi -n" -i "input_uvc.so -r <resolution> -f <frame rate> -d /dev/video0"

In the output, you should see:

Format.......: JPEG

If you don’t see this, the camera is not sending compressed frames. You will have more CPU and USB load, and probably problems. Check your resolution (eg 1920x1080) and framerate, and possibly select another candidate.

Now check it’s looking ok in the OctoPrint web interface.

if everything looks good, hit ctrl-c in your terminal.

Now edit /boot/octopi.txt and update the webcam commands.

Restart OctoPi via the OctoPrint web interface, or with the reboot command.

Double check everything by both looking at the web interface and logging in and looking at the end of /var/log/webcamd.log.

Focus, Brightness, Exposure

In short, you can create a configuration file that specifies the camera settings to use.

You can see a list of the current options via:

uvcdynctrl --clist.

To get the current value of a setting:

uvcdynctrl -g "White Balance Temperature, Auto"

YES- you must enter the complete name of the parameter!

To set it: uvcdynctrl -s "Brightness" 50.

Watch the live stream in the web interface and tweak till things look good.

Then follow the instructions in this post: https://discourse.octoprint.org/t/changed-the-video-feed-brightness-contrast-and-settings-for-my-logitech-usb-video/1103/8

Yes, start at the last (at time of writing) post by “airscapes”, which has corrections for some of the earlier steps.


Printing Configuration

Octolapse works by looking at the G-Code as it’s being read by Octoprint before it’s sent to the printer. (So it won’t work on GCode files stored on the printers SD card!)

It detects different features (layer changes, exterrior shells, infill, bridging, etc) by looking for different feed rates.


For it to work well, make a copy of your current Simplify3D/Cura/etc profile and go through and adjust every feedrate so that it’s slightly different.

Then create a matching set of values in Octolapse.

Camera Configuration

Octolapse communicates directly with mjpg_streamer. It should be able to set brightness, exposure, etc itself.

Right now, I have it call the uvcdynctrl config script created above, when a print starts- I want the control/monitoring stream to be a preview of the timelapse

But there are a lot of options in the camera profile settings.