Skip to content

V0.4 Enabling Camera Controls

FormerLurker edited this page May 25, 2020 · 17 revisions

OctoPi uses mjpg-streamer to create a camera stream, which allows you to monitor your printer via OctoPrint. Mjpg-streamer has the ability to change some camera settings via control.htm. Additionally, mjpg-streamer can create a description of your camera's controls and capabilities, accessible via a file called input.json. Since mjpg-streamer has no authentication or authorization capability, it was decided to disable all access to these page within OctoPi by default.

If you have not used port-forwarding or some other insecure methods to view your OctoPi instance through the internet, these pages are generally safe to use. If these pages are available, Octolapse can take advantage and use them create a screen that allows you to control your camera's settings.

Prerequisites

  • Mjpg-streamer must be installed.
  • Some plugins that create their own camera stream must be disabled. Currently this includes OctoPrint Anywhere and The Spaghetti Detective. These are both great plugins, but they are incompatible with custom camera controls.

Notes for Raspberry Pi Camera Users

If you are using a Raspberry Pi Camera, the steps are a bit different. See this comprehensive guide for using a Raspberry Pi Camera.

Step 1 - Connecting to Your Raspberry Pi

If you don't know how to connect to your Raspberry Pi, see this guide. When you are connected, continue on to step 2 below.

Step 2 - Edit your octopi.txt file

Open your octopi.txt file with the nano editor by entering the following command followed by the Enter key:

sudo nano /boot/octopi.txt

Open octopi.txt in nano

You may be prompted to enter your password. After the command completes, you will see the nano text editor. Use the arrow keys and edit this section (it may look slightly different than what is pictured here, but it should be close):

Next, using the arrow keys move down to the bottom of the octopi.txt file and find the following section:

Octopi.txt without access to control.htm

change the following text

#camera_http_webroot="./www-octopi"
#camera_http_options="-n"

to this:

camera_http_webroot="./www"
camera_http_options=""

Be careful to remove any # characters at the beginning of the lines! It should look like this when you are finished:

octopi.txt with control.htm access enabled

While you're here, you might want to adjust your camera's resolution and framerate. Find the camera_usb_options section and edit those now. For example, if you want a 1080P image at 30 frames per second, you would use the following:

camera_usb_options="-r 1920x1080 -f 30"

Be sure to refer to your camera's documentation when choosing a resolution and framerate. Not all resolutions/framerates are available for all cameras.

Make sure to remove any # characters from the beginning of the line!

and the end result will look something like this:

1080P at 30 FPS

**Note: The higher the resolution and framerate, the more bandwidth and CPU power will be used. Higher frame rates will reduce the image acquisition time (possibly improving quality, especially when using a smart trigger with snap-to-print enabled). Also, some versions of firefox will have trouble showing a high framerate mjpegstream, but chrome seems to do just fine. Your mileage may vary, but if you have problems, try lowering your framerate from 30 frames per second to 10 frames per second.

Now we want to save the file and exit nano. Hold down the ctrl key and press the letter O (so ctrl+O) to save the file. Press enter to confirm. Then press ctrl+Z to exit.

Clone this wiki locally