From 974b7d3c17e8ba77a137101a6e7bd321b1a1ba4d Mon Sep 17 00:00:00 2001 From: DavidGitter <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 00:30:55 +0200 Subject: [PATCH 01/12] added basic docker support --- .gitignore | 1 + Dockerfile | 22 ++++++++++++++++++++++ docker-compose.yaml | 16 ++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/.gitignore b/.gitignore index 402df09..b495cde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o /bambucam +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..85ef805 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +FROM debian:bookworm-slim + +ENV DEBIAN_FRONTEND=noninteractive + +ENV DEVICE_IP="printer-ip" +ENV DEVICE_ID="printer-serial-number" +ENV ACCESS_CODE="printer-access-code" +ENV PORT=1234 + +WORKDIR /app + +RUN mkdir plugins + +# copy the executable and plugins +COPY ./bambucam . +COPY ./plugins ./plugins + +# set plugin path +ENV PLUGIN_PATH=/app/plugins + +EXPOSE ${PORT} +ENTRYPOINT ["./bambucam"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..d8e0567 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +version: "3.8" + +services: + bambucam: + image: DockerSilas/bambucam:1.0.0 + container_name: bambucam + + ports: + - "8082:8082" # the port number mapping where the video stream is serviced + + env_file: + - .env + + restart: unless-stopped + + \ No newline at end of file From 41d82b117ef11d55e7c6ad0e7ab3831b0c0d8511 Mon Sep 17 00:00:00 2001 From: DavidGitter <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 00:34:31 +0200 Subject: [PATCH 02/12] updated docker support files --- Dockerfile | 20 ++++++++++++++-- docker-compose.yaml | 2 +- start.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 start.sh diff --git a/Dockerfile b/Dockerfile index 85ef805..99e58ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,19 @@ ENV DEBIAN_FRONTEND=noninteractive ENV DEVICE_IP="printer-ip" ENV DEVICE_ID="printer-serial-number" ENV ACCESS_CODE="printer-access-code" -ENV PORT=1234 +ENV PORT=8082 + +# true = retry to reach printer if its offline, false = shutdown +ENV KEEP_ALIVE=true + +# the interval (seconds) the printer is checked until available +ENV PING_INTERVAL=10 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + libmicrohttpd12 \ + libjpeg62-turbo \ + netcat-openbsd \ + && rm -rf /var/lib/apt/lists/* WORKDIR /app @@ -19,4 +31,8 @@ COPY ./plugins ./plugins ENV PLUGIN_PATH=/app/plugins EXPOSE ${PORT} -ENTRYPOINT ["./bambucam"] \ No newline at end of file + + +COPY start.sh . +RUN chmod +x start.sh +ENTRYPOINT ["./start.sh"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index d8e0567..937f593 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -11,6 +11,6 @@ services: env_file: - .env - restart: unless-stopped + restart: no \ No newline at end of file diff --git a/start.sh b/start.sh new file mode 100644 index 0000000..6c126d3 --- /dev/null +++ b/start.sh @@ -0,0 +1,56 @@ +#!/bin/sh +set -e + +# ENV defaults +DEVICE_IP="${DEVICE_IP}" +DEVICE_ID="${DEVICE_ID}" +ACCESS_CODE="${ACCESS_CODE}" +PORT="${PORT}" +KEEP_ALIVE="${KEEP_ALIVE}" # true = bleibt an, false = Container exit bei Fehler +PING_INTERVAL="${PING_INTERVAL}" # Sekunden zwischen Pings + + +# Funktion zum Maskieren, nur letzte 2 Zeichen anzeigen +# mask() { +# local val="$1" +# local len=${#val} +# if [ $len -le 2 ]; then +# echo "$val" +# else +# mask_len=$((len-2)) +# masked=$(printf '%*s' "$mask_len" '' | tr ' ' '*') +# echo "${masked}${val: -2}" +# fi +# } + +# Ausgabe aller ENV-Werte beim Start +echo "=== STARTING bambucam container ===" +echo "DEVICE_IP = $DEVICE_IP" +echo "DEVICE_ID = $DEVICE_ID" +echo "ACCESS_CODE = $ACCESS_CODE" +echo "PORT = $PORT" +echo "KEEP_ALIVE = $KEEP_ALIVE" +echo "PING_INTERVAL = $PING_INTERVAL" +echo "==================================" + +while true; do + # Prüfen, ob der Printer erreichbar ist + if nc -z -w2 "$DEVICE_IP" "6000"; then + echo "$(date '+%F %T') - printer available, starting bambucam" + # Bambucam starten und auf Exit warten + ./bambucam "$DEVICE_IP" "$DEVICE_ID" "$ACCESS_CODE" "$PORT" || true + EXIT_CODE=$? + echo "$(date '+%F %T') - bambucam exited with code $EXIT_CODE" + else + echo "$(date '+%F %T') - Printer not reachable (offline?)" + EXIT_CODE=1 + fi + + if [ "$KEEP_ALIVE" != "true" ]; then + echo "KEEP_ALIVE=false → Shutdown container" + exit $EXIT_CODE + fi + + echo "Waiting $PING_INTERVAL seconds before retrying..." + sleep $PING_INTERVAL +done \ No newline at end of file From 7dc0d1a332a7975d12e03a898e4b842b7514f288 Mon Sep 17 00:00:00 2001 From: DavidGitter <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:31:28 +0200 Subject: [PATCH 03/12] ignore plugin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b495cde..202d722 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.o /bambucam .env +*.so \ No newline at end of file From 84e7fa343913b3f908f129f07f2544f1db52a34f Mon Sep 17 00:00:00 2001 From: DavidGitter <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:31:49 +0200 Subject: [PATCH 04/12] updated readme --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index ed1a1ad..cd5a3eb 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,29 @@ flag. The supported video stream types are: - `HTTP`: Multipart JPEG stream using microhttpd - `RTP`: RTP video stream using FFmpeg +## Docker Usage +Use the following docker-compose.yaml to spawn a video-server: +````yaml +version: "3.8" + +services: + bambucam: + image: dockersilas/bambucam:1.0.0 + container_name: bambucam + + ports: + - "8082:8082" # the port number mapping where the video stream is serviced + + environment: + - DEVICE_ID="1A2B3C12345678" # your printer serial number (tho check for the right device) + - ACCESS_CODE="12345678" # your printer access code + - PORT=8082 # the port number where the video stream is serviced + - KEEP_ALIVE=true # true = run infinitly retrying if printer is offline, false = shutdown if printer offline + - PING_INTERVAL=10 # the interval (seconds) the printer is checked until available + + restart: no +```` + ## Build instructions Prepare the necessary `ffmpeg` and `libmicrohttpd` dependencies: From c4d8ec2e1eba64986433be731129974a56482b97 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:51:49 +0200 Subject: [PATCH 05/12] added credits --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cd5a3eb..ee07da9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ Bambu Cam ========= +Disclaimer: If you like the docker functionality and give this project a star, please consider checking out jtessler´s repo who made this possible creating this cli-tool. A simple wrapper around [Bambu Studio]'s `libBambuSource.so` prebuilt to access the camera frames from a 3D printer in LAN mode and, encode it, and serve a From 01566f0204487313ba7a3448b7515f030783ed65 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 18:57:01 +0200 Subject: [PATCH 06/12] Update README.md --- README.md | 115 ++---------------------------------------------------- 1 file changed, 3 insertions(+), 112 deletions(-) diff --git a/README.md b/README.md index ee07da9..dc4cc70 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,9 @@ Bambu Cam ========= -Disclaimer: If you like the docker functionality and give this project a star, please consider checking out jtessler´s repo who made this possible creating this cli-tool. +> [!NOTE] +> If you like the docker functionality and give this project a star, please consider also checking out jtessler´s repo who made this possible creating this cli-tool. -A simple wrapper around [Bambu Studio]'s `libBambuSource.so` prebuilt to access -the camera frames from a 3D printer in LAN mode and, encode it, and serve a -video stream at a given port. - -Usage: - -``` -$ bambucam -``` - -Where: - -- ``: Bambu printer local IP, e.g. `192.168.0.200` -- ``: Bambu printer ID (serial number), e.g. `0123456789ABCDE` -- ``: Bambu printer LAN mode pass code, e.g. `12345678` -- ``: Port on which to serve the video stream - -Bambu Cam supports multiple video stream types depending on the `SERVER` build -flag. The supported video stream types are: - -- `HTTP`: Multipart JPEG stream using microhttpd -- `RTP`: RTP video stream using FFmpeg +This repo contains the containerized version of jtessler´s BambuCam command-line tool which allowes setting up a webserver which streams the cam of Bamublab-Printers. ## Docker Usage Use the following docker-compose.yaml to spawn a video-server: @@ -47,92 +27,3 @@ services: restart: no ```` - -## Build instructions - -Prepare the necessary `ffmpeg` and `libmicrohttpd` dependencies: - -``` -$ sudo apt install \ - libavcodec-dev \ - libavformat-dev \ - libavutil-dev \ - libjpeg-dev \ - libmicrohttpd-dev -``` - -Assumes you have [Bambu Studio] installed and ran at least once to download the -expected plugins. - -``` -$ make -j -``` - -Use `PLUGIN_PATH` to specify a different path if the plugins are installed in a -directory other than the default `~/.config/BambuStudio/plugins`. - -``` -$ make PLUGIN_PATH=/path/to/bambu/plugins -j -``` - -Use `DEBUG` to add more verbose logging and build debug symbols. - -``` -$ make DEBUG=1 -j -``` - -Use `BAMBU_FAKE` to use a fake camera implementation to test without an actual -printer hardware. All device arguments are obviously ignored in this mode. - -``` -$ make BAMBU_FAKE=1 -j -``` - -Use `SERVER` to select the video streaming server implementation. More details -below. - -``` -$ make SERVER=RTP -j -``` - -## HTTP Stream Details - -``` -$ make SERVER=HTTP -j -``` - -The HTTP server uses [`multipart/x-mixed-replace`] to continuous send JPEG files -in a never-ending response. - -Build Bambu Cam with `SERVER=HTTP` and you can view the video stream on any web -browser by navigating to `http://localhost:/`. - -![Video stream example in a web browser](https://i.imgur.com/hvHuyc6.png]) - -[`multipart/x-mixed-replace`]:https://wiki.tcl-lang.org/page/multipart%2Fx-mixed-replace - -## RTP Stream Details - -``` -$ make SERVER=RTP -j -``` - -The RTP stream uses the Pro-MPEG Code of Practice #3 Release 2 FEC protocol, -which is "a 2D parity-check forward error correction mechanism for MPEG-2 -Transport Streams sent over RTP." Read more about the protocol in the [FFmpeg] -and [Wireshark] documention. - -VLC supports this protocol and explains why we can use the `rtp://` path -without serving any SDP nor RTSP information. - -Build Bambu Cam with `SERVER=RTP` and you can view the RTP stream in VLC: - -``` -$ vlc rtp://localhost/ -``` - -![Video stream example in VLC](https://i.imgur.com/lOo64MV.png) - -[Bambu Studio]:https://bambulab.com/en/download/studio -[FFmpeg]:https://ffmpeg.org/ffmpeg-protocols.html#prompeg -[Wireshark]:https://wiki.wireshark.org/2dParityFEC From 3d363a949136867b065630aba905b0ecbe01e118 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:00:08 +0200 Subject: [PATCH 07/12] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc4cc70..a0c42ae 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Bambu Cam > [!NOTE] > If you like the docker functionality and give this project a star, please consider also checking out jtessler´s repo who made this possible creating this cli-tool. -This repo contains the containerized version of jtessler´s BambuCam command-line tool which allowes setting up a webserver which streams the cam of Bamublab-Printers. +This repo contains the containerized version of jtessler´s BambuCam command-line tool which allowes setting up a webserver which streams the cam of Bambulab-Printers. ## Docker Usage Use the following docker-compose.yaml to spawn a video-server: @@ -18,10 +18,11 @@ services: ports: - "8082:8082" # the port number mapping where the video stream is serviced - environment: - - DEVICE_ID="1A2B3C12345678" # your printer serial number (tho check for the right device) + environment: + - DEVICE_IP: "192.168.168.172" # your printers ip + - DEVICE_ID="1A2B3C12345678" # your printer serial number (tho check if its the right device) - ACCESS_CODE="12345678" # your printer access code - - PORT=8082 # the port number where the video stream is serviced + - PORT=8082 # the port number where the video stream should be serviced - KEEP_ALIVE=true # true = run infinitly retrying if printer is offline, false = shutdown if printer offline - PING_INTERVAL=10 # the interval (seconds) the printer is checked until available From e08a469802afdf70db326569deef86341b20ad17 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:04:55 +0200 Subject: [PATCH 08/12] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index a0c42ae..3e95232 100644 --- a/README.md +++ b/README.md @@ -28,3 +28,11 @@ services: restart: no ```` + +## Building the Image +If you want to build the docker image for yourself, follow those steps: +- clone this repo +- create a folder "plugins" +- put your "libBambuStudio.so" in there which is made available by Bambulab Software +- follow the building steps of jtessler´s repo (building the bambucam executeable in the repo root directory) +- build using the Dockerfile From c84bf53c55f20ce0f4a6990cd7330e486fc6c290 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:05:52 +0200 Subject: [PATCH 09/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e95232..8da3cf3 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ services: ```` ## Building the Image -If you want to build the docker image for yourself, follow those steps: +If you want to build the docker image by yourself, follow those steps: - clone this repo - create a folder "plugins" - put your "libBambuStudio.so" in there which is made available by Bambulab Software From 96c7bc2d3cbd482eb57c7230bac2a820cca23726 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Tue, 31 Mar 2026 19:17:03 +0200 Subject: [PATCH 10/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8da3cf3..9e73026 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ services: - "8082:8082" # the port number mapping where the video stream is serviced environment: - - DEVICE_IP: "192.168.168.172" # your printers ip + - DEVICE_IP="192.168.1.123" # your printers ip - DEVICE_ID="1A2B3C12345678" # your printer serial number (tho check if its the right device) - ACCESS_CODE="12345678" # your printer access code - PORT=8082 # the port number where the video stream should be serviced From ba461e87ad630c1db8842820bc19e70aec6a7d04 Mon Sep 17 00:00:00 2001 From: DavidGitter <80157809+DavidGitter@users.noreply.github.com> Date: Wed, 1 Apr 2026 20:20:47 +0200 Subject: [PATCH 11/12] fixed image name --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 937f593..424b0c4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,7 +2,7 @@ version: "3.8" services: bambucam: - image: DockerSilas/bambucam:1.0.0 + image: dockersilas/bambucam:1.0.0 container_name: bambucam ports: From 36f27031fc556064ffb25cbe0af1c42fc0e4cc68 Mon Sep 17 00:00:00 2001 From: Silas Jung <80157809+DavidGitter@users.noreply.github.com> Date: Fri, 3 Apr 2026 20:34:37 +0200 Subject: [PATCH 12/12] Update README.md --- README.md | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9e73026..e880429 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,28 @@ Bambu Cam ========= -> [!NOTE] -> If you like the docker functionality and give this project a star, please consider also checking out jtessler´s repo who made this possible creating this cli-tool. -This repo contains the containerized version of jtessler´s BambuCam command-line tool which allowes setting up a webserver which streams the cam of Bambulab-Printers. +A simple wrapper around [Bambu Studio]'s `libBambuSource.so` prebuilt to access +the camera frames from a 3D printer in LAN mode and, encode it, and serve a +video stream at a given port. + +Usage: + +``` +$ bambucam +``` + +Where: + +- ``: Bambu printer local IP, e.g. `192.168.0.200` +- ``: Bambu printer ID (serial number), e.g. `0123456789ABCDE` +- ``: Bambu printer LAN mode pass code, e.g. `12345678` +- ``: Port on which to serve the video stream + +Bambu Cam supports multiple video stream types depending on the `SERVER` build +flag. The supported video stream types are: + +- `HTTP`: Multipart JPEG stream using microhttpd +- `RTP`: RTP video stream using FFmpeg ## Docker Usage Use the following docker-compose.yaml to spawn a video-server: @@ -36,3 +55,92 @@ If you want to build the docker image by yourself, follow those steps: - put your "libBambuStudio.so" in there which is made available by Bambulab Software - follow the building steps of jtessler´s repo (building the bambucam executeable in the repo root directory) - build using the Dockerfile + +## Build instructions + +Prepare the necessary `ffmpeg` and `libmicrohttpd` dependencies: + +``` +$ sudo apt install \ + libavcodec-dev \ + libavformat-dev \ + libavutil-dev \ + libjpeg-dev \ + libmicrohttpd-dev +``` + +Assumes you have [Bambu Studio] installed and ran at least once to download the +expected plugins. + +``` +$ make -j +``` + +Use `PLUGIN_PATH` to specify a different path if the plugins are installed in a +directory other than the default `~/.config/BambuStudio/plugins`. + +``` +$ make PLUGIN_PATH=/path/to/bambu/plugins -j +``` + +Use `DEBUG` to add more verbose logging and build debug symbols. + +``` +$ make DEBUG=1 -j +``` + +Use `BAMBU_FAKE` to use a fake camera implementation to test without an actual +printer hardware. All device arguments are obviously ignored in this mode. + +``` +$ make BAMBU_FAKE=1 -j +``` + +Use `SERVER` to select the video streaming server implementation. More details +below. + +``` +$ make SERVER=RTP -j +``` + +## HTTP Stream Details + +``` +$ make SERVER=HTTP -j +``` + +The HTTP server uses [`multipart/x-mixed-replace`] to continuous send JPEG files +in a never-ending response. + +Build Bambu Cam with `SERVER=HTTP` and you can view the video stream on any web +browser by navigating to `http://localhost:/`. + +![Video stream example in a web browser](https://i.imgur.com/hvHuyc6.png]) + +[`multipart/x-mixed-replace`]:https://wiki.tcl-lang.org/page/multipart%2Fx-mixed-replace + +## RTP Stream Details + +``` +$ make SERVER=RTP -j +``` + +The RTP stream uses the Pro-MPEG Code of Practice #3 Release 2 FEC protocol, +which is "a 2D parity-check forward error correction mechanism for MPEG-2 +Transport Streams sent over RTP." Read more about the protocol in the [FFmpeg] +and [Wireshark] documention. + +VLC supports this protocol and explains why we can use the `rtp://` path +without serving any SDP nor RTSP information. + +Build Bambu Cam with `SERVER=RTP` and you can view the RTP stream in VLC: + +``` +$ vlc rtp://localhost/ +``` + +![Video stream example in VLC](https://i.imgur.com/lOo64MV.png) + +[Bambu Studio]:https://bambulab.com/en/download/studio +[FFmpeg]:https://ffmpeg.org/ffmpeg-protocols.html#prompeg +[Wireshark]:https://wiki.wireshark.org/2dParityFEC