NVENC编码器API调用流程

NVIDIA GPUs based on architectures Kepler and beyond, contain a hardware-based H.264/HEVC video encoder (hereafter referred to as NVENC). The NVENC hardware takes YUV/RGB as input and generates an H.264/HEVC compliant video bitstream. NVENC hardware’s encoding capabilities can be accessed using the NVENCODE APIs, available in the NVIDIA Video Codec SDK.

This document provides information on how to program the NVENC using the NVENCODE APIs exposed in the SDK. The NVENCODE APIs expose encoding capabilities on Windows (Windows 7 and above) and Linux. It is expected that the developers should understand H.264/HEVC video codecs and familiarity with Windows and/or Linux development environment. NVENCODE API guarantees backward compatibility (and will make explicit reference whenever backward compatibility is broken). This means that applications compiled with older versions of released API will continue to work on future driver versions released by NVIDIA.

Developers can create a client application that calls NVENCODE API functions exposed by nvEncodeAPI.dll for Windows or libnvidia-encode.so for Linux. These libraries are installed as part of the NVIDIA display driver. The client application can either link to these libraries at run-time using LoadLibrary() on Windows or dlopen() on Linux.
The NVIDIA video encoder API is designed to accept raw video frames (in YUV or RGB format) and output the H.264 or HEVC bitstream. Broadly, the encoding flow consists of the following steps:

  1. Initialize the encoder
  2. Set up the desired encoding parameters
  3. Allocate input/output buffers
  4. Copy frames to input buffers and read bitstream from the output buffers. This can be
    done synchronously (Windows & Linux) or asynchronously (Windows 7 and above
    only).
  5. Clean-up - release all allocated input/output buffers
  6. Close the encoding session

一. 环境配置 [Windows]

  1. NVIDIA Kepler/Maxwell/Pascal/Volta/Turing GPU
  2. Windows: 驱动版本≥ version 418.81
  3. CUDA 10.0 Toolkit
  4. DirectX SDK

二. 流程简介

  1. 初始化编码器
  2. 设置所需编码参数
  3. 分配输入输出buffer
  4. 向input buffer输入编码帧,从output buffer中得到码流(可同步/异步)
  5. 清除释放所分配的输入输出buffer
  6. 关闭编码回话

猜你喜欢

转载自blog.csdn.net/weixin_37524256/article/details/106354745