Get a Go2RTC/reStreamer HLS-Stream to work with MultiCam

Camera model

Tapo C111

What is the problem?

Can't get the cameras-stream to show up in the Webinterface


Interestingly enough Restreamer recognizes Octoprint as 2 Viewers are shown...

Bildschirmfoto 2024-12-12 um 3.52.20 AM
Bildschirmfoto 2024-12-12 um 3.52.34 AM
But sadly the Tab doesn't show the Stream...

What did you already try to solve it?

I've setup restreamer in a docker-compose next to octoprint. Those are my config's:

Restreamer Compose:

---
services:
    restreamer:
        container_name: restreamer
        image: 'datarhei/restreamer:latest'
        volumes:
            - '/srv/docker/restreamer/config:/core/config'
            - '/srv/docker/restreamer/data:/core/data'
        ports:
            - '8082:8080'
            - '8181:8181'
            - '1935:1935'
            - '1936:1936'
            - '6000:6000/udp'
        restart: unless-stopped

Octoprint Compose:

---
services:
  octoprint:
    image: octoprint/octoprint
    restart: unless-stopped
    ports:
      - 8081:80
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0
    volumes:
      - /srv/docker/octoprint/config:/octoprint

Octoprint config:

api:
  key: FOO
plugins:
  announcements:
    _config_version: 1
    channels:
      _blog:
        read_until: 1732087800
      _important:
        read_until: 1698310200
      _octopi:
        read_until: 1684929600
      _plugins:
        read_until: 1732406400
      _releases:
        read_until: 1730798460
  classicwebcam:
    _config_version: 1
  discovery:
    upnpUuid: BAR
  errortracking:
    unique_id: BAR
  gcodeviewer:
    _config_version: 1
  octopod:
    _config_version: 14
    tokens:
    - apnsToken: BAR
      date: 12/12/24 02:06:48
      deviceName: iPhone
      languageCode: de
      printerID: x-coredata://BAR/Printer/p2
      printerName: Kobra2Neo
    webcam_flipH: null
    webcam_flipV: null
    webcam_rotate90: null
  softwareupdate:
    _config_version: 9
  tracking:
    enabled: true
    unique_id: BAR
  virtual_printer:
    _config_version: 1
printerProfiles:
  default: kobra2neo
serial:
  autoconnect: true
  baudrate: 115200
  port: /dev/ttyUSB0
server:
  firstRun: false
  onlineCheck:
    enabled: true
  pluginBlacklist:
    enabled: true
  secretKey: FOO
  seenWizards:
    backup: null
    classicwebcam: 1
    corewizard: 4
    tracking: null
temperature:
  profiles:
  - bed: 100
    chamber: null
    extruder: 210
    name: ABS
  - bed: 60
    chamber: null
    extruder: 190
    name: PLA
webcam:
  cleanTmpAfterDays: 7
  ffmpeg: /usr/bin/ffmpeg
  snapshot: http://10.10.XX.20:8082/memfs/64b36d63-40fe-4dbe-8385-6a8406b3ad24.jpg
  stream: http://10.10.XX.20:8082/memfs/64b36d63-40fe-4dbe-8385-6a8406b3ad24.m3u8
  timelapseEnabled: false

Have you tried running in safe mode?

No

Systeminfo Bundle

octoprint-systeminfo-20241212024139.zip (83.1 KB)

Additional information about your setup

Running on Pi5 (8GB) using Docker compose

I've had this working at one point, but it's been a while since I've tested.

What I find odd is that your config for OctoPrint has the settings still in the webcam section and not in the classicwebcam plugin settings where it should be.

One thought is possibly a browser security issue. An embedded video might not load if it's not on the same port when accessing OctoPrint via https. So if you are accessing OctoPrint using https://octopi.local/ or https://ip/ then there's a good chance the browser is blocking the load of the other because it's not using https as well. Open your browser's developer tools and check the console tab in there to see if you are getting errors when switching to the control tab of OctoPrint.

One way to get around the browser security issue is to reconfigure haproxy to redirect to that port 8082 you are using, and then use a relative path the way the default OctoPi image works with port 8080.

Thanks for your reply, I get the concept but can you be a bit more specific?

I'm thinking about setting up a reverse proxy for all the services I've dockerized on the host, but am not yet sure how to realize this... Have been using nginx in the past but would like to try Caddy this time!

Yes, I've setup my docker sth like that...

But I only access my OctoPrint like this: http://10.10.XX.20:8081 so there's no SSL/TLS in the chain yet...

I'll do so later down the road once I've setup a reverseproxy and access it via cloudflared :wink:

I'm not really familiar with caddy, but in haproxy on an OctoPi image the configuration redirects the path /webcam/ to port 8080 on the same device. That can be configured to redirect to another IP address, etc. and then you would set your stream url to /webcam/memfs/64b36d63-40fe-4dbe-8385-6a8406b3ad24.m3u8.

