1.显卡能力排查
目前只有 NIVIDIA 支持 ffmpeg 的 gpu加速(AMD貌似也陆续开始支持)。
在下述网站中查找自己的显卡能够支持的编解码格式。https://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-newhttps://developer.nvidia.com/video-encode-and-decode-gpu-support-matrix-new
2.更新显卡驱动 (可选)
https://www.nvidia.cn/content/DriverDownloads/https://www.nvidia.cn/content/DriverDownloads/
3.安装 cuda tool kit
https://developer.nvidia.com/cuda-downloads?target_os=Windowshttps://developer.nvidia.com/cuda-downloads?target_os=Windows
4.安装包含NVIDIA加速组件的ffmpeg
在gyan.dev发布网站中找到并下载 ffmpeg-git-full.7z ,essential版本不包含NVIDIA编解码器组件,不要下载。
Builds - CODEX FFMPEG @ gyan.devhttps://www.gyan.dev/ffmpeg/builds/
5.配置ffmpeg在windows下的环境
略
6.测试是否安装成功
C:\Users\Alienware>ffmpeg -encoders|findstr /i "nvenc"
ffmpeg version 2024-07-04-git-03175b587c-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 59. 28.100 / 59. 28.100
libavcodec 61. 9.100 / 61. 9.100
libavformat 61. 4.100 / 61. 4.100
libavdevice 61. 2.100 / 61. 2.100
libavfilter 10. 2.102 / 10. 2.102
libswscale 8. 2.100 / 8. 2.100
libswresample 5. 2.100 / 5. 2.100
libpostproc 58. 2.100 / 58. 2.100
V....D av1_nvenc NVIDIA NVENC av1 encoder (codec av1)
V....D h264_nvenc NVIDIA NVENC H.264 encoder (codec h264)
V....D hevc_nvenc NVIDIA NVENC hevc encoder (codec hevc)
7.转码试试效果
E:\videos\8k>ffmpeg -hwaccel cuda -i 8K.mp4 -c:v hevc_nvenc -b:v 40M -c:a copy -f hls -hls_time 2 -hls_list_size 0 index.m3u8