Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework docker setup #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BambuSource2Raw/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
33 changes: 21 additions & 12 deletions BambuSource2Raw/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y curl
RUN mkdir -p /bambu-bin
RUN mkdir -p /bambu-bin/cfg
WORKDIR /bambu-bin
COPY bambusource2raw /bambu-bin/bambusource2raw
COPY start_rtsp_feed_docker.sh /bambu-bin/start_rtsp_feed_docker.sh
COPY ffmpeg /bambu-bin/ffmpeg
COPY rtsp-simple-server /bambu-bin/rtsp-simple-server
COPY rtsp-simple-server.yml /bambu-bin/rtsp-simple-server.yml
COPY libBambuSource.so /bambu-bin/libBambuSource.so
FROM debian:latest as builder
RUN set -e; apt-get update; apt-get install -y curl libcurl4 unzip libcurl4-openssl-dev build-essential; \
apt-get clean; rm -rf /var/cache/apt;
RUN mkdir -p /app/build
WORKDIR /app
COPY Makefile.linux ./
ENV outdir="./build"
ENV MAKEFILES="./Makefile.linux"
RUN make libBambuSource.so
RUN make ffmpeg
RUN make rtsp-simple-server
COPY *.c *.h *.cpp ./
RUN make bambusource2raw

FROM debian:latest as runner
COPY --from=builder /app/build/* /usr/local/bin/
COPY --from=builder /app/build/*.yml /bambu-bin/
RUN set -e; apt-get update; apt-get install -y libcurl4 curl; \
apt-get clean; rm -rf /var/cache/apt;
COPY docker_entrypoint.sh /usr/local/bin
EXPOSE 8554
CMD ["/bin/bash", "/bambu-bin/start_rtsp_feed_docker.sh"]
ENTRYPOINT ["docker_entrypoint.sh"]
39 changes: 12 additions & 27 deletions BambuSource2Raw/Makefile.linux
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cc = g++
outdir = ../linux-build
outdir ?= ../linux-build
bin = bambusource2raw
cflags = $(shell curl-config --cflags)
ldflags = -ldl $(shell curl-config --libs)
Expand All @@ -15,49 +15,34 @@ RTSP_SIMPLE_SERVER_DOWNLOAD=/tmp/rtsp-simple-server_v0.20.0_linux_amd64.tar.gz
BAMBU_SOURCE_URL=https://upgrade-file.bambulab.cn/studio/plugins/01.03.00.02/linux_01.03.00.02.zip
BAMBU_SOURCE_DOWNLOAD=/tmp/bambusource_linux_01.03.00.02.zip

all: $(outdir) $(outdir)/$(bin) $(outdir)/Dockerfile $(outdir)/start_rtsp_feed_docker.sh $(outdir)/start_rtsp_feed.sh $(outdir)/libBambuSource.so $(outdir)/ffmpeg $(outdir)/rtsp-simple-server
all: $(outdir) $(bin) libBambuSource.so ffmpeg rtsp-simple-server

$(bin): $(obj)
@$(cc) -o $(bin) $(obj) $(ldflags)
@$(cc) -o "$(outdir)/$(bin)" $(obj) $(ldflags)

%.o: %.c $(deps)
@$(cc) $(cflags) -c $< -o $@

$(outdir):
$(outdir):
-mkdir -p $(outdir)

$(outdir)/$(bin): $(bin)
cp -f $< $(outdir)
chmod +x $@

$(outdir)/Dockerfile: Dockerfile
cp -f $< $(outdir)

$(outdir)/start_rtsp_feed_docker.sh: start_rtsp_feed_docker.sh
cp -f $< $(outdir)
chmod +x $@

$(outdir)/start_rtsp_feed.sh: start_rtsp_feed.sh
cp -f $< $(outdir)
chmod +x $@

$(outdir)/ffmpeg:
wget -O $(FFMPEG_DOWNLOAD) $(FFMPEG_URL)
tar -xf $(FFMPEG_DOWNLOAD) ffmpeg-5.1.1-amd64-static/ffmpeg -O > $(outdir)/ffmpeg
ffmpeg:
curl -LqSs -o "$(FFMPEG_DOWNLOAD)" $(FFMPEG_URL)
tar -xf "$(FFMPEG_DOWNLOAD)" ffmpeg-5.1.1-amd64-static/ffmpeg -O > $(outdir)/ffmpeg
chmod +x $(outdir)/ffmpeg
-rm $(FFMPEG_DOWNLOAD)

$(outdir)/rtsp-simple-server:
wget -O $(RTSP_SIMPLE_SERVER_DOWNLOAD) $(RTSP_SIMPLE_SERVER_URL)
rtsp-simple-server:
curl -LqSs -o "$(RTSP_SIMPLE_SERVER_DOWNLOAD)" $(RTSP_SIMPLE_SERVER_URL)
tar -xf $(RTSP_SIMPLE_SERVER_DOWNLOAD) rtsp-simple-server -O > $(outdir)/rtsp-simple-server
tar -xf $(RTSP_SIMPLE_SERVER_DOWNLOAD) rtsp-simple-server.yml -O > $(outdir)/rtsp-simple-server.yml
chmod +x $(outdir)/rtsp-simple-server
-rm $(RTSP_SIMPLE_SERVER_DOWNLOAD)

$(outdir)/libBambuSource.so:
wget -O $(BAMBU_SOURCE_DOWNLOAD) $(BAMBU_SOURCE_URL)
libBambuSource.so:
curl -LqSs -o "$(BAMBU_SOURCE_DOWNLOAD)" "$(BAMBU_SOURCE_URL)"
unzip $(BAMBU_SOURCE_DOWNLOAD) libBambuSource.so -d $(outdir)
-rm $(BAMBU_SOURCE_DOWNLOAD)

clean:
-rm -rf $(obj) $(bin) $(outdir)/$(bin)
-rm -rf $(obj) $(bin) $(outdir)/$(bin)
9 changes: 9 additions & 0 deletions BambuSource2Raw/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -ueo pipefail
RTSP_URL="rtsp://127.0.0.1:8554/bbl"
cd /bambu-bin
rtsp-simple-server 2>&1 > /dev/null &
sleep 10s
cd cfg
echo "Starting stream at: ${RTSP_URL}"
bambusource2raw | ffmpeg -hide_banner -loglevel error -i - -c copy -f rtsp "${RTSP_URL}"
Empty file modified BambuSource2Raw/start_rtsp_feed.sh
100644 → 100755
Empty file.
33 changes: 0 additions & 33 deletions BambuSource2Raw/start_rtsp_feed_docker.sh

This file was deleted.

12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
3. Close BambuStudio and it will generate `BambuNetworkEngine.conf` under `X:\Users\[user_name]\AppData\Roaming\BambuStudio`
4. Download release archive of this project or just compile your own.


## Docker Setup

Quick and easy way to setup BambuSource2Raw is through the provided Docker builder.

```bash
git clone https://github.com/hisptoot/BambuSource2Raw
cd BambuSource2Raw/BambuSource2Raw/
docker build -t bblrtsp:v1 .
docker run --rm --name BambuRTSP-1 -p 8554:8554 -v "${HOME}/.config/BambuStudio:/bambu-bin/cfg:ro" bblrtsp:v1
```

## Linux
1.
apt-get install -y libcurl4
Expand Down