当前位置: 首页 > news >正文

[win10] ffmpeg gpu加速

ffmpeg 基础转:[win10] ffmpeg 学习笔记_*小呆的博客-CSDN博客

根据NVIDIA官网,FFmpeg | NVIDIA Developer。如下的gpu被支持使用ffmpeg的gpu加速。

FFmpeg GPU HW-Acceleration Support Table

FermiKeplerMaxwell (1st Gen)Maxwell (2nd Gen)Maxwell (GM206)Pascal
H.264 encodingN/AFFmpeg v3.3FFmpeg v3.3FFmpeg v3.3FFmpeg v3.3FFmpeg v3.3
HEVC encodingN/AN/AN/AFFmpeg v3.3FFmpeg v3.3FFmpeg v3.3
MPEG2, MPEG-4, H.264 decodingFFmpeg v3.3FFmpeg v3.3FFmpeg v3.3FFmpeg v3.3FFmpeg v3.3FFmpeg v3.3
HEVC decodingN/AN/AN/AN/AFFmpeg v3.3FFmpeg v3.3
VP9 decodingN/AN/AN/AFFmpeg v3.3FFmpeg v3.3FFmpeg v3.3

 官方提供,加速情况如下

我在使用ffmpeg.exe -f image2 -i \%05d.tiff -vcodec h264_nvenc output5_tiff.mkv 时出现如下错误:

No NVENC capable devices found
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height 

硬件要求

        看来只安装了ffmpeg并不能直接使用 _nvenc,我们先检查一下硬件是否满足要求。Video Encode and Decode GPU Support Matrix [NEW] | NVIDIA Developer

NVDEC Support Matrix

BOARD

FAMILY

CHIP

# OF CHIPS

# OF NVDEC
/CHIP

Total # of NDEC

MPEG-1

MPEG-2

VC-1

H.264
(AVCHD)

H.265 (HEVC)

   VP8   

VP9

8 bit10 bit12 bit8 bit10 bit12 bit
GeForce
GeForce GT 1030                              Pascal                     GP108111YESYESYESYESYESYESYESNOYESYESYES
GeForce GTX 1050 / 1050 TiPascalGP107111YESYESYESYESYESYESYESNOYESYESYES
GeForce GTX 1050 / 1050 TiPascalGP106111YESYESYESYESYESYESYESNOYESNONO
GeForce GTX 1060PascalGP106111YESYESYESYESYESYESYESNOYESNONO
GeForce GTX 1060PascalGP104111YESYESYESYESYESYESYESNOYESNONO
GeForce GTX 1070 - 1080PascalGP104111YESYESYESYESYESYESYESYESYESNONO
GeForce GTX 1080 TiPascalGP102111YESYESYESYESYESYESYESNOYESYESYES
GeForce GTX Titan X Titan XpPascalGP102111YESYESYESYESYESYESYESNOYESYESYES
Titan VVoltaGV100111YESYESYESYESYESYESYESNOYESYESYES

我是gtx1050,所以ok,在网上查询,突然发现,win里面如果直接下载了ffmpeg官网的exe他其实里面自带编译好的一些nvenc的,是可以直接调用的。

windows 下ffmpeg gpu的加速

ffmpeg -codecs | sls cuvid (备注:sls是powershell的命令,类似于linux下的grep命令)

 

DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv h264_cuvid ) (encoders:
 libx264 libx264rgb h264_amf h264_nvenc h264_qsv nvenc nvenc_h264 )


 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_cuvid ) (encoder
s: libx265 nvenc_hevc hevc_amf hevc_nvenc hevc_qsv )


 DEVIL. mjpeg                Motion JPEG (decoders: mjpeg mjpeg_cuvid ) (encoders: mjpeg mjpeg_qsv )


 DEV.L. mpeg1video           MPEG-1 video (decoders: mpeg1video mpeg1_cuvid )
 DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv mpeg2_cuvid ) (encoders: mpeg2video mpeg2_qsv )
 DEV.L. mpeg4                MPEG-4 part 2 (decoders: mpeg4 mpeg4_cuvid ) (encoders: mpeg4 libxvid )
 D.V.L. vc1                  SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_cuvid )
 DEV.L. vp8                  On2 VP8 (decoders: vp8 libvpx vp8_cuvid vp8_qsv ) (encoders: libvpx )
 DEV.L. vp9                  Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid ) (encoders: libvpx-vp9 )

记录:

intel的集成显卡就支持硬件编解码,通过qsv技术

nvenc 是nvidia的硬压

软压、硬压 速度比较(底下有解释这两个名词)

1.hevc

ffmpeg.exe -i D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\test\%05d.tiff -v
codec hevc D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\output5.mkv

frame=  820 fps= 40 q=-0.0 Lsize=      89kB time=00:00:32.68 bitrate=  22.3kbits/s speed=1.61x
video:81kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 9.601210%
x265 [info]: frame I:      4, Avg QP:10.98  kb/s: 510.90
x265 [info]: frame P:    290, Avg QP:31.95  kb/s: 19.42
x265 [info]: frame B:    526, Avg QP:34.97  kb/s: 15.84
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 37.8% 8.8% 21.1% 1.4% 31.0%

encoded 820 frames in 19.72s (41.57 fps), 19.52 kb/s, Avg QP:33.78

2.libx265

ffmpeg.exe -i D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\test\%05d.tiff -v
codec libx265 D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\output5.mkv

frame=  820 fps= 43 q=-0.0 Lsize=      89kB time=00:00:32.68 bitrate=  22.3kbits/s speed=1.72x
video:81kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 9.601210%
x265 [info]: frame I:      4, Avg QP:10.98  kb/s: 510.90
x265 [info]: frame P:    290, Avg QP:31.95  kb/s: 19.42
x265 [info]: frame B:    526, Avg QP:34.97  kb/s: 15.84
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 37.8% 8.8% 21.1% 1.4% 31.0%

encoded 820 frames in 19.00s (43.16 fps), 19.52 kb/s, Avg QP:33.78

3.hevc_nvenc

ffmpeg.exe -i D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\test\%05d.tiff -v codec hevc_nvenc D:\Liu_Dong\Brain_map_compression\ZhangYueYi\raw_brain\output5.mkv

frame=  820 fps=107 q=16.0 Lsize=      84kB time=00:00:32.76 bitrate=  20.9kbits/s speed=4.26x
video:78kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.649312%

可以看到,速度快了3-4倍

知识点记录

1.查看所有可用的硬件加速器。

ffmpeg -hwaccels

2.软编码和硬编码如何区分

    软编码:使用CPU进行编码

    硬编码:使用非CPU进行编码,如显卡GPU、专用的DSP、FPGA、ASIC芯片等

3.软编码和硬编码比较

       软编码:实现直接、简单,参数调整方便,升级易,但CPU负载重,性能较硬编码低,低码率下质量通常比硬编码要好一点。

       硬编码:性能高,低码率下通常质量低于软编码器,但部分产品在GPU硬件平台移植了优秀的软编码算法(如X264)的,质量基本等同于软编码。

4. ffmpeg -codecs | grep nvenc(从编解码器里找到nvenc的相关选项)

如果不加 grep nvenc 出来的是全部的codec。

其中前缀含义如下:
前缀含义

D….. = Decoding supported
.E…. = Encoding supported
..V… = Video codec
..A… = Audio codec
..S… = Subtitle codec 字幕编解码
…I.. = Intra frame-only codec
….L. = Lossy compression  有损压缩
…..S = Lossless compression  无损压缩

5. ffmpeg -h encoder=hevc_nvenc (得到编码器为hevc_nvenc的全部信息)

注意这个可以预先检查你的设备是否支持这个编码器

ffmpeg version N-92288-gbdfd2e3c79 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181017
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 21.100 / 56. 21.100
  libavcodec     58. 34.100 / 58. 34.100
  libavformat    58. 19.102 / 58. 19.102
  libavdevice    58.  4.106 / 58.  4.106
  libavfilter     7. 38.100 /  7. 38.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
Encoder hevc_nvenc [NVIDIA NVENC hevc encoder]:
    General capabilities: delay hardware
    Threading capabilities: none
    Supported pixel formats: yuv420p nv12 p010le yuv444p p016le yuv444p16le bgr0 rgb0 cuda d3d11
