Skip to main content Link Menu Expand (external link) Document Search Copy Copied


How to setup multiple Webcams with MainsailOS.

Thank you to Charlie_Powell for letting us adapt his guide for MainsailOS!
The original guide can be found here.


For multicam to work, you will need:

  • MainsailOS v0.5.0 or higher
  • SSH access
  • Two or more cameras

If you are working with an existing installation, make a backup!

Creating the configuration files

MainsailOS supports an infinite number of webcam*.txt style configuration files. They should be placed in /home/pi/klipper_config.

In Mainsail’s user interface, go to ‘Settings > Interface’ and click on (1) and save as webcam2.txt.


You should now have two identical files with different names:

  1. /home/pi/klipper_config/webcam.txt
  2. /home/pi/klipper_config/webcam2.txt

Edit the original configuration file for a specific camera

Find the path to the camera by its ID. This makes it easier to stop dev/video0 and /dev/video1 from being switched in the future.

In a terminal, run the command ls /dev/v4l/by-id, copy your camera id and paste it into the editor in Mainsail. For example:

$ ls  /dev/v4l/by-id/


usb-046d_0825_88C56B60-video-index0  usb-046d_0825_88C56B60-video-index1

This example will use the first one: usb-046d_0825_88C56B60-video-index0

Not sure which device is which? You can run lsusb to match a camera name to an ID.

Edit /home/pi/klipper_config/webcam.txt by clicking on it in Mainsail.

Insert two lines at the beginning of webcam.txt:

camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"

The device long id should match the camera name from running lsusb.

If you are using a Raspberry Pi branded camera, set camera="raspi" at the top of the file and you do not have to reference the cameras by device ID.{: .info}

3. Editing the second configuration file

When using a second camera, you must add the port mjpg_streamer runs under and the device.

If you are using one Raspberry Pi branded camera and a different USB camera you don’t need to reference them by ID, as camera="raspi" and camera="usb" is enough.

Similar to finding the first camera, run ls and copy the ID of the second camera:

ls  /dev/v4l/by-id/

Edit /home/pi/klipper_config/webcam2.txt as described above and add: camera="usb" and set camera_usb_options but this time using the ID for the second camera:

camera_usb_options="-r 640x480 -f 10 -d /dev/v4l/by-id/<device long id>"

Adjust the port by editing camera_http_options:

camera_http_options="-n -p 8081"

The port should reflect the number in webcam*.txt:

webcam.txt => -p 8080
webcam1.txt => -p 8081
webcam2.txt => -p 8082
webcam3.txt => -p 8083

MainsailOS comes setup with four NGINX reverse proxies for port 8080 through 8083, so you can configure 4 webcams with this guide. For more webcams you will need to edit the NGINX configuration, which is not recommended. It can be easy to make a mistake when editing NGINX, which will also cause Mainsail to stop working.
If you need more than four webcams, visit us on Discord and we will help you.

4. Test that it works

Restart webcamd by clicking the power button icon in the upper right corner of Mainsail and click Webcamd to restart it. Find your second camera under http://<your-ip>/webcam2/. If it doesn’t work, check in the webcam log in the file manager log section for details.

If it works, you can use the URLs in Mainsail:

Stream: http://<your-ip>/webcam2/

Congratulations, you set up multi webcam with Mainsail!
If you want to add more, follow the guide again and increment the webcam*.txt number, i.e. webcam**3**.txt and so on.
The webcams are accessible through your http://<your-ip>/webcam, http://<your-ip>/webcam2, etc.