Skip to content

Commit e666824

Browse files
committed
Build FFmpeg
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 7c2ca27 commit e666824

File tree

5 files changed

+109
-76
lines changed

5 files changed

+109
-76
lines changed

.ffmpeg/Dockerfile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
FROM ubuntu:noble AS builder
2+
ARG VERSION_FFMPEG="7.1"
3+
ARG VERSION_RCLONE="v1.68.2"
4+
ARG VERSION_GO="latest"
5+
6+
USER root
7+
8+
#======================================
9+
# Install build tools
10+
#======================================
11+
ARG TOOLS_DEPS="autoconf automake cmake libfreetype6 gcc build-essential libtool make nasm pkg-config zlib1g-dev numactl \
12+
libnuma-dev libx11-6 libxcb1 libxcb1-dev yasm git curl jq wget ca-certificates"
13+
14+
RUN apt-get update -qqy \
15+
&& apt-get upgrade -yq \
16+
&& apt-get -qqy --no-install-recommends install ${TOOLS_DEPS} \
17+
&& apt-get -qyy clean \
18+
&& mkdir -p /usr/local/src
19+
20+
RUN if [ "${VERSION_GO}" = "latest" ]; then \
21+
VERSION_GO=$(curl -sk https://go.dev/dl/?mode=json | jq -r '.[0].version'); \
22+
fi \
23+
&& curl -skLO https://go.dev/dl/$VERSION_GO.linux-$(dpkg --print-architecture).tar.gz \
24+
&& tar -xf $VERSION_GO.linux-$(dpkg --print-architecture).tar.gz -C /usr/local \
25+
&& rm -rf $VERSION_GO.linux-$(dpkg --print-architecture).tar.gz* \
26+
&& ln -sf /usr/local/go/bin/go /usr/bin/go \
27+
&& go version
28+
29+
RUN cd /usr/local/src \
30+
&& git clone https://github.com/rclone/rclone.git \
31+
&& cd rclone \
32+
&& git checkout $VERSION_RCLONE \
33+
&& make \
34+
&& mv ~/go/bin/rclone /usr/local/bin/ \
35+
&& rclone version
36+
37+
#======================================
38+
# Install x264 from source
39+
#======================================
40+
RUN cd /usr/local/src \
41+
&& git clone https://code.videolan.org/videolan/x264.git \
42+
&& cd x264 \
43+
&& ./configure --prefix="/usr/local" --enable-static \
44+
&& make \
45+
&& make install
46+
47+
#======================================
48+
# Install FFmpeg from source
49+
#======================================
50+
RUN cd /usr/local/src \
51+
&& git clone https://github.com/FFmpeg/FFmpeg.git \
52+
&& cd FFmpeg \
53+
&& git checkout release/$VERSION_FFMPEG \
54+
&& PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure \
55+
--prefix="/usr/local" \
56+
--extra-cflags="-I/usr/local/include" \
57+
--extra-ldflags="-L/usr/local/lib" \
58+
--pkg-config-flags="--static" \
59+
--enable-gpl \
60+
--enable-nonfree \
61+
--enable-libx264 \
62+
--enable-libxcb \
63+
--enable-static \
64+
&& make \
65+
&& make install
66+
67+
# Final stage
68+
FROM ubuntu:noble
69+
70+
USER root
71+
72+
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
73+
COPY --from=builder /usr/local/bin/rclone /usr/local/bin/rclone
74+
75+
RUN apt-get -qqy update \
76+
&& apt-get -qqy --no-install-recommends install \
77+
libx11-dev libxcb1 libxcb-shm0 \
78+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
79+
80+
RUN ffmpeg -version \
81+
&& rclone --version

Makefile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(TAG_VERSION)))
2020
FFMPEG_VERSION := $(or $(FFMPEG_VERSION),$(FFMPEG_VERSION),7.1)
2121
FFMPEG_TAG_PREV_VERSION := $(or $(FFMPEG_TAG_PREV_VERSION),$(FFMPEG_TAG_PREV_VERSION),ffmpeg-7.1)
2222
FFMPEG_TAG_VERSION := $(or $(FFMPEG_TAG_VERSION),$(FFMPEG_TAG_VERSION),ffmpeg-7.1)
23-
FFMPEG_BASED_NAME := $(or $(FFMPEG_BASED_NAME),$(FFMPEG_BASED_NAME),linuxserver)
24-
FFMPEG_BASED_TAG := $(or $(FFMPEG_BASED_TAG),$(FFMPEG_BASED_TAG),version-7.1-cli)
23+
FFMPEG_BASED_NAME := $(or $(FFMPEG_BASED_NAME),$(FFMPEG_BASED_NAME),selenium)
24+
FFMPEG_BASED_TAG := $(or $(FFMPEG_BASED_TAG),$(FFMPEG_BASED_TAG),latest)
2525
CURRENT_PLATFORM := $(shell if [ `arch` = "aarch64" ] || [ `arch` = "arm64" ]; then echo "linux/arm64"; else echo "linux/amd64"; fi)
2626
PLATFORMS := $(or $(PLATFORMS),$(shell echo $$PLATFORMS),$(CURRENT_PLATFORM))
2727
SEL_PASSWD := $(or $(SEL_PASSWD),$(SEL_PASSWD),secret)
@@ -144,7 +144,7 @@ sessionqueue: base
144144
event_bus: base
145145
cd ./EventBus && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) -t $(NAME)/event-bus:$(TAG_VERSION) .
146146