There are some proxy examples in this thread: https://community.octoprint.org/t/reverse-proxy-configuration/1107?u=jneilliii

My Caddyfile looks exactly as suggested by @foosel on her proxy example.

But I'm not so sure, as this doesn't fully work as I would expect it:

I've already taken a look into auth. and octoprint.log inside the container, but both won't recognise my attempt to login through the proxied login dialog! :frowning:

The exact same credentials work like a charm if I open the Webinterface via the IP-address... So I'm kinda lost here :sob:

P.S.: I've so far also tested go2rtc and while I can see the stream in both webinterfaces I can't get it to showup inside Octoprint:

Camera Streamer Control plugin is not designed to work with go2rtc. I suggest you use classic webcam plugin and the HLS link provided from go2rtc's settings interface. It will be something like this...

http://<ip>:1984/api/stream.m3u8?src=<stream_identifier>&mp4=flac

Thanks @jneilliii

I just started a 6h printjob and will give feedback directly afterwards...

EDIT: Regarding me being unable to login from the proxied site (outside my LAN via Cloudflare) I just fixed that by turning off cloudflare's HTTPS and letting Caddy get a Let'sEncrypt Cert!

Arggghhh, just barely finished typing the whole response... And then it was gone!

For the next men/women facing a similar issue:

I fixed it with Go2RTC and following this YouTube Video

My Go2RTC sits in a compose next to Octoprint:

---
services:
  go2rtc:
    container_name: go2rtc
    image: 'alexxit/go2rtc:latest'
    # network_mode: host
    # privileged: true
    ports:
      - 8080:1984
    restart: unless-stopped
    environment:
      - TZ=America/Cancun
    volumes:
      - '/srv/docker/go2rtc/config:/config'

The URLs I entered in the MultiCam Settings Dialog are as follows:
Stream: https://subdom.mydom.net/go2rtc/api/stream.m3u8?src=kobra2neo-rtsp1&mp4=flac
Snapshot: https://subdom.mydom.net/go2rtc/api/frame.jpeg?src=kobra2neo-rtsp1

Those are already proxied through Caddy and only available within LAN/VPN whereas the other services are public:

(private-only) {
        @private not client_ip 172.xx.0.0/24 10.10.xx0.0/24 10.10.yy1.0/24 10.10.zz2.0/24
        respond @private "Not from within so: Access Denied"
        }

subdom.mydom..net {
        basic_auth {
               # docker exec -it CID sh; caddy hash-password
               admin mypasswdhash
        }
        respond "Welcome, {http.auth.user.id}" 200
        redir /octoprint /octoprint/
        handle_path /octoprint/* {
                handle_path /webcam/* {
                        import private-only
                        reverse_proxy 10.10.xx.20:8080
                }
                reverse_proxy 10.10.xx.20:8081 {
                        header_up X-Forwarded-Proto {scheme}
                        header_up X-Script-Name /octoprint
                }
        }
        # Thats still [WIP](https://github.com/alexjustesen/speedtest-tracker/issues/1932)
        redir /speedtest /speedtest/
        handle_path /speedtest/* {
                rewrite /admin* /speedtest/admin*
                reverse_proxy 10.10.xx.20:8082 {
                        header_up X-Script-Name /speedtest
                }
        }
        redir /guacamole /guacamole/
        handle_path /guacamole/* {
                reverse_proxy 10.10.xx.20:8083 {
                        header_up X-Script-Name /guacamole
                }
        }
        redir /restreamer /restreamer/
        handle_path /restreamer/* {
                reverse_proxy 10.10.xx.20:8084
        }
        redir /go2rtc /go2rtc/
        handle_path /go2rtc/* {
                import private-only
                reverse_proxy 10.10.xx.20:8080
        }
}

Those services are made publicly available through a Cloudflare tunnel as public IP aren't that commonly available where I life:

---
services:
  caddy:
    image: caddy:latest
    restart: unless-stopped
    cap_add:
      - NET_ADMIN
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    networks:
      - reverseproxy_net
    volumes:
      - /srv/docker/reverseproxy/config:/etc/caddy
      - /srv/docker/reverseproxy/site:/srv
      - /srv/docker/reverseproxy/data:/data
  tunnel:
    container_name: caddy-cloudflared-tunnel
    image: cloudflare/cloudflared
    restart: unless-stopped
    command: tunnel run
    environment:
      - TUNNEL_TOKEN=MYTOKEN

networks:
  reverseproxy_net:
    name: reverseproxy_net
    driver: bridge

In Cloudflare you need to disable HTTP>HTTPS rewriting, that way tha Caddy Docker will get LE Certs and the nonexisting Public-IP isn't a Problem any longer <3