https://trac.ffmpeg.org/wiki/CompilationGuide/Centos#CompilationInstallation
nvidia 硬件条件下 ffmpeg安装流程
一.安装yasm
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.13.01/nasm-2.13.01.tar.xz
tar xf nasm-2.13.01.tar.xz
cd nasm-2.13.01
./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 https://bitbucket.org/multicoreware/x265
cd x265/build/linux
sudo cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX=”/usr” -DENABLE_SHARED:bool=off ../../source
make
sudo make install
十. 安装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
./configure –prefix=”/usr” –enable-static –disable-gpl –disable-opencl
make
sudo make install
十一. 安装libvpx
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
十二. 安装cuda toolkit
sudo sh cuda_8.0.61_375.26_linux.run
curl -L -O https://developer.nvidia.com/compute/cuda/8.0/Prod2/local_installers/cuda_8.0.61_375.26_linux-run
sudo sh cuda_8.0.61_375.26_linux-run
curl -L -O https://developer.nvidia.com/compute/cuda/8.0/Prod2/patches/2/cuda_8.0.61.2_linux-run
sudo sh cuda_8.0.61.2_linux-run
===========
Driver: Installed
Toolkit: Installed in /usr/local/cuda-8.0
Samples: Installed in /root/cuda_samples
Please make sure that
- PATH includes /usr/local/cuda-8.0/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-8.0/lib64, or, add /usr/local/cuda-8.0/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.0/doc/pdf for detailed information on setting up CUDA.
十三. 配置cuda信息
vi ~/.bashrc
export CUDA_HOME=/usr/local/cuda-8.0
export LD_LIBRARY_PATH= CUDAHOME/lib64exportPATH= PATH:/usr/local/cuda-8.0/bin
十四. 安装配置nvidia-video-codec-sdk
unzip Video_Codec_SDK_8.0.14.zip
sudo cp -r Video_Codec_SDK_8.0.14/Samples/common/inc/* /usr/include/
mv Video_Codec_SDK_8.0.14 nv_sdk
十五. 安装nvida驱动
NVIDIA-Linux-x86_64-375.66.run
chmod +x NVIDIA-Linux-x86_64-375.66.run
sudo /bin/bash ./NVIDIA-Linux-x86_64-375.66.run
安装完成后, 运行 nvidia-smi 如果有类似如下的GPU信息显示出来,说明驱动安装成功
Tue Jun 27 12:44:02 2017
+—————————————————————————–+
| NVIDIA-SMI 375.66 Driver Version: 375.66 |
|——————————-+———————-+———————-+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 Tesla M40 Off | 0000:00:07.0 Off | Off |
| N/A 26C P0 61W / 250W | 0MiB / 12209MiB | 0% Default |
+——————————-+———————-+———————-+
+—————————————————————————–+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| No running processes found |
+—————————————————————————–+
十六. 支持opengl glsl滤镜的过程
1)安装x window系统,因为要支持opengl需要窗口系统
yum groupinstall “X Window System” “Desktop” “Desktop Platform”
yum install gdm
yum groupinstall “Development Tools”
yum install kernel-devel kernel-headers
2) 重建启动镜像
使用 dracut重新建立 initramfs image file :
* 备份 the initramfs file
sudomv/boot/initramfs− (uname -r).img /boot/initramfs- (uname−r).img.bak∗重新建立theinitramfsfile sudo dracut -v /boot/initramfs- (uname−r).img (uname -r)
3) 修改 /etc/X11/xorg.conf
$ nvidia-xconfig –query-gpu-info
vi /etc/X11/xorg.conf
Section “DRI”
Mode 0666
EndSection
Section “Device”
Identifier “Device0”
Driver “nvidia”
VendorName “NVIDIA Corporation”
BoardName “Tesla M40”
BusID “PCI:0:7:0”
EndSection
4) 导出 display
vi ~/.bashrc
export DISPLAY=:0.0
5) 可安装nvidia opengl例子最新版 (可以不安装)
5.1)升级gcc 4.8
第一部分:升级到4.7
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
这个将安装的文件放在了
/opt/centos/devtoolset-1.1
如果想要编辑器去处理的话,这样操作
export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++
如果你想要gcc替换本地的,当然不是真的去替换,只要把他放在我们的/usrlocal/bin下面就好了,不必去管系统自带的【/usr/bin】。
ln -s /opt/centos/devtoolset-1.1/root/usr/bin/* /usr/local/bin/
hash -r
gcc --version
第二部分:升级到4.8【这个应该是目前最新的啦,不过网上查的话已经到5.2啦,感觉落后一点比较稳,当然还有就是这个版本是新的里面使用最多的】
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
或
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-2/devtools-2.repo
然后
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
这个将安装的文件放在了
/opt/rh/devtoolset-2
如果想要编辑器去处理的话,这样操作
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc
export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp
export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
如果你想要gcc替换本地的,当然不是真的去替换,只要把他放在我们的/usrlocal/bin下面就好了,不必去管系统自带的【/usr/bin】。
ln -s /opt/rh/devtoolset-2/root/usr/bin/* /usr/local/bin/
hash -r
gcc --version
5.2) 下载安装编译例子
git clone https://github.com/NVIDIAGameWorks/GraphicsSamples.git
cd GraphicsSamples
cd samples/build/linux64
make debug
##如果异常,需要把每一个.mk文件 增加rt库依赖
例如:
vi Makefile.Basic.mk
Basic_debug_libraries += dl
Basic_debug_libraries += rt
5.3)可复制相关库文件 (判断相关版本信息决定是否覆盖)
cp /root/GraphicsSamples/extensions/externals/lib/linux64/libGLEW.a /usr/lib64/libGLEW.a
cp /root/GraphicsSamples/extensions/externals/lib/linux64/libglfw3.a /usr/local/lib/libglfw3.a
6) 重启进入xwindows模式
$ vi /etc/inittab
Change:
id:3:initdefault:
To:
id:5:initdefault:
十七. 修改ffmpeg,增加自己开发的opengl滤镜
1) 下载ffmpeg ,应安装3.2系列或者3.3.1
2)下载opengl滤镜模板
git clone https://github.com/nervous-systems/ffmpeg-opengl.git
3) ffmpeg 源码结构,添加opengl滤镜
ln -s ~/ffmpeg-opengl/vf_genericshader.c libavfilter/
git apply ~/ffmpeg-opengl/FFmpeg.diff
十八. 配置ffmpeg, 编译安装
1) 配置
PKG_CONFIG_PATH=”/usr/lib/pkgconfig” ./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
2) 编译
make -j 10
3) 安装
make install
其他资料:
PKG_CONFIG_PATH=”/usr/lib/pkgconfig” ./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
PKG_CONFIG_PATH=”/usr/lib/pkgconfig” ./configure –prefix=”/usr” –enable-cuda –enable-cuvid –enable-nvenc –enable-nonfree –enable-libnpp –enable-libfdk_aac –enable-libfreetype –enable-libmp3lame –enable-libopus –enable-libtheora –enable-libvorbis –enable-libvpx –enable-pthreads –extra-cflags=-I/usr/local/cuda/include –extra-ldflags=-L/usr/local/cuda/lib64
PKG_CONFIG_PATH=”/usr/lib/pkgconfig” ./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-filter=genericshader –enable-opengl –extra-libs=”-lGLEW -lglfw3 -lGL -lX11 -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lm -pthread”
PKG_CONFIG_PATH=”/usr/lib/pkgconfig” ./configure –enable-libx264 –enable-filter=genericshader –enable-gpl –enable-opengl –extra-libs=”-lGLEW -lglfw3 -lGL -lX11 -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -lm -pthread”
ffmpeg -encoders |grep he
ffmpeg -decoders |grep cuvid
ffmpeg -decoders |grep he
lshw
2.1安装:
yum install lshw
2.2显示显卡信息
lshw -C display
2.3查看当前使用的显卡驱动
sudo lshw -c video | grep configuration
configuration: latency=0
configuration: driver=nvidia latency=0
modinfo nvidia
cuda下载链接:
https://developer.nvidia.com/cuda-downloads
https://www.qcloud.com/document/product/213/6816?lang=en
驱动下载:
http://www.nvidia.com/Download/Find.aspx
https://trac.ffmpeg.org/wiki/HWAccelIntro
自定义滤镜:
ffmpeg -i input.mp4 -vf genericshader -y output.mp4
ffmpeg -i toystory.mp4 -vf genericshader -vcodec h264_nvenc -y out4.mp4
vmstat -w -n 1
nvidia-smi dmon -i 0