-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: 'base:ubuntu-ffmpeg-cuda' | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches-ignore: | ||
- '**' | ||
|
||
jobs: | ||
docker: | ||
runs-on: [self-hosted] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: 'Build.ubuntu.env' | ||
export: 'true' | ||
expandWithJobEnv: 'true' | ||
expand: 'true' | ||
|
||
- uses: cardinalby/export-env-action@v1 | ||
with: | ||
envFile: 'Build.ubuntu.cuda.env' | ||
export: 'true' | ||
expandWithJobEnv: 'true' | ||
expand: 'true' | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@master | ||
with: | ||
platforms: all | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@master | ||
|
||
- name: Cache Docker layers | ||
uses: actions/cache@v2 | ||
with: | ||
path: /tmp/.buildx-cache | ||
key: ${{ runner.os }}-buildx-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-buildx- | ||
- name: Login to DockerHub | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build Multi-Arch | ||
uses: docker/build-push-action@v2 | ||
with: | ||
builder: ${{ steps.buildx.outputs.name }} | ||
context: . | ||
file: ./Dockerfile.ubuntu.cuda | ||
build-args: | | ||
BUILD_IMAGE=nvidia/cuda:${{ env.CUDA_VERSION }}-devel-${{ env.OS_NAME }}${{ env.OS_VERSION }} | ||
DEPLOY_IMAGE=nvidia/cuda:${{ env.CUDA_VERSION }}-runtime-${{ env.OS_NAME }}${{ env.OS_VERSION }} | ||
FFNVCODEC_VERSION=${{ env.FFNVCODEC_VERSION }} | ||
FREETYPE_VERSION=${{ env.FREETYPE_VERSION }} | ||
XML2_VERSION=${{ env.XML2_VERSION }} | ||
SRT_VERSION=${{ env.SRT_VERSION }} | ||
X264_VERSION=${{ env.X264_VERSION }} | ||
X265_VERSION=${{ env.X265_VERSION }} | ||
VPX_VERSION=${{ env.VPX_VERSION }} | ||
LAME_VERSION=${{ env.LAME_VERSION }} | ||
OPUS_VERSION=${{ env.OPUS_VERSION }} | ||
OGG_VERSION=${{ env.OGG_VERSION }} | ||
VORBIS_VERSION=${{ env.VORBIS_VERSION }} | ||
FFMPEG_VERSION=${{ env.FFMPEG_VERSION }} | ||
platforms: linux/amd64 | ||
push: true | ||
tags: | | ||
datarhei/base:${{ env.OS_NAME }}-ffmpeg-cuda-${{ env.OS_VERSION }}-${{ env.FFMPEG_VERSION }}-${{env.CUDA_VERSION}} | ||
datarhei/base:${{ env.OS_NAME }}-ffmpeg-cuda-latest | ||
cache-from: type=local,src=/tmp/.buildx-cache | ||
cache-to: type=local,dest=/tmp/.buildx-cache-new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# FFMPEG CUDA PACKAGES | ||
CUDA_VERSION=11.4.2 | ||
FFNVCODEC_VERSION=11.1.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# FFMPEG BASE PACKAGES | ||
OS_NAME=ubuntu | ||
OS_VERSION=20.04 | ||
FREETYPE_VERSION=2.10.4 | ||
ENV LIBXML2_VERSION=2.9.14 | ||
SRT_VERSION=1.4.4 | ||
X264_VERSION=stable | ||
X265_VERSION=3.4 | ||
VPX_VERSION=1.11.0 | ||
LAME_VERSION=3.100 | ||
OPUS_VERSION=1.3.1 | ||
OGG_VERSION=1.3.5 | ||
VORBIS_VERSION=1.3.7 | ||
FFMPEG_VERSION=4.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
ARG BUILD_IMAGE=nvidia/cuda:11.4.2-devel-ubuntu20.04 | ||
ARG DEPLOY_IMAGE=nvidia/cuda:11.4.2-runtime-ubuntu20.04 | ||
|
||
FROM $BUILD_IMAGE as builder | ||
|
||
ARG FFNVCODEC_VERSION=11.1.5.1 | ||
|
||
ARG FREETYPE_VERSION=2.10.4 | ||
ENV XML2_VERSION=2.9.14 | ||
ARG SRT_VERSION=1.4.2 | ||
ARG X264_VERSION=stable | ||
ARG X265_VERSION=3.4 | ||
ENV VPX_VERSION=1.11.0 | ||
ARG LAME_VERSION=3.100 | ||
ARG OPUS_VERSION=1.3.1 | ||
ENV OGG_VERSION=1.3.5 | ||
ARG VORBIS_VERSION=1.3.7 | ||
ARG FFMPEG_VERSION=4.4.2 | ||
|
||
ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig | ||
ENV SRC=/usr/local | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update -y && \ | ||
apt-get install -y \ | ||
pkg-config \ | ||
curl \ | ||
git \ | ||
nasm \ | ||
openssl \ | ||
libssl-dev \ | ||
cmake \ | ||
yasm \ | ||
build-essential \ | ||
libtool \ | ||
autoconf \ | ||
libv4l-dev | ||
|
||
# install x264 | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://code.videolan.org/videolan/x264/-/archive/stable/x264-${X264_VERSION}.tar.gz && \ | ||
tar xfvz x264-${X264_VERSION}.tar.gz && \ | ||
rm x264-${X264_VERSION}.tar.gz && \ | ||
cd x264-${X264_VERSION}* && \ | ||
./configure \ | ||
--SRC="${SRC}" \ | ||
--bindir="${SRC}/bin" \ | ||
--enable-shared && \ | ||
make -j$(nproc) && \ | ||
make install | ||
|
||
# install x265 | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://github.com/videolan/x265/archive/refs/tags/${X265_VERSION}.tar.gz && \ | ||
tar xfvz ${X265_VERSION}.tar.gz && \ | ||
rm ${X265_VERSION}.tar.gz && \ | ||
cd x265-${X265_VERSION}/build/linux \ | ||
sed -i "/-DEXTRA_LIB/ s/$/ -DCMAKE_INSTALL_SRC=\${SRC}/" multilib.sh && \ | ||
sed -i "/^cmake/ s/$/ -DENABLE_CLI=OFF/" multilib.sh && \ | ||
./multilib.sh && \ | ||
make -C 8bit install && \ | ||
rm -rf ${DIR} | ||
|
||
# install opus | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://archive.mozilla.org/pub/opus/opus-${OPUS_VERSION}.tar.gz && \ | ||
tar xfvz opus-${OPUS_VERSION}.tar.gz && \ | ||
rm opus-${OPUS_VERSION}.tar.gz && \ | ||
cd opus-${OPUS_VERSION} && \ | ||
autoreconf -fiv && \ | ||
./configure --prefix="${SRC}" \ | ||
--enable-shared && \ | ||
make && \ | ||
make install | ||
|
||
# install ogg | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk http://downloads.xiph.org/releases/ogg/libogg-${OGG_VERSION}.tar.gz && \ | ||
tar xfvz libogg-${OGG_VERSION}.tar.gz && \ | ||
rm libogg-${OGG_VERSION}.tar.gz && \ | ||
cd libogg-${OGG_VERSION} && \ | ||
./configure --prefix="${SRC}" \ | ||
--enable-shared && \ | ||
make && \ | ||
make install | ||
|
||
# install vorbis | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk http://downloads.xiph.org/releases/vorbis/libvorbis-${VORBIS_VERSION}.tar.gz && \ | ||
tar xfvz libvorbis-${VORBIS_VERSION}.tar.gz && \ | ||
rm libvorbis-${VORBIS_VERSION}.tar.gz && \ | ||
cd libvorbis-${VORBIS_VERSION} && \ | ||
./configure --prefix="${SRC}" --with-ogg="${SRC}" \ | ||
--enable-shared && \ | ||
make && \ | ||
make install | ||
|
||
# install libmp3lame | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://downloads.sourceforge.net/project/lame/lame/${LAME_VERSION}/lame-${LAME_VERSION}.tar.gz && \ | ||
tar -xvz -f lame-${LAME_VERSION}.tar.gz && \ | ||
rm lame-${LAME_VERSION}.tar.gz && \ | ||
cd lame-${LAME_VERSION} && \ | ||
./configure \ | ||
--prefix="${SRC}" \ | ||
--bindir="${SRC}/bin" \ | ||
--disable-static \ | ||
--enable-nasm && \ | ||
make -j$(nproc) && \ | ||
make install | ||
|
||
# install vpx | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://github.com/webmproject/libvpx/archive/refs/tags/v${VPX_VERSION}.tar.gz && \ | ||
tar xfvz v${VPX_VERSION}.tar.gz && \ | ||
rm v${VPX_VERSION}.tar.gz && \ | ||
cd libvpx-${VPX_VERSION} && \ | ||
./configure --prefix="${SRC}" \ | ||
--enable-vp8 \ | ||
--enable-vp9 \ | ||
--enable-vp9-highbitdepth \ | ||
--enable-pic \ | ||
--enable-shared \ | ||
--disable-debug \ | ||
--disable-examples \ | ||
--disable-docs \ | ||
--disable-install-bins && \ | ||
make && \ | ||
make install | ||
|
||
# install freetype | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://download.savannah.gnu.org/releases/freetype/freetype-${FREETYPE_VERSION}.tar.gz && \ | ||
tar xfvz freetype-${FREETYPE_VERSION}.tar.gz && \ | ||
rm freetype-${FREETYPE_VERSION}.tar.gz && \ | ||
cd freetype-${FREETYPE_VERSION} && \ | ||
./configure --prefix="${SRC}" \ | ||
--disable-static \ | ||
--enable-shared && \ | ||
make && \ | ||
make install | ||
|
||
# install srt | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://github.com/Haivision/srt/archive/refs/tags/v${SRT_VERSION}.tar.gz && \ | ||
tar xfvz v${SRT_VERSION}.tar.gz && \ | ||
rm v${SRT_VERSION}.tar.gz && \ | ||
cd srt-${SRT_VERSION} && \ | ||
cmake \ | ||
-G "Unix Makefiles" \ | ||
-DCMAKE_INSTALL_BINDIR="$SRC/bin" \ | ||
-DCMAKE_INSTALL_INCLUDEDIR="$SRC/include" \ | ||
-DCMAKE_INSTALL_LIBDIR="$SRC/lib" \ | ||
-DCMAKE_INSTALL_SRC="$SRC" && \ | ||
make && \ | ||
make install | ||
|
||
# install libxml2 | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk https://github.com/GNOME/libxml2/archive/refs/tags/v${XML2_VERSION}.tar.gz && \ | ||
tar xfvz v${XML2_VERSION}.tar.gz && \ | ||
rm v${XML2_VERSION}.tar.gz && \ | ||
cd libxml2-${XML2_VERSION} && \ | ||
./autogen.sh --prefix="${SRC}" \ | ||
--with-ftp=no \ | ||
--with-http=no \ | ||
--with-python=no && \ | ||
make && \ | ||
make install | ||
|
||
# install and patch ffmpeg | ||
RUN mkdir -p /dist && cd /dist && \ | ||
curl -OLk http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \ | ||
curl -OLk https://github.com/FFmpeg/nv-codec-headers/releases/download/n${FFNVCODEC_VERSION}/nv-codec-headers-${FFNVCODEC_VERSION}.tar.gz && \ | ||
tar -xvz -f ffmpeg-${FFMPEG_VERSION}.tar.gz && \ | ||
tar -xvz -f nv-codec-headers-${FFNVCODEC_VERSION}.tar.gz && \ | ||
rm ffmpeg-${FFMPEG_VERSION}.tar.gz nv-codec-headers-${FFNVCODEC_VERSION}.tar.gz && \ | ||
cd nv-codec-headers-${FFNVCODEC_VERSION} && \ | ||
make install | ||
|
||
COPY ./contrib /contrib | ||
|
||
RUN cd /dist/ffmpeg-${FFMPEG_VERSION} && \ | ||
patch -p1 < /contrib/ffmpeg-jsonstats.patch && \ | ||
./configure \ | ||
--extra-version=datahrei \ | ||
--prefix="${SRC}" \ | ||
--extra-cflags=-I/usr/local/cuda/include \ | ||
--extra-ldflags=-L/usr/local/cuda/lib64 \ | ||
--enable-nonfree \ | ||
--enable-gpl \ | ||
--enable-version3 \ | ||
--enable-postproc \ | ||
--enable-static \ | ||
--enable-openssl \ | ||
--enable-libxml2 \ | ||
--enable-cuda \ | ||
--enable-cuvid \ | ||
--enable-nvenc \ | ||
--enable-libnpp \ | ||
--enable-libv4l2 \ | ||
--enable-libfreetype \ | ||
--enable-libsrt \ | ||
--enable-libx264 \ | ||
--enable-libx265 \ | ||
--enable-libvpx \ | ||
--enable-libmp3lame \ | ||
--enable-libopus \ | ||
--enable-libvorbis \ | ||
--disable-ffplay \ | ||
--disable-ffprobe \ | ||
--disable-debug \ | ||
--disable-doc && \ | ||
make -j$(nproc) && \ | ||
make install && \ | ||
hash -r | ||
|
||
FROM $DEPLOY_IMAGE | ||
|
||
COPY --from=builder /usr/local/bin/ffmpeg /usr/local/bin/ffmpeg | ||
COPY --from=builder /usr/local/lib /usr/local/lib | ||
|
||
RUN echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf && \ | ||
ldconfig && \ | ||
apt-get update && \ | ||
apt-get install -y \ | ||
v4l-utils \ | ||
fbset && \ | ||
ffmpeg -buildconf | ||
|
||
ENV NVIDIA_VISIBLE_DEVICES all | ||
ENV NVIDIA_DRIVER_CAPABILITIES compute,video,utility | ||
|
||
WORKDIR /tmp | ||
ENTRYPOINT ["/usr/local/bin/ffmpeg"] | ||
CMD ["-version"] |