Need to be able to create octopi.txt - trying to get camera working with Octoprint

Raspberry Pi 3B+ running Raspbian (lite). Camera is working perfectly - if I run the script for MJPG streamer I can access the image just fine from the :8080 html address.

I cannot get Octoprint to recognize a URL, and I have no idea how to configure the FFMPEG server. Most importantly, all sources online reference an "octopi.txt" file that I do not have on my pi.

Camera model Raspberry Pi camera

What is the problem? Don't have octopi.txt as I installed octoprint manually

What did you already try to solve it? Spent hours reading and searching - constructed a simple octopi.txt file, but pi won't allow me to copy it into the boot folder

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support)

Additional information about your setup (OctoPrint version, OctoPi version, ...) Latest Octoprint version...

Hello @vicenzajay,
you'll find this at octopi github

I wasn't clear then. I have already constructed the file - but the PI is telling me that I can't write to the boot directory.

Since I installed octoprint manually, how do I get it to enable/create an octopi.txt in the boot directory?

To be clear, Octoprint is working fine (controlling printing), and the camera is working fine (I can use script to take pictures, stream, etc.). I just need to get Octoprint and the camera working together - and by all accounts, this requires that file.

That's the beauty of flashing octopi on the sd card, all those little tricks have been put in place for you. Then again, building it all on your own is a great learning opportunity.
That github link leads to all the details but I guess you know that already.

You need to be root to write to /boot
alternative is to take the sd card out, to another computer, and mount it there as an external volume. If that computers OS doesnt care about linux file permissions you can circumvent them.

1 Like

I'll try that after this print finishes.

Yeah - I like doing things manually...I learn more that way...

What about the URL and FFMPEG entries for Octoprint. Are those taken care of automatically with a good octopi.txt? This is very vague in what I've read thus far.

octopi.txt is simply the config file for webcamd

That github repo lays open all the secrets of octopi.

So the link to the "remove mjpg streamer" executable has no download options. How do I get the actual executable to "execute it" through ssh? I suppose I can copy the raw script into notepad++ and save it as - move it to the pi and run it?

Github is great for creating but awful as a repository of knowledge for, as you say, opening secrets. It just doesn't do that very well or at all intuitively.

I get that octopi.txt is the config file. I've created one. I'm entirely unclear about how and where this should go onto the pi at this point (given the remove mjpg script linked here).

You don't need an octopi.txt file at all - if you have the stream working under port 8080 then you have already gone beyond needing it.

Assuming you are following the guide Setting up OctoPrint on a Raspberry Pi running Raspbian or Raspberry Pi OS and have all the scripts there setup, then it also tells you what stream URL to use.

Open OctoPrint's settings dialog and under Webcam & Timelapse configured the following:

  • Stream URL: /webcam/?action=stream
  • Snapshot URL:
  • Path to FFMPEG: /usr/bin/ffmpeg

How far along the guide have you got? Is there a bit you have skipped? A particular part that didn't work? All should be explained, so follow along in that guide and you will hopefully find the answers to your questions.

You can also (if you didn't setup Haproxy) access the webcam stream under http://<pi's IP>:8080/?action=stream, but note that you have to have an absolute URL for this to add the port number.

1 Like

So I am using that page. And I did install haproxy. I'm not sure how to "enable" it all, however. There's some confusion as to how to get things into an autostart condition (i.e. to start haproxy at pi startup, etc.)

On that page, I am at the paragraph below his haproxy config example. None of the commands that he shows below that work on my system. I have done everything prior to that paragraph on that page exactly as is shown...

With 'none of the commands work', please be more specific - when you run the sudo service haproxy start command, what actually happens? Copy and paste every error you find here so we are not stabbing in the dark.

In theory, nothing should happen on the console but instead of accessing OctoPrint from :5000, it now just needs the IP/hostname, no port required.

Good - so when I run that command in a terminal, the pi pauses and then returns the prompt (no errors). I'm assuming that means the haproxy service has started. My haproxy config was a copy-paste from the text offered.

When I enter any of the scripts to enter into Octoprint's settings tab for the Webcam - they each return "invalid" errors (as in the page specified doesn't exist). Note - the FFMPEG path returns a "valid" result - so it is an exception.

Give me a few hours as a print is finishing on this printer. After it completes that job, I'll be more free to do restarts, etc.

Oh, another note - when I installed mjpg streamer, I did it from Liam's github page. As a result, it is installed under the /projects/ folder on the pi. I'm wondering whether there's a way to completely wipe that installation and redo it using the scripts on the bottom of the page we are discussing here.

Also - appreciate the willingness to help...thank you very much.

1 Like

What happens when you open the URLs in your browser? They will (likely) only work once mjpg-streamer is fully running. Reading the guide now, it is a bit strange how it is asking you to enter the webcam URLs before installing the actual streaming software... If you can access the stream in your browser then it should all be accessible from the OctoPrint UI as well.

If I understand the mjpg streamer install, it is just built into a binary inside it's project folder. So just removing the mjpg-streamer-experimental folder should be enough to delete it. I think.

So I thought I was making progress, but then not so much.

So I uninstalled the folder from /projects/ and ran the scripts to re-install the streaming software. That worked.

I then entered the command in terminal to start streaming (raspicam version) and then I was able, with no problem to access the stream in the browser window.

So far, so good - then I tried entering:

Open OctoPrint's settings dialog and under Webcam & Timelapse configured the following:

  • Stream URL: /webcam/?action=stream
  • Snapshot URL:
  • Path to FFMPEG: /usr/bin/ffmpeg

in Octoprint - no joy. It says "if you can see the stream below, then it's working" - no stream was present

There seems to be something missing with 'auto-starting' the stream when the pi boots up. If the absolute URL is accessible once the command in terminal is executed, then in theory, this absolute URL should be easily accessible by Octoprint. The only thing I can think is that there is some script missing here to ensure that the PI, on bootup, loads all the drivers/scripts and actually starts the streaming service. I don't know how to do that from scratch.

Confirmed. If I manually start the service/streaming in the "experimental" folder, I can then map to the streaming and snapshot url's in Octoprint no problem.

I think we're really close here - I just need a script or "how to" to ensure that the service starts along with the PI booting.

Oh - I don't believe haproxy is playing any role in the way I'm doing this right now.

We are really close here. I have been able to create the octopi.txt by using sudo nano /boot/octopi.txt at this point (not sure why it wasn't working last night). I then manually entered the lines necessary as well as enabled the webroot lines. Camera is showing up in Octoprint Control Tab and timelapse and snapshot are configured.


The sticky wicket is getting the streaming service to start on PI startup with the correct parameters. What I need to have happen is these two lines execute automatically:

cd mjpg-streamer/mjpg-streamer-experimental
./mjpg_streamer -i "./ -x 1280 -y 720 -fps 15 -br 100" -o "./"

That's it. I think that would sort the issue completely.

Man, I am trying every which way from Sunday to convert this to a script and then a service to run automatically. I'm failing badly...

It's a little hidden, but try this part:

If you want autostart of the webcam you need to add the following line to /etc/rc.local (Just make sure to put it above the line that reads exit 0).

  /home/pi/scripts/webcam start
1 Like