ffmpeg 是在 CPU 还是 GPU 上运行?

Rag*_*raj 7 c++ video gpu ffmpeg

已经在链接中显示了

https://dri.freedesktop.org/wiki/IntelPerformanceTuning/

第 2 步:CPU 与 GPU

如果 CPU % 超过 90,则应用程序正在 CPU 中运行。

在配置 ffmpeg 时,我启用了 opencl。ffmpeg 配置是,

ffmpeg version ebe0fa0 Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
  configuration: --enable-gpl --enable-libx264 --enable-opencl --enable-nonfree --enable-libmfx --enable-libmp3lame --enable-libaacplus
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
Run Code Online (Sandbox Code Playgroud)

但是在使用命令运行 ffmpeg 时

ffmpeg -i /home/M.mp4 -c:v h264 -preset:v 更快 /home/out.avi

CPU% 已超过 90 (375%)。

对于 ImageMagick,如果我在配置时启用 opencl,那么该应用程序将在 GPU 中运行,即 CPU% 将低于 90。我注意到了这一点。

但对于 ffmpeg,它是 GPU 加速的。那么,为什么CPU%会超过90%呢?ffmpeg 是在 CPU 还是 GPU 上运行?如果不是,我怎样才能让它在GPU中运行?

小智 13

要在 GPU 上工作,您应该在设置中启用视频编码/解码技术,之后,您应该根据您拥有的硬件,为每个命令指定正确的参数。

有时,如果添加此参数,即使没有在配置中启用任何内容,ffmpeg 也可以在您的 GPU 上运行。

将 AVI 编码为 h.264 视频(软件编码)

ffmpeg -i input.avi -c:v libx264 output.mp4

将 AVI 编码为 h.265 视频(软件编码)

ffmpeg -i input.avi -c:v libx265 output.mp4

将 AVI 编码为 h.264 视频(AMD GPU 编码)

ffmpeg -i input.avi -c:v h264_amf output.mp4

将 AVI 编码为 h.265 视频(AMD GPU 编码)

ffmpeg -i input.avi -c:v hevc_amf output.mp4

将 AVI 编码为 h.264 视频(NVIDIA GPU 编码)

ffmpeg -i input.avi -c:v h264_nvenc output.mp4

将 AVI 编码为 h.265 视频(NVIDIA GPU 编码)

ffmpeg -i input.avi -c:v hevc_nvenc output.mp4