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. 關閉編碼回話
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章