c++ - ffmpeg 是在 CPU 还是 GPU 中运行?

标签 c++ video ffmpeg gpu

它已显示在链接中

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

Step 2: CPU vs 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 中运行?

最佳答案

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

关于c++ - ffmpeg 是在 CPU 还是 GPU 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38373180/

相关文章:

macos - 使用 YUV 4 :2:0 Planar color model 在 Mac OS X 上进行 ffmpeg 屏幕截图

FFmpeg 是 libx264 的最佳 LGPL 替代品?

c++ - Apache 权限被拒绝连接到套接字

C++编程效率

c++ - 为什么模板只能在头文件中实现?

javascript - 在Javascript中实现倒带功能

c++ - 绘制opencv?

android - 以纵向模式拍摄视频,但使用媒体播放器播放时方向错误

c++ - 我如何在 C++ 中执行 os.getpid()?

javascript - 使用 Dailymotion javascript SDK 时带破折号的参数不起作用