147-
node_base: base
147+
node_base: base video
148148
cd ./NodeBase && SEL_PASSWD=$(SEL_PASSWD) docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) $(FROM_IMAGE_ARGS) --secret id=SEL_PASSWD -t $(NAME)/node-base:$(TAG_VERSION) .
149149

150150
chrome: node_base
@@ -246,7 +246,10 @@ standalone_edge_beta: edge_beta
246246
cd ./Standalone && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg NAMESPACE=$(NAME) --build-arg VERSION=beta --build-arg BASE=node-edge -t $(NAME)/standalone-edge:beta .
247247

248248
video: base
249-
cd ./Video && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION_FFMPEG=$(FFMPEG_VERSION) $(FROM_IMAGE_ARGS) -t $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) .
249+
cd ./Video && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg FFMPEG_BASED_NAME=$(FFMPEG_BASED_NAME) --build-arg FFMPEG_BASED_TAG=$(FFMPEG_BASED_TAG) $(FROM_IMAGE_ARGS) -t $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) .
250+
251+
ffmpeg:
252+
cd ./.ffmpeg && docker buildx build --platform $(PLATFORMS) $(BUILD_ARGS) --build-arg VERSION_FFMPEG=$(FFMPEG_VERSION) $(FROM_IMAGE_ARGS) -t $(NAME)/ffmpeg:$(FFMPEG_VERSION)-$(BUILD_DATE) .
250253

251254
fetch_grid_scaler_resources:
252255
mkdir -p ./.keda/scalers \
@@ -333,6 +336,10 @@ tag_and_push_edge_images:
333336
tag_and_push_firefox_images:
334337
./tag_and_push_browser_images.sh $(VERSION) $(BUILD_DATE) $(NAMESPACE) $(PUSH_IMAGE) firefox
335338

339+
tag_ffmpeg_latest:
340+
docker tag $(NAME)/ffmpeg:$(FFMPEG_VERSION)-$(BUILD_DATE) $(NAME)/ffmpeg:latest
341+
docker tag $(NAME)/ffmpeg:$(FFMPEG_VERSION)-$(BUILD_DATE) $(NAME)/ffmpeg:$(FFMPEG_VERSION)
342+
336343
tag_latest:
337344
docker tag $(NAME)/base:$(TAG_VERSION) $(NAME)/base:latest
338345
docker tag $(NAME)/hub:$(TAG_VERSION) $(NAME)/hub:latest
@@ -354,6 +361,11 @@ tag_latest:
354361
docker tag $(NAME)/standalone-docker:$(TAG_VERSION) $(NAME)/standalone-docker:latest
355362
docker tag $(NAME)/video:$(FFMPEG_TAG_VERSION)-$(BUILD_DATE) $(NAME)/video:latest
356363

364+
release_ffmpeg_latest:
365+
docker push $(NAME)/ffmpeg:latest
366+
docker push $(NAME)/ffmpeg:$(FFMPEG_VERSION)
367+
docker push $(NAME)/ffmpeg:$(FFMPEG_VERSION)-$(BUILD_DATE)
368+
357369
release_latest: release_grid_scaler_latest
358370
docker push $(NAME)/base:latest
359371
docker push $(NAME)/hub:latest

NodeBase/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ENV LANG_WHICH=${LANG_WHICH} \
5050
#============================
5151
# Some configuration options
5252
#============================
53+
SE_RECORD_VIDEO=false \
5354
SE_SCREEN_WIDTH=1920 \
5455
SE_SCREEN_HEIGHT=1080 \
5556
SE_SCREEN_DEPTH=24 \

