Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NVidia driver + ffmpeg + nginx streaming install #219

Open
cooliobr opened this issue Oct 24, 2022 · 3 comments
Open

NVidia driver + ffmpeg + nginx streaming install #219

cooliobr opened this issue Oct 24, 2022 · 3 comments

Comments

@cooliobr
Copy link

cooliobr commented Oct 24, 2022

Hi, i will put here my small guide to install nvidia driver + ffmepg and nginx to streaming.

First we need to install some libs:

This guide is for Ubuntu 18.04

apt install pkg-config build-essential linux-headers-$(uname -r) libc6-i386 libdb1-compat nginx git pkgconf build-essential yasm vim nginx git pkgconf curl build-essential libperl-dev libxml2-dev libxslt1-dev libpcre3-dev libssl-dev libgeoip-dev libgd3 libgd-dev  bc libtesseract-dev libzvbi-dev cmake libncurses5-dev libncursesw5-dev -y

Disable nouveau :

bash -c "echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
bash -c "echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf"
echo 0 > /sys/class/vtconsole/vtcon1/bind
service lightdm stop
rmmod nouveau

After this you need to reboot your server.

Download and install cuda:

wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
chmod 755 cuda_11.8.0_520.61.05_linux.run
./cuda_11.8.0_520.61.05_linux.run --override --driver --toolkit --silent

Apply LIB PATH:

echo "/usr/local/cuda-11.0/lib64" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf 
echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf
ldconfig

May will nned to patch driver to put more than 2 channels, tou can find this patch in google, patch+nvidia+linux+git

Nginx config ( you need change to your path)

curl http://epgbr.com.br/install/streamer/nginx.conf --output /etc/nginx/nginx.conf
curl http://epgbr.com.br/install/streamer/cors.conf --output /etc/nginx/cors.conf
service nginx restart

For ffmpeg i will put full script.
put all text in a file.sh, give +x mode and execute

#!/bina/bash
LOCAL=$(pwd)

sudo apt-get update -qq && sudo apt-get -y install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libgnutls28-dev \
  libsdl2-dev \
  libssl-dev \
  libtool \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  pkg-config \
  texinfo \
  wget \
  yasm \
  zlib1g-dev

mkdir -p $LOCAL/ffmpeg_sources ~/bin

cd $LOCAL/ffmpeg_sources && \
wget https://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2 && \
tar xjvf nasm-2.14.02.tar.bz2 && \
cd nasm-2.14.02 && \
./autogen.sh && \
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" && \
make -j8 && \
make install

cd $LOCAL/ffmpeg_sources && \
git -C x264 pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/x264.git && \
cd x264 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --enable-static --enable-pic && \
PATH="$HOME/bin:$PATH" make -j8 && \
make install

sudo apt-get install libnuma-dev && \
cd $LOCAL/ffmpeg_sources && \
git -C x265_git pull 2> /dev/null || git clone https://bitbucket.org/multicoreware/x265_git && \
cd x265_git/build/linux && \
PATH="$HOME/bin:$PATH" cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED=off ../../source && \
PATH="$HOME/bin:$PATH" make -j8  && \
make install

cd $LOCAL/ffmpeg_sources && \
git -C fdk-aac pull 2> /dev/null || git clone --depth 1 https://github.com/mstorsjo/fdk-aac && \
cd fdk-aac && \
autoreconf -fiv && \
./configure --prefix="$HOME/ffmpeg_build" --disable-shared && \
make  -j8 && \
make install

cd $LOCAL/ffmpeg_sources && \
wget -O lame-3.100.tar.gz https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz && \
tar xzvf lame-3.100.tar.gz && \
cd lame-3.100 && \
PATH="$HOME/bin:$PATH" ./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm && \
PATH="$HOME/bin:$PATH" make  -j8 && \
make install

cd $LOCAL/ffmpeg_sources && \
git -C nv-codec-headers pull 2> /dev/null || git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers && \
cd $LOCAL/ffmpeg_sources/nv-codec-headers && \
make  -j8 && \
make install PREFIX="$HOME/ffmpeg_build"

CUDA_HOME="/usr/local/cuda"
LD_LIBRARY_PATH="$CUDA_HOME/lib64:$LD_LIBRARY_PATH"
PATH="$CUDA_HOME/bin:$PATH"

cd $LOCAL/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar -xvjf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --enable-cuda-nvcc \
  --nvccflags="-gencode arch=compute_50,code=sm_50 -O2" \
  --enable-cuvid \
  --enable-nvenc \
  --enable-nvdec \
  --enable-libnpp \
  --extra-cflags="-I/usr/local/cuda/include" \
  --extra-ldflags="-L/usr/local/cuda/lib64" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-openssl \
  --enable-gpl \
  --enable-libfdk-aac \
  --enable-libmp3lame \
  --enable-libx264 \
  --enable-libx265 \
  --enable-static \
  --enable-nonfree && \
PATH="$HOME/bin:$PATH" make  -j8 && \
make install && \
hash -r

cp ffmpeg ffplay ffprobe /usr/bin/

jb-alvarado added a commit to jb-alvarado/ffplayout that referenced this issue Nov 27, 2022
@RoxyBoxxy
Copy link

How do i add this to ffplayout it uses cpu not gpu and i cant add x264_nvenc to the config

@catalinx3006
Copy link

hi, command not found

curl http://epgbr.com.br/install/streamer/nginx.conf --output /etc/nginx/nginx.conf
curl http://epgbr.com.br/install/streamer/cors.conf --output /etc/nginx/cors.conf
service nginx restart

@cooliobr
Copy link
Author

hi, command not found

curl http://epgbr.com.br/install/streamer/nginx.conf --output /etc/nginx/nginx.conf curl http://epgbr.com.br/install/streamer/cors.conf --output /etc/nginx/cors.conf service nginx restart

this is only nginx conf, you can find it in internet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants