ffmpeg在CPU或GPU中运行吗?

时间:2016-07-14 11:37:56

标签: c++ video ffmpeg gpu

已在链接中显示

  

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 faster /home/out.avi

CPU%已超过90(375%)。

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

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

1 个答案:

答案 0 :(得分:0)

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

相关问题