安装相关环境

硬件环境:

yum安装驱动

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum install yum-plugin-fastestmirror sudo vim /lib/modprobe.d/dist-blacklist.conf

dist-blacklist.conf

#blacklist nvidiafb blacklist nouveau options nouveau modeset=0

mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak dracut /boot/initramfs-$(uname -r).img $(uname -r) lspci | grep nouveau

没有输出,说明屏蔽默认带有的nouveau成功。

一些命令:

sudo yum install nvidia-detect nvidia显卡检测 nvidia-detect -v 检测结果 # yum -y install kmod-nvidia 安装显卡驱动 这一步应该不需要

run脚本安装

参考:https://github.com/keylase/nvidia-patch

cd /opt/nvidia wget https://international.download.nvidia.com/XFree86/Linux-x86_64/430.40/NVIDIA-Linux-x86_64-430.40.run chmod x NVIDIA-Linux-x86_64-430.40.run ./NVIDIA-Linux-x86_64-430.40.run --kernel-source-path=/usr/src/kernels/3.10.0-957.27.2.el7.x86_64 # 下面是移除NVENC同时运行最大数量的限制 restriction on maximum number of simultaneous NVENC git clone https://github.com/keylase/nvidia-patch cd nvidia-patch bash ./patch.sh

如果需要卸载,使用命令:

./NVIDIA-Linux-x86_64-430.40.run --uninstall

安装Cuda

sudo yum-config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo sudo yum clean all sudo yum -y install nvidia-driver-latest-dkms cuda nvidia-smi

mac ffmpeg环境搭建(流媒体开发学习4)(1)

编译支持

库说明

下载路径

mkdir ~/ffmpeg_sources

yasm

cd ~/ffmpeg_sources curl -L -O http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar xvzf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure --prefix=”/usr” make sudo make install

nasm

curl -L -O http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.xz tar xf nasm-2.14.02.tar.xz cd nasm-2.14.02 ./configure --prefix=”/usr” make sudo make install

libfdk-aac

git clone --depth 1 git://git.code.sf.net/p/opencore-amr/fdk-aac cd fdk-aac sudo autoreconf -fiv ./configure --prefix="/usr" --disable-shared make sudo make install

lame

curl -L -O http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar xzvf lame-3.99.5.tar.gz cd lame-3.99.5 ./configure --prefix="/usr" --disable-shared --enable-nasm make sudo make install

libopus

curl -L -O https://archive.mozilla.org/pub/opus/opus-1.2.tar.gz tar xvzf opus-1.2.tar.gz cd opus-1.2 ./configure --prefix="/usr" --disable-shared make sudo make install

libogg

curl -L -O http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz tar xzvf libogg-1.3.2.tar.gz cd libogg-1.3.2 ./configure --prefix="/usr" --disable-shared make sudo make install

libvorbis

curl -L -O http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.4.tar.gz tar xzvf libvorbis-1.3.4.tar.gz cd libvorbis-1.3.4 ./configure --prefix="/usr" --with-ogg="/usr" --disable-shared make sudo make install

libtheora

git clone git://git.xiph.org/mirrors/theora.git theora-git cd theora-git PKG_CONFIG_PATH=/usr/lib/pkgconfig ./autogen.sh --prefix=/usr --disable-examples --disable-shared --disable-sdltest --disable-vorbistest && make && make install

libx265

sudo yum install hg cmake hg clone http://hg.videolan.org/x265 cd x265/build/linux sudo cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX="/usr" -DENABLE_SHARED:bool=off ../../source make sudo make install vim /usr/lib/pkgconfig/x265.pc

加上:在Libs.private: -lstdc -lm -lrt -ldl后面加上-lpthread

x264

curl -L -O http://download.videolan.org/pub/x264/snapshots/last_x264.tar.bz2 tar xjvf last_x264.tar.bz2 cd x264-snapshot-20170625-2245/ ./configure --prefix="/usr" --enable-static make sudo make install

disable-gpl

./configure --prefix="/usr" --enable-static --disable-gpl --disable-opencl make sudo make install

安装ffnvcodec

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git cd nv-codec-headers make && sudo make install

libvpx

VP8/VP9 video encoder.

git clone --depth 1 https://github.com/webmproject/libvpx.git cd libvpx ./configure --prefix="/usr" --disable-examples --disable-unit-tests --as=yasm make sudo make install

https

wget http://mirrors.ibiblio.org/openssl/source/old/1.0.2/openssl-1.0.2k.tar.gz tar -xvf openssl-1.0.2k.tar.gz cd openssl-1.0.2k make clean ./config shared --prefix="/usr" make -j32 && make install

配置ffmpeg, 编译安装

下载

git clone https://git.ffmpeg.org/ffmpeg.git git clone https://github.com/libav/libav

配置

PKG_CONFIG_PATH="/usr/lib/pkgconfig" export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH cd ffmpeg ./configure --prefix="/usr" --pkg-config-flags="--static" --enable-gpl --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libxvid --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --extra-cflags="-I/usr/local/cuda/include/" --extra-ldflags=-L/usr/local/cuda/lib64 --disable-shared --enable-nvenc --enable-cuda --enable-cuvid --enable-libnpp --enable-pthreads --enable-openssl

我实际编译去掉了–enable-libfdk-aac enable-libxvid

编译

make -j 10

安装

make install

使用 测试转码推流

ffmpeg -hwaccel cuvid -c:v h264_cuvid -i "rtsp://aaa:bbb@ip:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif" -c:v h264_nvenc -an -preset slow -tune film -f flv rtmp://rtmpip:port/live/v_test```

,