Skip to content

Commit f6daf0d

Browse files
committed
add vaapi
1 parent e6e3a92 commit f6daf0d

File tree

5 files changed

+153
-46
lines changed

5 files changed

+153
-46
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM ubuntu:20.04 AS build
22

33
RUN apt-get update \
4-
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates \
4+
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates python3 \
55
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
66
&& update-ca-certificates
77

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ Requirements MacOS
5858
Requirements Linux
5959
------------
6060
* Debian >= Buster, Ubuntu => Focal Fossa, other Distributions might work too
61-
* build-essentials installed:
61+
* build-essentials, curl, and Python3 is requre installed:
6262

6363
```
6464
# Debian and Ubuntu
65-
$ sudo apt-get install build-essential curl g++
65+
$ sudo apt-get install build-essential curl python3
6666
6767
# Fedora
68-
$ sudo dnf install @development-tools
68+
$ sudo dnf install @development-tools curl python3
6969
```
7070

7171
Installation

build-ffmpeg

Lines changed: 147 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
# https://github.com/markus-perl/ffmpeg-build-script
44

5-
PROGNAME=$(basename $0)
5+
PROGNAME=$(basename "$0")
66
VERSION=1.18
77
CWD=$(pwd)
88
PACKAGES="$CWD/packages"
99
WORKSPACE="$CWD/workspace"
1010
CFLAGS="-I$WORKSPACE/include"
1111
LDFLAGS="-L$WORKSPACE/lib"
1212
LDEXEFLAGS=""
13-
EXTRALIBS="-lpthread -lm -lz"
13+
EXTRALIBS="-ldl -lpthread -lm -lz"
1414
CONFIGURE_OPTIONS=()
1515

