-
Notifications
You must be signed in to change notification settings - Fork 71
/
install_ffmpeg.sh
executable file
·79 lines (65 loc) · 2.71 KB
/
install_ffmpeg.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -ex
export PATH="$HOME/compiled/bin":$PATH
export PKG_CONFIG_PATH=$HOME/compiled/lib/pkgconfig
# NVENC only works on Windows/Linux
if [ $(uname) != "Darwin" ]; then
if [ ! -e "$HOME/nv-codec-headers" ]; then
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git "$HOME/nv-codec-headers"
cd $HOME/nv-codec-headers
git checkout 250292dd20af60edc6e0d07f1d6e489a2f8e1c44
make -e PREFIX="$HOME/compiled"
make install -e PREFIX="$HOME/compiled"
fi
fi
if [ ! -e "$HOME/nasm/nasm" ]; then
# sudo apt-get -y install asciidoc xmlto # this fails :(
git clone -b nasm-2.14.02 https://repo.or.cz/nasm.git "$HOME/nasm"
cd "$HOME/nasm"
./autogen.sh
./configure --prefix="$HOME/compiled"
make
make install || echo "Installing docs fails but should be OK otherwise"
fi
if [ ! -e "$HOME/x264/x264" ]; then
git clone http://git.videolan.org/git/x264.git "$HOME/x264"
cd "$HOME/x264"
# git master as of this writing
git checkout 545de2ffec6ae9a80738de1b2c8cf820249a2530
./configure --prefix="$HOME/compiled" --enable-pic --enable-static
make
make install-lib-static
fi
EXTRA_FFMPEG_FLAGS=""
EXTRA_LDFLAGS=""
if [ $(uname) == "Darwin" ]; then
EXTRA_LDFLAGS="-framework CoreFoundation -framework Security"
else
# If we have clang, we can compile with CUDA support!
if which clang > /dev/null; then
echo "clang detected, building with GPU support"
EXTRA_FFMPEG_FLAGS="--enable-cuda --enable-cuda-llvm --enable-cuvid --enable-nvenc --enable-decoder=h264_cuvid --enable-filter=scale_cuda,signature_cuda --enable-encoder=h264_nvenc"
if [[ $BUILD_TAGS == *"experimental"* ]]; then
echo "experimental tag detected, building with Tensorflow support"
EXTRA_FFMPEG_FLAGS="$EXTRA_FFMPEG_FLAGS --enable-libtensorflow"
fi
fi
fi
if [ ! -e "$HOME/ffmpeg/libavcodec/libavcodec.a" ]; then
# download TensorFlow C library
LIBTENSORFLOW_VERSION=2.5.0 \
&& curl -LO https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \
&& sudo tar -C /usr/local -xzf libtensorflow-gpu-linux-x86_64-${LIBTENSORFLOW_VERSION}.tar.gz \
&& sudo ldconfig
EXTRA_FFMPEG_FLAGS="$EXTRA_FFMPEG_FLAGS --enable-libtensorflow"
# download livepeer-ml model
LP_ML_MODEL_VERSION=0.3
curl -LO https://github.com/livepeer/livepeer-ml/releases/download/v${LP_ML_MODEL_VERSION}/tasmodel.pb
mv tasmodel.pb ./ffmpeg
git clone https://github.com/livepeer/FFmpeg.git "$HOME/ffmpeg" || echo "FFmpeg dir already exists"
cd "$HOME/ffmpeg"
git checkout d8e4017c1b9d002b1a5d15b2b57951098a084400
./configure --prefix="$HOME/compiled" --enable-libx264 --enable-gpl --enable-static $EXTRA_FFMPEG_FLAGS
make
make install
fi