• 安装依赖库
yum install alsa-lib-devel
  • 下载头文件
git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git

cd nv-codec-headers

sudo make
sudo make install
  • 编译SDL2

https://blog.csdn.net/quantum7/article/details/104173159

  • 下载ffmpeg

http://ffmpeg.org/

最新的。

  • 重新编译 

# export is must use
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:${PKG_CONFIG_PATH}

pkg-config --modversion ffnvcodec

CUDA_PATH=nvcc=/usr/local/cuda-11.0

make clean

export ECFLAG="-fPIC"
./configure \
     --extra-cflags="-I/usr/local/cuda/include -fPIC " \
    --extra-ldflags="-L/usr/local/cuda/lib64   -ldl " \
    --pkg-config-flags=--static \
    --enable-shared \
    --enable-gpl --enable-libx264 \
    --enable-cuvid --enable-nvenc --enable-nonfree \
    --nvcc=${CUDA_PATH}/bin/nvcc

make

sudo make install
  • 更新库连接
echo "/usr/local/lib" >> /etc/ld.so.conf
ldconfig
  • 测试h264_nvenc
ffmpeg -h encoder=h264_nvenc
ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Encoder h264_nvenc [NVIDIA NVENC H.264 encoder]:
    General capabilities: delay hardware 
    Threading capabilities: none
    Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda
h264_nvenc AVOptions:
  -preset            <int>        E..V..... Set the encoding preset (from 0 to 11) (default medium)

  • test

    h264_cuvid

    ffmpeg -h decoder=h264_cuvid
    ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
      built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-39)
      libavutil      56. 31.100 / 56. 31.100
      libavcodec     58. 54.100 / 58. 54.100
      libavformat    58. 29.100 / 58. 29.100
      libavdevice    58.  8.100 / 58.  8.100
      libavfilter     7. 57.100 /  7. 57.100
      libswscale      5.  5.100 /  5.  5.100
      libswresample   3.  5.100 /  3.  5.100
      libpostproc    55.  5.100 / 55.  5.100
    Decoder h264_cuvid [Nvidia CUVID H264 decoder]:
        General capabilities: delay avoidprobe hardware 
        Threading capabilities: none
        Supported hardware devices: cuda 
        Supported pixel formats: cuda nv12 p010le p016le
    h264_cuvid AVOptions:
      -deint             <int>        .D.V..... Set deinterlacing mode (from 0 to 2) (default weave)
         weave                        .D.V..... Weave deinterlacing (do nothing)
         bob                          .D.V..... Bob deinterlacing
         adaptive                     .D.V..... Adaptive deinterlacing
      -gpu               <string>     .D.V..... GPU to be used for decoding
      -surfaces          <int>        .D.V..... Maximum surfaces to be used for decoding (from 0 to INT_MAX) (default 25)
      -drop_second_field <boolean>    .D.V..... Drop second field when deinterlacing (default false)
      -crop              <string>     .D.V..... Crop (top)x(bottom)x(left)x(right)
      -resize            <string>     .D.V..... Resize (width)x(height)