OctoPrint in Docker, snapshot works, stream doesn't

Camera model: Logitech c920

What is the problem?: I'm running OctoPrint in docker (works great) on my Raspberry Pi (that is running Raspbian and serves DHCP through pinhole, also works great).

I've plugged my Logitech c920 into the Pi, and the system recognizes it. I can even preview a snapshot in OctoPrint. However, I cannot get the stream to work.

What did you already try to solve it? Read every forum post and solution this side of the internet to see if I could figure out what's wrong. Tried changing ports and address listed in the stream settings in OctoPrint to the IP my Pi is sitting on (local_ip:5000), and a bunch of other little things like that, but have reverted back to the stock settings.

This the docker-compose.yml file I'm using; I believe I've enabled all the suggested settings for the webcam to work:

version: '2.4'

services:
  octoprint:
    image: octoprint/octoprint
    restart: unless-stopped
    ports:
      - 5000:5000
    devices:
    # use `python -m serial.tools.miniterm` to see what the name is of the printer
     - /dev/ttyUSB0:/dev/ttyUSB0
     - /dev/video0:/dev/video0
    volumes:
     - octoprint:/octoprint
    # uncomment the lines below to ensure camera streaming is enabled when
    # you add a video device
    environment:
     - ENABLE_MJPG_STREAMER=true

  ####
  # uncomment if you wish to edit the configuration files of octoprint
  # refer to docs on configuration editing for more information
  ####

  #config-editor:
  #  image: linuxserver/code-server
  #  ports:
  #    - 8443:8443
  #  depends_on:
  #    - octoprint
  #  restart: unless-stopped
  #  environment:
  #    - PUID=0
  #    - GUID=0
  #    - TZ=America/Chicago
  #  volumes:
  #    - octoprint:/octoprint

volumes:
  octoprint:

Logs (/var/log/webcamd.log, syslog, dmesg, ... no logs, no support): Tried to find webcamd.log, but I don't see it where it's supposed to be.

Tried to use SCP to save syslog to my local machine (accessing everything on the Pi headless using ssh/zsh on my Mac), but the file came over blank. Couldn't select-all and copy from Terminal, so not sure how to get that to everyone.

Additional information about your setup (OctoPrint version, OctoPi version, ...): OctoPrint v. 1.73 running in Docker; everything on the system is updated as of this morning.

What's configured as the stream URL?

In the background of the screenshot it looks like it is webcam/?action=stream. This needs a leading slash - /webcam/action=stream or the browser will not know what to do with it.

Thanks! It did not have a /, so thanks for that catch. Sadly, I've added it but there seems to be no change. These are the settings now. (I've saved and tried to preview again to no avail.)

Ok, I spotted another thing, in the docker-compose.yml file you have posted you are mapping 5000:5000. The webcam server is running on port 8080 inside the container, but there is also haproxy running on port 80 that's needed to use OctoPrint & the webcam on the same port. So if you want it to be accessible on port 5000 outside the container, then you must map port 80 internal to 5000 external. If I remember docker right that's 5000:80? If not it is the other way around.

1 Like

That was it! What a mensch; thank you for swooping in and saving the day, you are a true hero.

1 Like

Dang man, I've been googling like mad trying to solve this for a week now!! Thanks so much for posting this. Holy cow.

What I ended up doing, running Octoprint in docker on a lenovo tiny, was using the following:
ports:
- 80:8080
- 5000:5000

That got webcame working on http://localhost/?action=stream like Octoprint seems to want. I tried changing the port up, but it seems to only work on 80. Not sure if thats a me thing. Login on 50000 works fine.

I'm okay with it on 80 and am just stoked to finally have this setup completely working.

Thanks again!

@GalacticBossanova

I have an identical camera as yourself and exactly the same problem as you. I have the timelapse working, I even have the video stream working from my browser, but can't get the videostream working in octoprint.

Would you mind posting your yaml file so I can see exactly what you did and changed please?

Thanks

Rob

@rwillett Use the original yaml but update the "ports" section to:

    ports:
      - 5000:5000
      - 5001:8080

Then go to OctoPrint Settings > Webcam & Timelapse and for the "Stream URL" use the IP address of the server with port number without the /webcam/ part. For example mine looks like:

http://192.168.0.51:5001/?action=stream

FYI @douglas_d_rain regarding mapping a different port than 80

Hope this works for you.

Hopping onto this thread just to say that this lead the way to be able to get my webcam connecting to the printer's docker instance.

here's a copy of the working docker-compose yaml i used for others who might have similar struggles:

version: '2.2'

services:
  octoprint_ender3:
    restart: unless-stopped
    image: octoprint/octoprint
    ports:
      - 4081:8080
      - 4001:5000
    devices:
      - /dev/ttyUSB0:/dev/ttyACM0
      - /dev/video1:/dev/video0
    volumes:
     - /root/octoprint/ender3:/home/octoprint
    # uncomment the lines below to ensure camera streaming is enabled when
    # you add a video device
    environment:
     - ENABLE_MJPG_STREAMER=true

then in the ui i set the stream url to be:

http://192.168.1.105:4081/?action=stream

which led to a working stream test.

How did you verify that /dev/video1 is the correct device. I can't get it running with /dev/video0 nor /dev/video1