hevc_nvenc AVOptions:
  -preset            <int>        E..V..... Set the encoding preset (from 0 to 11) (default medium)
     default                      E..V.....
     slow                         E..V..... hq 2 passes
     medium                       E..V..... hq 1 pass
     fast                         E..V..... hp 1 pass
     hp                           E..V.....
     hq                           E..V.....
     bd                           E..V.....
     ll                           E..V..... low latency
     llhq                         E..V..... low latency hq
     llhp                         E..V..... low latency hp
     lossless                     E..V..... lossless
     losslesshp                   E..V..... lossless hp
  -profile           <int>        E..V..... Set the encoding profile (from 0 to 4) (default main)
     main                         E..V.....
     main10                       E..V.....
     rext                         E..V.....
  -level             <int>        E..V..... Set the encoding level restriction (from 0 to 186) (default auto)
     auto                         E..V.....
     1                            E..V.....
     1.0                          E..V.....
     2                            E..V.....
     2.0                          E..V.....
     2.1                          E..V.....
     3                            E..V.....
     3.0                          E..V.....
     3.1                          E..V.....
     4                            E..V.....
     4.0                          E..V.....
     4.1                          E..V.....
     5                            E..V.....
     5.0                          E..V.....
     5.1                          E..V.....
     5.2                          E..V.....
     6                            E..V.....
     6.0                          E..V.....
     6.1                          E..V.....
     6.2                          E..V.....
  -tier              <int>        E..V..... Set the encoding tier (from 0 to 1) (default main)
     main                         E..V.....
     high                         E..V.....
  -rc                <int>        E..V..... Override the preset rate-control (from -1 to INT_MAX) (default -1)
     constqp                      E..V..... Constant QP mode
     vbr                          E..V..... Variable bitrate mode
     cbr                          E..V..... Constant bitrate mode
     vbr_minqp                    E..V..... Variable bitrate mode with MinQP (deprecated)
     ll_2pass_quality              E..V..... Multi-pass optimized for image quality (deprecated)
     ll_2pass_size                E..V..... Multi-pass optimized for constant frame size (deprecated)
     vbr_2pass                    E..V..... Multi-pass variable bitrate mode (deprecated)
     cbr_ld_hq                    E..V..... Constant bitrate low delay high quality mode
     cbr_hq                       E..V..... Constant bitrate high quality mode
     vbr_hq                       E..V..... Variable bitrate high quality mode
  -rc-lookahead      <int>        E..V..... Number of frames to look ahead for rate-control (from 0 to INT_MAX) (default 0)
  -surfaces          <int>        E..V..... Number of concurrent surfaces (from 0 to 64) (default 0)
  -cbr               <boolean>    E..V..... Use cbr encoding mode (default false)
  -2pass             <boolean>    E..V..... Use 2pass encoding mode (default auto)
  -gpu               <int>        E..V..... Selects which NVENC capable GPU to use. First GPU is 0, second is 1, and so on. (from -2 to INT_MAX) (default any)
     any                          E..V..... Pick the first device available
     list                         E..V..... List the available devices
  -delay             <int>        E..V..... Delay frame output by the given amount of frames (from 0 to INT_MAX) (default INT_MAX)
  -no-scenecut       <boolean>    E..V..... When lookahead is enabled, set this to 1 to disable adaptive I-frame insertion at scene cuts (default false)
  -forced-idr        <boolean>    E..V..... If forcing keyframes, force them as IDR frames. (default false)
  -spatial_aq        <boolean>    E..V..... set to 1 to enable Spatial AQ (default false)
  -temporal_aq       <boolean>    E..V..... set to 1 to enable Temporal AQ (default false)
  -zerolatency       <boolean>    E..V..... Set 1 to indicate zero latency operation (no reordering delay) (default false)
  -nonref_p          <boolean>    E..V..... Set this to 1 to enable automatic insertion of non-reference P-frames (default false)
  -strict_gop        <boolean>    E..V..... Set 1 to minimize GOP-to-GOP rate fluctuations (default false)
  -aq-strength       <int>        E..V..... When Spatial AQ is enabled, this field is used to specify AQ strength. AQ strength scale is from 1 (low) - 15 (aggressive) (from 1 to 15) (default 8)
  -cq                <float>      E..V..... Set target quality level (0 to 51, 0 means automatic) for constant quality mode in VBR rate control (from 0 to 51) (default 0)
  -aud               <boolean>    E..V..... Use access unit delimiters (default false)
  -bluray-compat     <boolean>    E..V..... Bluray compatibility workarounds (default false)
  -init_qpP          <int>        E..V..... Initial QP value for P frame (from -1 to 51) (default -1)
  -init_qpB          <int>        E..V..... Initial QP value for B frame (from -1 to 51) (default -1)
  -init_qpI          <int>        E..V..... Initial QP value for I frame (from -1 to 51) (default -1)
  -qp                <int>        E..V..... Constant quantization parameter rate control method (from -1 to 51) (default -1)
  -weighted_pred     <int>        E..V..... Set 1 to enable weighted prediction (from 0 to 1) (default 0)

6. cuvid不支持编码端,只有解码端。

        执行了下面之后

