Skip to content

Commit

Permalink
Use compiled ffmpeg binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
iosifnicolae2 authored Jul 1, 2023
1 parent fea2806 commit fb44911
Showing 1 changed file with 4 additions and 103 deletions.
107 changes: 4 additions & 103 deletions hls-streaming/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,113 +1,14 @@
###############################
# Build the FFmpeg-build image.
FROM --platform=linux/amd64 alpine:3.13 as build

ARG PREFIX=/opt/ffmpeg
ARG LD_LIBRARY_PATH=/opt/ffmpeg/lib
ARG MAKEFLAGS="-j4"

# FFmpeg build dependencies.
RUN apk add --update \
git \
build-base \
coreutils \
freetype-dev \
gcc \
lame-dev \
libogg-dev \
libass \
libass-dev \
libvpx-dev \
libvorbis-dev \
libwebp-dev \
libtheora-dev \
opus-dev \
openssl \
openssl-dev \
pkgconf \
pkgconfig \
rtmpdump-dev \
wget \
x264-dev \
x265-dev \
yasm

# Get fdk-aac from community.
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
apk add --update fdk-aac-dev

# Get rav1e from testing.
RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories && \
apk add --update rav1e-dev

# Get ffmpeg source.
RUN cd /tmp/ && \
git clone https://github.com/iosifnicolae2/FFmpeg.git ffmpeg

# Compile ffmpeg.
RUN cd /tmp/ffmpeg && \
./configure \
--enable-version3 \
--enable-gpl \
--enable-nonfree \
--enable-small \
--enable-libmp3lame \
--enable-libx264 \
--enable-libx265 \
--enable-libvpx \
--enable-libtheora \
--enable-libvorbis \
--enable-libopus \
--enable-libfdk-aac \
--enable-libass \
--enable-libwebp \
--enable-librtmp \
--enable-librav1e \
--enable-postproc \
--enable-libfreetype \
--enable-openssl \
--disable-debug \
--disable-doc \
--disable-ffplay \
--extra-cflags="-I${PREFIX}/include" \
--extra-ldflags="-L${PREFIX}/lib" \
--extra-libs="-lpthread -lm" \
--prefix="${PREFIX}" && \
make && make install && make distclean

# Cleanup.
RUN rm -rf /var/cache/apk/* /tmp/*

##########################
# Build the release image.
FROM --platform=linux/amd64 alpine:3.13
LABEL MAINTAINER Alfred Gutierrez <[email protected]>
ENV PATH=/opt/ffmpeg/bin:$PATH

RUN apk add --update \
ca-certificates \
openssl \
pcre \
lame \
libogg \
libass \
libvpx \
libvorbis \
libwebp \
libtheora \
opus \
rtmpdump \
x264-dev \
x265-dev \
bash
bash \
curl

RUN apk add rav1e-libs --repository=https://dl-cdn.alpinelinux.org/alpine/edge/testing

COPY --from=build /opt/ffmpeg /opt/ffmpeg
COPY --from=build /usr/lib/libfdk-aac.so.2 /usr/lib/libfdk-aac.so.2
COPY --from=build /usr/lib/librav1e.so /usr/lib/librav1e.so
RUN curl -Lf# https://github.com/homebridge/ffmpeg-for-homebridge/releases/latest/download/ffmpeg-alpine-x86_64.tar.gz | tar xzf - -C / --no-same-owner

HEALTHCHECK --start-period=10s --interval=5s --timeout=3s \
CMD [[ ! -f /data/index.m3u8 ]] && echo "is starting.." && exit 1 || s=$(( $(date +%s) - $(stat /data/index.m3u8 -c %Y) )) && [ "$s" -lt "60" ] && echo "is up" && exit 0 || echo "is down" && rm -f /data/index.m3u8 && exit 1

CMD ["ffmpeg"]
CMD ["ffmpeg"]

1 comment on commit fb44911

@vercel
Copy link

@vercel vercel bot commented on fb44911 Jul 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.