1616
# Speed up the process
1717
# Env Var NUMJOBS overrides automatic detection
18-
if [[ -n $NUMJOBS ]]; then
19-
MJOBS=$NUMJOBS
18+
if [[ -n "$NUMJOBS" ]]; then
19+
MJOBS="$NUMJOBS"
2020
elif [[ -f /proc/cpuinfo ]]; then
2121
MJOBS=$(grep -c processor /proc/cpuinfo)
2222
elif [[ "$OSTYPE" == "darwin"* ]]; then
@@ -44,17 +44,17 @@ download () {
4444
# download url [filename[dirname]]
4545

4646
DOWNLOAD_PATH="$PACKAGES"
47-
DOWNLOAD_FILE=${2:-"${1##*/}"}
47+
DOWNLOAD_FILE="${2:-"${1##*/}"}"
4848

4949
if [[ "$DOWNLOAD_FILE" =~ "tar." ]]; then
5050
TARGETDIR="${DOWNLOAD_FILE%.*}"
51-
TARGETDIR=${3:-"${TARGETDIR%.*}"}
51+
TARGETDIR="${3:-"${TARGETDIR%.*}"}"
5252
else
53-
TARGETDIR=${3:-"${DOWNLOAD_FILE%.*}"}
53+
TARGETDIR="${3:-"${DOWNLOAD_FILE%.*}"}"
5454
fi
5555

5656
if [ ! -f "$DOWNLOAD_PATH/$DOWNLOAD_FILE" ]; then
57-
echo "Downloading $1"
57+
echo "Downloading $1 as $DOWNLOAD_FILE"
5858
curl -L --silent -o "$DOWNLOAD_PATH/$DOWNLOAD_FILE" "$1"
5959

6060
EXITCODE=$?
@@ -162,7 +162,7 @@ while (( $# > 0 )); do
162162
exit 0
163163
;;
164164
--version)
165-
echo $VERSION
165+
echo "$VERSION"
166166
exit 0
167167
;;
168168
-*)
@@ -185,8 +185,8 @@ while (( $# > 0 )); do
185185
esac
186186
done
187187

188-
if [ -z $bflag ]; then
189-
if [ -z $cflag ]; then
188+
if [ -z "$bflag" ]; then
189+
if [ -z "$cflag" ]; then
190190
usage
191191
exit 1
192192
fi
@@ -199,7 +199,7 @@ echo ""
199199

200200
echo "Using $MJOBS make jobs simultaneously."
201201

202-
if [ -n $LDEXEFLAGS ]; then
202+
if [ -n "$LDEXEFLAGS" ]; then
203203
echo "Start the build in full static mode."
204204
fi
205205

@@ -223,6 +223,13 @@ if ! command_exists "curl"; then
223223
exit 1
224224
fi
225225

226+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
227+
if ! command_exists "python3" ; then
228+
echo "python3 not installed.";
229+
exit 1
230+
fi
231+
fi
232+
226233
##
227234
## build tools
228235
##
@@ -277,6 +284,67 @@ if build "cmake"; then
277284
build_done "cmake"
278285
fi
279286

287+
# Required for building vaapi tools so linux only
288+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
289+
if build "m4"; then
290+
download "https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.xz"
291+
# https://lists.gnu.org/archive/html/bug-m4/2018-08/msg00000.html
292+
# No new version of M4 has been released, so a patch has been applied.
293+
execute curl -sLJO https://github.com/easybuilders/easybuild-easyconfigs/raw/master/easybuild/easyconfigs/m/M4/M4-1.4.18_glibc_2.28.patch
294+
execute patch -p1 -d . < M4-1.4.18_glibc_2.28.patch
295+
execute ./configure --prefix="${WORKSPACE}"
296+
execute make -j $MJOBS
297+
execute make install
298+
build_done "m4"
299+
fi
300+
301+
if build "autoconf"; then
302+
download "https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.xz"
303+
execute ./configure --prefix="${WORKSPACE}"
304+
execute make -j $MJOBS
305+
execute make install
306+
build_done "autoconf"
307+
fi
308+
309+
if build "automake"; then
310+
download "https://ftp.gnu.org/gnu/automake/automake-1.16.tar.xz"
311+
execute ./configure --prefix="${WORKSPACE}"
312+
execute make -j $MJOBS
313+
execute make install
314+
build_done "automake"
315+
fi
316+
317+
if build "util-macros"; then
318+
download "https://www.x.org/archive/individual/util/util-macros-1.19.2.tar.gz"
319+
execute ./configure --prefix="${WORKSPACE}"
320+
execute make -j $MJOBS
321+
execute make install
322+
build_done "util-macros"
323+
fi
324+
325+
if build "libtool"; then
326+
download "https://ftp.jaist.ac.jp/pub/GNU/libtool/libtool-2.4.6.tar.xz"
327+
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
328+
execute make -j $MJOBS
329+
execute make install
330+
build_done "libtool"
331+
fi
332+
333+
if build "meson"; then
334+
download "https://github.com/mesonbuild/meson/releases/download/0.55.3/meson-0.55.3.tar.gz"
335+
execute ln -s $(pwd)/meson.py ${WORKSPACE}/bin/meson
336+
build_done "meson"
337+
fi
338+
339+
if build "ninja"; then
340+
download "https://github.com/ninja-build/ninja/archive/v1.10.1.tar.gz" "ninja-1.10.1.tar.gz"
341+
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" .
342+
execute make -j $MJOBS
343+
execute make install
344+
build_done "ninja"
345+
fi
346+
fi
347+
280348

281349
##
282350
## video library
@@ -301,13 +369,17 @@ CONFIGURE_OPTIONS+=("--enable-libx264")
301369

302370
if build "x265"; then
303371
download "https://github.com/videolan/x265/archive/Release_3.5.tar.gz" "x265-3.5.tar.gz"
304-
cd source || exit
305-
execute cmake -DCMAKE_INSTALL_PREFIX:PATH="${WORKSPACE}" -DENABLE_SHARED:bool=off -DSTATIC_LINK_CRT:BOOL=ON .
306-
execute make -j $MJOBS
307-
execute make install
372+
cd build/linux || exit
308373

309-
if [ -n $LDEXEFLAGS ]; then
374+
if [ -n "$LDEXEFLAGS" ]; then
375+
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF -DSTATIC_LINK_CRT=ON ../../source
376+
execute make -j $MJOBS
377+
execute make install
310378
sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}/lib/pkgconfig/x265.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
379+
else
380+
execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../../source
381+
execute make -j $MJOBS
382+
execute make install
311383
fi
312384

313385
build_done "x265"
@@ -462,8 +534,8 @@ if build "srt"; then
462534
execute cmake . -DCMAKE_INSTALL_PREFIX:PATH="${WORKSPACE}" -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DENABLE_APPS=OFF -DUSE_STATIC_LIBSTDCXX=ON
463535
execute make install
464536

465-
if [ -n $LDEXEFLAGS ]; then
466-
sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "$WORKSPACE/lib/pkgconfig/srt.pc" # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
537+
if [ -n "$LDEXEFLAGS" ]; then
538+
sed -i.backup 's/-lgcc_s/-lgcc_eh/g' "${WORKSPACE}"/lib/pkgconfig/srt.pc # The -i.backup is intended and required on MacOS: https://stackoverflow.com/questions/5694228/sed-in-place-flag-that-works-both-on-mac-bsd-and-linux
467539
fi
468540

469541
build_done "srt"
@@ -475,35 +547,70 @@ CONFIGURE_OPTIONS+=("--enable-libsrt")
475547
## HWaccel library
476548
##
477549

478-
if command -v nvcc > /dev/null ; then
479-
if build "nv-codec"; then
480-
download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.0/nv-codec-headers-11.0.10.0.tar.gz"
481-
execute make PREFIX="${WORKSPACE}"
482-
execute make install PREFIX="${WORKSPACE}"
483-
build_done "nv-codec"
484-
fi
485-
CFLAGS+=" -I/usr/local/cuda/include"
486-
LDFLAGS+=" -L/usr/local/cuda/lib64"
487-
CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvenc" "--enable-cuda-llvm")
550+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
551+
if command_exists nvcc ; then
552+
if build "nv-codec"; then
553+
download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.0.10.0/nv-codec-headers-11.0.10.0.tar.gz"
554+
execute make PREFIX="${WORKSPACE}"
555+
execute make install PREFIX="${WORKSPACE}"
556+
build_done "nv-codec"
557+
fi
558+
CFLAGS+=" -I/usr/local/cuda/include"
559+
LDFLAGS+=" -L/usr/local/cuda/lib64"
560+
CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvenc" "--enable-cuda-llvm")
488561

489-
if [ -z $LDEXEFLAGS ]; then
490-
CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked.
491-
fi
562+
if [ -z "$LDEXEFLAGS" ]; then
563+
CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked.
564+
fi
492565

493-
# https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
494-
CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52")
495-
fi
566+
# https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
567+
CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52")
568+
fi
496569

497-
if [[ "$OSTYPE" == "linux-gnu" ]]; then
498570
if build "amf"; then
499571
download "https://github.com/GPUOpen-LibrariesAndSDKs/AMF/archive/1.4.16.1.tar.gz" "amf-1.4.16.1.tar.gz"
500-
execute mkdir -p ${WORKSPACE}/include/AMF
501-
execute cp -r amf/public/include/* ${WORKSPACE}/include/AMF/
572+
execute mkdir -p "${WORKSPACE}"/include/AMF
573+
execute cp -r amf/public/include/* "${WORKSPACE}"/include/AMF/
502574
build_done "amf"
503575
fi
504576
CONFIGURE_OPTIONS+=("--enable-amf")
577+
578+
if build "libpciaccess"; then
579+
download "https://gitlab.freedesktop.org/xorg/lib/libpciaccess/-/archive/libpciaccess-0.16/libpciaccess-libpciaccess-0.16.tar.bz2" "libpciaccess-0.16.tar.bz2"
580+
execute autoreconf --force --verbose --install
581+
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static CFLAGS=-fPIC
582+
execute make -j $MJOBS
583+
execute make install
584+
build_done "libpciaccess"
585+
fi
586+
587+
if build "libdrm"; then
588+
download "https://dri.freedesktop.org/libdrm/libdrm-2.4.102.tar.xz"
589+
execute meson --prefix="${WORKSPACE}" --libdir="${WORKSPACE}"/lib builddir/
590+
execute ninja -C builddir/ install
591+
build_done "libdrm"
592+
fi
593+
594+
if build "libva"; then
595+
download "https://github.com/intel/libva/releases/download/2.9.0/libva-2.9.0.tar.bz2"
596+
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
597+
execute make -j $MJOBS
598+
execute make install
599+
build_done "libva"
600+
fi
601+
602+
if build "intel-vaapi-driver"; then
603+
download "https://github.com/intel/intel-vaapi-driver/releases/download/2.4.1/intel-vaapi-driver-2.4.1.tar.bz2"
604+
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
605+
execute make -j $MJOBS
606+
execute make install
607+
build_done "intel-vaapi-driver"
608+
fi
609+
610+
CONFIGURE_OPTIONS+=("--enable-vaapi")
505611
fi
506612

613+
507614
##
508615
## FFmpeg
509616
##
@@ -542,7 +649,7 @@ echo ""
542649
echo "Building done. The binary can be found here: $WORKSPACE/bin/ffmpeg"
543650
echo ""
544651

545-
if [[ $AUTOINSTALL == "yes" ]]; then
652+
if [[ "$AUTOINSTALL" == "yes" ]]; then
546653
if command_exists "sudo"; then
547654
sudo cp "$WORKSPACE/bin/ffmpeg" "$INSTALL_FOLDER/ffmpeg"
548655
sudo cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
@@ -552,7 +659,7 @@ if [[ $AUTOINSTALL == "yes" ]]; then
552659
cp "$WORKSPACE/bin/ffprobe" "$INSTALL_FOLDER/ffprobe"
553660
echo "Done. ffmpeg is now installed to your system."
554661
fi
555-
elif [[ ! $SKIPINSTALL == "yes" ]]; then
662+
elif [[ ! "$SKIPINSTALL" == "yes" ]]; then
556663
read -r -p "Install the binary to your $INSTALL_FOLDER folder? [Y/n] " response
557664
case $response in
558665
[yY][eE][sS]|[yY])

cuda-ubuntu.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM nvidia/cuda:11.1-devel-ubuntu20.04 AS build
33
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
44

55
RUN apt-get update \
6-
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates \
6+
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates python3 \
77
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
88
&& update-ca-certificates
99

full-static.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM nvidia/cuda:11.1-devel-ubuntu20.04 AS build
33
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility,video
44

55
RUN apt-get update \
6-
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates \
6+
&& apt-get -y --no-install-recommends install build-essential curl ca-certificates python3 \
77
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* \
88
&& update-ca-certificates
99

0 commit comments

Comments
 (0)