【问题标题】:Is ffmpeg running in CPU or GPU?ffmpeg 是在 CPU 还是 GPU 中运行?
【发布时间】:2021-05-25 20:25:39
【问题描述】:

已经在链接中展示了

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}...

但是在使用命令运行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 中运行?

【问题讨论】:

  • ffmpeg 在CPU 中运行。参考链接here.
  • 我相信只有某些编码器/解码器/功能启用了硬件加速。请参阅此处的表格:trac.ffmpeg.org/wiki/HWAccelIntro ...例如,在您的情况下,您可以使用-c:v nvenc_h264 使用 NVidia 卡对 H.264 视频进行编码。如果来源正确,OpenCL 似乎只支持过滤。
  • 我投票结束这个问题,因为它不是一个实际的编程问题。
  • 我正在使用英特尔 QSV。所以在链接 trac.ffmpeg.org/wiki/HWAccelIntro 中是肯定的。那么在快速同步的情况下,它会在 GPU 中运行吗??
  • 您能否提供更多有关执行平台的信息:CPU 型号、操作系统等?

标签: c++ video ffmpeg gpu


【解决方案1】:

要在 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

【讨论】:

    猜你喜欢
    • 2017-09-29
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 2021-11-20
    • 2020-07-18
    • 1970-01-01
    • 2012-11-21
    • 1970-01-01
    相关资源
    最近更新 更多