【视频开发】【CUDA开发】ffmpeg Nvidia硬件加速总结
原文链接:https://developer.nvidia.com/ffmpeg
GPU-accelerated video processing integrated into the most popular open-source multimedia tools.
FFmpeg and libav are among the most popular open-source multimedia manipulation tools with a library of plugins that can be applied to various parts of the audio and video processing pipelines and have achieved
wide adoption across the world.
Video encoding, decoding and transcoding are some of the most popular applications of FFmpeg. Thanks to the support of the FFmpeg and libav community and contributions from NVIDIA engineers, both of these tools
now support native NVIDIA GPU hardware accelerated video encoding and decoding through the integration of the NVIDIA Video Codec SDK.
Leveraging FFmpeg’s Audio codec, stream muxing, and RTP protocols, the FFmpeg’s integration of NVIDIA Video Codec SDK enables high performance hardware accelerated video pipelines.
FFmpeg uses Video Codec SDK
If you have an NVIDIA GPU which supports hardware-accelerated video encoding and decoding, it’s simply a matter of compiling FFmpeg binary with the required support for NVIDIA libraries and using the resulting binaries
to speed up video encoding/decoding.
FFmpeg supports following functionality accelerated by video hardware on NVIDIA GPUs:
- Hardware-accelerated encoding of H.264 and HEVC*
- Hardware-accelerated decoding** of H.264, HEVC, VP9, VP8, MPEG2, and MPEG4*
- Granular control over encoding settings such as encoding preset, rate control and other video quality parameters
- Create high-performance end-to-end hardware-accelerated video processing, 1:N encoding and 1:N transcoding pipeline using built-in filters in FFmpeg
- Ability to add your own custom high-performance CUDA filters using the shared CUDA context implementation in FFmpeg
- Windows/Linux support
* Support is dependent on HW. For a full list of GPUs and formats supported, please see the available GPU
Support Matrix.
** HW decode support will be added to libav in the near future


| Operating System | Windows 7, 8, 10, and Linux |
| Dependencies |
NVENCODE API - NVIDIA Quadro, Tesla, GRID or GeForce products with Kepler, Maxwell and Pascal generation GPUs. NVDECODE API - NVIDIA Quadro, Tesla, GRID or GeForce products with Fermi, Kepler, Maxwell and Pascal generation GPUs. GPU Support Matrix Appropriate NVIDIA Display Driver DirectX SDK (Windows only) Optional: CUDA toolkit 7.5 |
| Development Environment |
Windows: Visual Studio 2010/2013/2015, MSYS/MinGW Linux: gcc 4.8 or higher |
FFmpeg GPU HW-Acceleration Support Table
| Fermi | Kepler | Maxwell (1st Gen) | Maxwell (2nd Gen) | Maxwell (GM206) | Pascal | |
|---|---|---|---|---|---|---|
| H.264 encoding | N/A | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 |
| HEVC encoding | N/A | N/A | N/A | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 |
| MPEG2, MPEG-4, H.264 decoding | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 |
| HEVC decoding | N/A | N/A | N/A | N/A | FFmpeg v3.3 | FFmpeg v3.3 |
| VP9 decoding | N/A | N/A | N/A | FFmpeg v3.3 | FFmpeg v3.3 | FFmpeg v3.3 |
For guidelines about NVIDIA GPU-accelerated video encoding/decoding performance, please visit the Video
Codec SDK page for more details.
Getting Started with FFmpeg/libav using NVIDIA GPUs
Using NVIDIA hardware acceleration in FFmpeg/libav requires the following steps
- Download the latest FFmpeg or libav source
code, by cloning the corresponding GIT repositories - FFmpeg: https://git.FFmpeg.org/FFmpeg.git
- Libav: https://github.com/libav/libav
- Download and install the compatible driver from NVIDIA web site
- Downoad and install the CUDA Toolkit CUDA toolkit
- Use the following configure command (Use correct CUDA library path in config command below)
./configure --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree
--enable-libnpp
--extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 - Use following command for build: make -j 10
- Use FFmpeg/libav binary as required. To start with FFmpeg, try the below sample command line for 1:2 transcoding
ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -vsync 0 -i <input.mp4> –vf scale_npp=1920:1072
-vcodec h264_nvenc <output0.264> -vf scale_npp=1280:720 -vcodec h264_nvenc <output1.264>
For more information on FFmpeg licensing, please see this page.
FFmpeg in Action
FFmpeg is used by many projects, including Google Chrome and VLC player. You can easily integrate NVIDIA hardware-acceleration to these applications by configuring FFmpeg to use NVIDIA GPUs for video encoding and decoding tasks.

