当前位置:   article > 正文

编译ffmpeg + x264 + cuda + opencv_x264 cuda

x264 cuda

1 下载x264并编译

  1. git clone https://git.videolan.org/git/x264.git
  2. ./configure --enable-shared --enable-static
  3. make -j8
  4. make install

 

2 安装Libav

3 安装nv-codec-headers

  1. git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
  2. make
  3. sudo make install

注意SDK版本对于gpu驱动版本

4 编译 ffmpeg

  1. ./configure --enable-gpl --enable-libx264 --enable-pic --enable-cuda --enable-cuvid --enable-nonfree --enable-libnpp --enable-shared --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --enable-cuda-sdk --enable-nvenc
  2. make -j8
  3. sudo make install

5 编译 opencv

勾选OPENCV_ENABLE_NONFREE

勾选WITH_TIFF

勾选WITH_GTK

勾选WITH_CUDA

勾选CUDA_USE_STATIC_CUDA_RUNTIME

编译sudo make -j8

 


Other

ffmpeg+x264一键安装脚本(Linux)

ffmpeg支持x264插件
1 ffmpeg安装x264插件

2 要安装x264模块首先要先装nasm

3 安装脚本如下【复制即可使用】

  1. #!/bin/bash
  2. yum -y install epel-release && yum -y install git wget #下载git,wget
  3. echo $?
  4. if [ $? == 0 ];then #判断工具安装情况
  5. wget http://www.nasm.us/pub/nasm/releasebuilds/2.13/nasm-2.13.tar.gz #下载安装包nasm
  6. git clone git://git.videolan.org/x264.git #下载x264模块
  7. wget http://219.238.7.67/files/208800000B606D7E/ffmpeg.org/releases/ffmpeg-3.4.2.tar.bz2 #下载ffmpeg
  8. else
  9. exit #如果工具下载失败,直接退出
  10. fi
  11. tar xvf nasm-2.13.tar.gz #安装nasm
  12. cd nasm-2.13/ && mkdir /product/{ffmpeg,x264,nasm2-13} -p
  13. ./configure --prefix=/product/nasm2-13
  14. echo $?
  15. if [ $? == 0 ];then
  16. make && make install
  17. echo $?
  18. if [ $? == 0 ];then
  19. echo "nasm success" >/media/1.txt
  20. else
  21. exit
  22. fi
  23. fi
  24. cd ../x264/ #安装x264
  25. ln -s /product/nasm2-13/bin/nasm /usr/bin/nasm
  26. ./configure --enable-shared --enable-static --prefix=/product/x264
  27. echo $?
  28. if [ $? == 0 ];then
  29. make && make install
  30. echo $?
  31. if [ $? == 0 ];then
  32. echo "x264 success" >> /media/1.txt
  33. else
  34. exit
  35. fi
  36. fi
  37. cd ..
  38. tar xvf ffmpeg-3.4.2.tar.bz2 #安装ffmpeg
  39. cd ffmpeg-3.4.2/
  40. ./configure --prefix=/product/ffmpeg/ --enable-shared --disable-ffserver --disable-ffplay --enable-postproc --enable-gpl --enable-libx264 --disable-asm --extra-cflags=-I/product/x264/include --extra-ldflags=-L/product/x264/lib
  41. echo $?
  42. if [ $? == 0 ];then
  43. make && make install
  44. echo $?
  45. if [ $? == 0 ];then
  46. echo "ffmpeg success" >/media/1.txt
  47. else
  48. exit
  49. fi
  50. fi
  51. ln -s /product/ffmpeg/bin/ffmpeg /usr/bin/ffmpeg #做链接,写入/etc/ld.so.conf
  52. sed -i '$a/product/x264/bin/' /etc/ld.so.conf
  53. sed -i '$a/product/x264/lib' /etc/ld.so.conf
  54. sed -i '$a/product/x264/include/' /etc/ld.so.conf
  55. ln -s /product/x264/bin/x264 /usr/bin/x264
  56. sed -i '$a/product/ffmpeg/lib/' /etc/ld.so.conf
  57. sed -i '$a/product/ffmpeg/include/' /etc/ld.so.conf
  58. ldconfig

 

 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/901688
推荐阅读
相关标签
  

闽ICP备14008679号