ffmpeg -codecs | grep cuvid

 可以看到只有解码端

 DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_qsv h264_cuvid ) (encoders: libx264 libx264rgb h264_amf h264_nvenc h264_qsv nvenc nvenc_h264 )
 DEV.L. hevc                 H.265 / HEVC (High Efficiency Video Coding) (decoders: hevc hevc_qsv hevc_cuvid ) (encoders: libx265 nvenc_hevc hevc_amf hevc_nvenc hevc_qsv )
 DEVIL. mjpeg                Motion JPEG (decoders: mjpeg mjpeg_cuvid ) (encoders: mjpeg mjpeg_qsv )
 DEV.L. mpeg1video           MPEG-1 video (decoders: mpeg1video mpeg1_cuvid )
 DEV.L. mpeg2video           MPEG-2 video (decoders: mpeg2video mpegvideo mpeg2_qsv mpeg2_cuvid ) (encoders: mpeg2video mpeg2_qsv )
 DEV.L. mpeg4                MPEG-4 part 2 (decoders: mpeg4 mpeg4_cuvid ) (encoders: mpeg4 libxvid )
 D.V.L. vc1                  SMPTE VC-1 (decoders: vc1 vc1_qsv vc1_cuvid )
 DEV.L. vp8                  On2 VP8 (decoders: vp8 libvpx vp8_cuvid vp8_qsv ) (encoders: libvpx )
 DEV.L. vp9                  Google VP9 (decoders: vp9 libvpx-vp9 vp9_cuvid ) (encoders: libvpx-vp9 )

参考:硬编 软编 ffmpeg nvidia - bw_0927 - 博客园

转自:[win10] ffmpeg gpu加速_*小呆的博客-CSDN博客_ffmpeg gpu加速

相关文章:

  • Qt/null 空指针的一些操作规则
  • FFmpeg H264编码
  • 图像锐化是什么
  • FFmpeg原始帧处理-滤镜API用法详解
  • ffmpeg中的rtbufsize
  • 智能指针的实现
  • 什么是构造函数和析构函数?
  • CD-ROM
  • 光盘文件格式-udf、iso9660、Joliet、Romeo
  • 刻录光盘的程序步骤
  • ISO文件
  • DVD-数字通用光盘
  • VCD-影音光碟
  • CD-CompactDisk
  • 光盘的标准与格式
  • ----------
  • [ JavaScript ] 数据结构与算法 —— 链表
  • 【MySQL经典案例分析】 Waiting for table metadata lock
  • Android优雅地处理按钮重复点击
  • CentOS 7 修改主机名
  • co.js - 让异步代码同步化
  • CSS魔法堂:Absolute Positioning就这个样
  • Docker容器管理
  • eclipse(luna)创建web工程
  • iOS | NSProxy
  • JavaScript 奇技淫巧
  • java架构面试锦集:开源框架+并发+数据结构+大企必备面试题
  • Laravel 实践之路: 数据库迁移与数据填充
  • Making An Indicator With Pure CSS
  • mongodb--安装和初步使用教程
  • Spring Boot MyBatis配置多种数据库
  • SpringCloud集成分布式事务LCN (一)
  • Tornado学习笔记(1)
  • vue+element后台管理系统,从后端获取路由表,并正常渲染
  • Vue2.0 实现互斥
  • windows下mongoDB的环境配置
  • zookeeper系列(七)实战分布式命名服务
  • 从0搭建SpringBoot的HelloWorld -- Java版本
  • 分享几个不错的工具
  • 构建工具 - 收藏集 - 掘金
  • 软件开发学习的5大技巧,你知道吗?
  • 为视图添加丝滑的水波纹
  • 小李飞刀:SQL题目刷起来!
  • 移动互联网+智能运营体系搭建=你家有金矿啊!
  • 用Canvas画一棵二叉树
  • 终端用户监控:真实用户监控还是模拟监控?
  • 昨天1024程序员节,我故意写了个死循环~
  • ​ ​Redis(五)主从复制:主从模式介绍、配置、拓扑(一主一从结构、一主多从结构、树形主从结构)、原理(复制过程、​​​​​​​数据同步psync)、总结
  • ​学习一下,什么是预包装食品?​
  • #我与Java虚拟机的故事#连载03:面试过的百度,滴滴,快手都问了这些问题
  • #在线报价接单​再坚持一下 明天是真的周六.出现货 实单来谈
  • (附源码)springboot家庭装修管理系统 毕业设计 613205
  • (个人笔记质量不佳)SQL 左连接、右连接、内连接的区别
  • (更新)A股上市公司华证ESG评级得分稳健性校验ESG得分年均值中位数(2009-2023年.12)
  • (三)Pytorch快速搭建卷积神经网络模型实现手写数字识别(代码+详细注解)