Video/Dockerfile

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,9 @@
11
ARG NAMESPACE=selenium
22
ARG BASE=base
33
ARG VERSION=latest
4-
FROM ${NAMESPACE}/${BASE}:${VERSION} AS builder
5-
ARG VERSION_FFMPEG="7.1"
6-
ARG VERSION_RCLONE="v1.68.2"
7-
ARG VERSION_GO="1.23.3"
8-
9-
USER root
10-
11-
#======================================
12-
# Install build tools
13-
#======================================
14-
ARG TOOLS_DEPS="autoconf automake cmake libfreetype6 gcc build-essential libtool make nasm pkg-config zlib1g-dev numactl \
15-
libnuma-dev libx11-6 libxcb1 libxcb1-dev yasm git"
16-
17-
RUN apt-get update -qqy \
18-
&& apt-get -qqy --no-install-recommends install ${TOOLS_DEPS} \
19-
&& apt-get -qyy clean \
20-
&& mkdir -p /usr/local/src
21-
22-
RUN curl -sLO https://go.dev/dl/go$VERSION_GO.linux-$(dpkg --print-architecture).tar.gz \
23-
&& tar -xf go$VERSION_GO.linux-$(dpkg --print-architecture).tar.gz -C /usr/local \
24-
&& rm -rf go$VERSION_GO.linux-$(dpkg --print-architecture).tar.gz* \
25-
&& ln -sf /usr/local/go/bin/go /usr/bin/go \
26-
&& go version
27-
28-
RUN cd /usr/local/src \
29-
&& git clone https://github.com/rclone/rclone.git \
30-
&& cd rclone \
31-
&& git checkout $VERSION_RCLONE \
32-
&& make \
33-
&& mv ~/go/bin/rclone /usr/local/bin/ \
34-
&& rclone version
35-
36-
#======================================
37-
# Install x264 from source
38-
#======================================
39-
RUN cd /usr/local/src \
40-
&& git clone https://code.videolan.org/videolan/x264.git \
41-
&& cd x264 \
42-
&& ./configure --prefix="/usr/local" --enable-static \
43-
&& make \
44-
&& make install
45-
46-
#======================================
47-
# Install FFmpeg from source
48-
#======================================
49-
RUN cd /usr/local/src \
50-
&& git clone https://github.com/FFmpeg/FFmpeg.git \
51-
&& cd FFmpeg \
52-
&& git checkout release/$VERSION_FFMPEG \
53-
&& PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" ./configure \
54-
--prefix="/usr/local" \
55-
--extra-cflags="-I/usr/local/include" \
56-
--extra-ldflags="-L/usr/local/lib" \
57-
--pkg-config-flags="--static" \
58-
--enable-gpl \
59-
--enable-nonfree \
60-
--enable-libx264 \
61-
--enable-libxcb \
62-
&& make \
63-
&& make install
64-
65-
RUN rm -rf /usr/local/src/* \
66-
&& rm -rf /usr/local/go \
67-
&& apt-get remove -y ${TOOLS_DEPS} \
68-
&& apt-get -qyy autoremove
4+
ARG FFMPEG_BASED_NAME=selenium
5+
ARG FFMPEG_BASED_TAG=latest
6+
FROM ${FFMPEG_BASED_NAME}/ffmpeg:${FFMPEG_BASED_TAG} AS source
697

708
# Final stage
719
FROM ${NAMESPACE}/${BASE}:${VERSION}
@@ -74,7 +12,8 @@ LABEL authors=${AUTHORS}
7412

7513
USER root
7614

77-
COPY --from=builder /usr/local /usr/local
15+
COPY --from=source /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg
16+
COPY --from=source /usr/local/bin/rclone /usr/local/bin/rclone
7817

7918
RUN apt-get -qqy update \
8019
&& apt-get -qqy --no-install-recommends install \
@@ -88,13 +27,13 @@ COPY --chown="${SEL_UID}:${SEL_GID}" *.sh video_ready.py /opt/bin/
8827

8928
USER ${SEL_UID}
9029

91-
RUN ldd /usr/local/bin/ffmpeg \
92-
&& /usr/local/bin/ffmpeg -version \
30+
RUN ffmpeg -version \
9331
&& rclone --version \
9432
&& touch /opt/selenium/upload.conf
9533

9634
ENV DISPLAY_NUM=99 \
9735
DISPLAY_CONTAINER_NAME="selenium" \
36+
SE_RECORD_VIDEO=true \
9837
SE_SERVER_PROTOCOL="http" \
9938
SE_VIDEO_POLL_INTERVAL=1 \
10039
SE_SCREEN_WIDTH=1920 \

Video/recorder.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
priority=10
33
command=/opt/bin/video.sh
44
killasgroup=true
5-
autostart=true
5+
autostart=%(ENV_SE_RECORD_VIDEO)s
66
startsecs=0
7-
autorestart=true
7+
autorestart=%(ENV_SE_RECORD_VIDEO)s
88
stopsignal=TERM
99
stopwaitsecs=30
1010

@@ -17,9 +17,9 @@ stdout_logfile_maxbytes=0
1717
priority=0
1818
command=python3 /opt/bin/video_ready.py
1919
killasgroup=true
20-
autostart=true
20+
autostart=%(ENV_SE_RECORD_VIDEO)s
2121
startsecs=0
22-
autorestart=true
22+
autorestart=%(ENV_SE_RECORD_VIDEO)s
2323
stopsignal=KILL
2424

2525
;Logs (all activity redirected to stdout so it can be seen through "docker logs"

0 commit comments

Comments
 (0)