HandBrake is an open-source video transcoder available for Linux,
Mac, and Windows.
HandBrake works with most common video files and formats, including ones created by consumer and professional video cameras, mobile devices such as phones and tablets, game and computer screen recordings, and DVD and Blu-ray discs. HandBrake leverages tools
such as Libav, x264, and x265 to create new MP4 or MKV video files from these.

Plex Media Server is a client-server media player system and software suite that runs on Windows, macOS, linux,
FreeBSD or a NAS. Plex organizes all of the videos, music, and photos from your computer’s personal media library and let you stream to your devices.
The Plex Transcoder uses FFmpeg to handle and translates your media into that the format your client device supports.
How to use FFmpeg/libav with NVIDIA GPU-acceleration
Decode a single H.264 to YUV
To decode a single H.264 encoded elementary bitstream file into YUV, use the following command:
FFMPEG: ffmpeg -vsync 0 -c:v h264_cuvid -i <input.mp4> -f rawvideo <output.yuv>
LIBAV: avconv -vsync 0 -c:v h264_cuvid -i <input.mp4> -f rawvideo <output.yuv>
Example applications:
- Video analytics, video inferencing
- Video post-processing
- Video playback
Encode a single YUV file to a bitstream
To encode a single YUV file into an H.264/HEVC bitstream, use the following command:
H.264
FFMPEG: ffmpeg -f rawvideo -s:v 1920x1080 -r 30 -pix_fmt yuv420p -i <input.yuv>
-c:v h264_nvenc -preset slow -cq 10 -bf 2 -g 150 <output.mp4>
LIBAV: avconv -f rawvideo -s:v 1920x1080 -r 30 -pix_fmt yuv420p -i <input.yuv> -c:v h264_nvenc -preset slow -cq 10 -bf 2 -g 150 <output.mp4>
HEVC (No B-frames)
FFMPEG: ffmpeg -f rawvideo -s:v 1920x1080 -r 30 -pix_fmt yuv420p -i <input.yuv>
-vcodec hevc_nvenc -preset slow -cq 10 -g 150 <output.mp4>
LIBAV: avconv -f rawvideo -s:v 1920x1080 -r 30 -pix_fmt yuv420p -i <input.yuv> -vcodec hevc_nvenc -preset slow -cq 10 -g 150 <output.mp4>
Example applications:
- Surveillance
- Archiving footages from remote cameras
- Archiving raw captured video from a single camera
Transcode a single video file
To do 1:1 transcode, use the following command:
FFMPEG: ffmpeg -hwaccel cuvid -c:v h264_cuvid -i <input.mp4> -vf scale_npp=1280:720
-c:v h264_nvenc <output.mp4>
LIBAV: avconv -hwaccel cuvid -c:v h264_cuvid -i <input.mp4> -vf scale_npp=1280:720 -c:v h264_nvenc <output.mp4>
Example applications:
- Accelerated transcoding of consumer videos
Transcode a single video file to N streams
To do 1:N transcode, use the following command:
FFMPEG: ffmpeg -hwaccel cuvid -c:v h264_cuvid -i <input.mp4> -vf scale_npp=1280:720
-vcodec h264_nvenc <output0.mp4> -vf scale_npp 640:480 -vcodec h264_nvenc <output1.mp4>
LIBAV: avconv -hwaccel cuvid -c:v h264_cuvid -i <input.mp4> -vf scale_npp=1280:720 -vcodec h264_nvenc <output0.mp4> -vf scale_npp 640:480 -vcodec h264_nvenc <output1.mp4>
Example applications:
- Commercial (data center) video transcoding
Resources
Supported GPUs
HW accelerated encode and decode are supported on NVIDIA GeForce, Quadro, Tesla, and GRID products with Fermi, Kepler, Maxwell and Pascal generation GPUs. Please refer to GPU
support matrix for specific codec support.
Additional Resources
【视频开发】【CUDA开发】ffmpeg Nvidia硬件加速总结的更多相关文章
- 【并行计算-CUDA开发】【视频开发】ffmpeg Nvidia硬件加速总结
2017年5月25日 0. 概述 FFmpeg可通过Nvidia的GPU进行加速,其中高层接口是通过Video Codec SDK来实现GPU资源的调用.Video Codec SDK包含完整的的高性 ...
- 【并行计算与CUDA开发】英伟达硬件加速编解码
硬件加速 并行计算 OpenCL OpenCL API VS SDK 英伟达硬件编解码方案 基于 OpenCL 的 API 自己写一个编解码器 使用 SDK 中的编解码接口 使用编码器对于 OpenC ...
- 【并行计算与CUDA开发】英伟达硬件加速解码器在 FFMPEG 中的使用
目录(?)[-] 私有驱动 编译 FFMPEG 使用 nvenc 这篇文档介绍如何在 ffmpeg 中使用 nvenc 硬件编码器. 私有驱动 nvenc 本身是依赖于 nvidia 底层的私有驱动的 ...
- 【并行计算-CUDA开发】CUDA软件架构与Nvidia硬件对应关系
前面扯了很多,不过大多都是在讲CUDA 在软体层面的东西:接下来,虽然Heresy 自己也不熟,不过还是来研究一下硬体的部分吧-毕竟要最佳化的时候,好像还是要大概知道一下相关的东西的.这部分主要参考资 ...
- FFmpeg再学习 -- 硬件加速编解码
为了搞硬件加速编解码,用了一周时间来看 CUDA,接下来开始加以总结. 一.什么是 CUDA (1)首先需要了解一下,什么是 CUDA. 参看:百度百科 -- CUDA 参看:CUDA基础介绍 参看: ...
- 【视频开发】【CUDA开发】FFMPEG硬件加速-nvidia方案
1.目标 <1>显卡性能参数: <2>方案可行性: 2.平台信息 2.1.查看当前显卡信息 命令: lspci |grep VGA 信息: 01:00.0 VGA com ...
- 【ARM-Linux开发】【CUDA开发】【视频开发】关于Linux下利用GPU对视频进行硬件加速转码的方案
最近一直在研究Linux下利用GPU进行硬件加速转码的方案,折腾了很久,至今没有找到比较理想的硬加速转码方案.似乎网上讨论这一方案的文章也特别少,这个过程中也进行了各种尝试,遇到很多具体问题,以下便对 ...
- 【视频开发】ffmpeg实现dxva2硬件加速
这几天在做dxva2硬件加速,找不到什么资料,翻译了一下微软的两篇相关文档.这是第二篇,记录用ffmpeg实现dxva2. 第一篇翻译的Direct3D device manager,链接:http: ...
- 【并行计算-CUDA开发】 NVIDIA Jetson TX1
概述 NVIDIA Jetson TX1是计算机视觉系统的SoM(system-on-module)解决方案.它组合了最新的NVIDIAMaxwell GPU架构,其具有ARM Cortex-A57 ...
随机推荐
- Alpha冲刺(10/10)——2019.5.3
所属课程 软件工程1916|W(福州大学) 作业要求 Alpha冲刺(10/10)--2019.5.3 团队名称 待就业六人组 1.团队信息 团队名称:待就业六人组 团队描述:同舟共济扬帆起,乘风破浪 ...
- idea拉取最新代码弹窗(Ctrl + T)
在此设置
- 常见的transformation算子
RDD:RDD分区数,若从HDFS创建RDD,RDD的分区就是和文件块一一对应,若是集合并行化形式创建,RDD分区数可以指定,一般默认值是CPU的核数. task:task数量就是和分区数量对应. 一 ...
- Java中多态
多态:把子类看成是父类,把实现类看成是接口,这样类就具有多种形态,称为多态. 在多态中访问成员变量,访问的是父类中的成员变量. 在多态中访问成员方法,先访问的是子类,看看子类有没有覆盖重写要访问的父类 ...
- 【洛谷P4319】 变化的道路 线段树分治+LCT
最近学了一下线段树分治,感觉还蛮好用... 如果正常动态维护最大生成树的话用 LCT 就行,但是这里还有时间这一维的限制. 所以,我们就把每条边放到以时间为轴的线段树的节点上,然后写一个可撤销 LCT ...
- H5如何实现关闭当前页面,跳转到新页面?
小程序有此功能的跳转方法. 那么H5如何实现该功能? 很简单. location.replace('new.html') 这个方法可以实现 关闭当前页面,跳转到新页面 的效果. 而 windo ...
- prisma 已经支持mongodb了
好久没有关注prisma 的版本迭代了,记得在去年12月份左右的时候,mongodb 在github 上还只是一个草案, 官方文档也没有相关的详细介绍,今天留意了下,居然已经支持了,还是很给力的(my ...
- 51Nod 1769 Clarke and math2
51Nod 1769 Clarke and math2 http://www.51nod.com/Challenge/Problem.html#!#problemId=1769 要算的是\(G=F*I ...
- 【2019.11.06】SDN上机第2次作业
参考资料网址:https://www.cnblogs.com/TITIN24/p/11794970.html 利用mininet创建如下拓扑 要求拓扑支持OpenFlow 1.3协议,主机名.交换机名 ...
- 第06组 Beta冲刺(2/4)
队名:福大帮 组长博客链接:https://www.cnblogs.com/mhq-mhq/p/11990570.html 作业博客 : https://edu.cnblogs.com/campus/ ...