VideoEncodeConfig

Function

Stores video encoding parameters.

Structure Definition

struct VideoEncodeConfig {
    uint32_t width = 1920;
    uint32_t height = 1080;
    // stream format renference acldvppStreamFormat
    StreamFormat outputVideoFormat = StreamFormat::H264_MAIN_LEVEL;
    // output format renference acldvppPixelFormat
    ImageFormat inputImageFormat = ImageFormat::YUV_SP_420;
    VideoEncodeCallBack callbackFunc = nullptr;
    uint32_t keyFrameInterval = 30;
    uint32_t srcRate = 30;
    uint32_t rcMode = 0;
    uint32_t maxBitRate = 300;
    uint32_t ipProp = 70;
};

Parameter Description

Parameter

Description

width

Width of the encoded video frame data. The value must be the same as the width of the image to be encoded (originalSize) and defaults to 1920.

  • For the Atlas 200/300/500 inference product, the value ranges from 128 to 1920, and the input video width must be a multiple of 16.
  • For the Atlas inference products, the value ranges from 128 to 4096, and the input video width must be a multiple of 2.

height

Height of the encoded video frame data. The value must be the same as the height of the image to be encoded (originalSize) and defaults to 1080.

  • For the Atlas 200/300/500 inference product, the value ranges from 128 to 1920, and the input video height must be a multiple of 2.
  • For the Atlas inference products, the value ranges from 128 to 4096, and the input video height must be a multiple of 2.

outputVideoFormat

Output video format after encoding. The default value is StreamFormat::H264_MAIN_LEVEL.

inputImageFormat

Supported input image format: YUV_SP_420 (default) and YVU_SP_420

callbackFunc

Callback function after encoding. It cannot be a null pointer.

keyFrameInterval

Video I-frame interval. The value ranges from 1 to 2000 and defaults to 30.

srcRate

Frame rate of input streams, in fps. The default value is 30.

  • For the Atlas 200/300/500 inference product, the value ranges from 1 to 120.
  • For the Atlas inference products, the value ranges from 1 to 240.

rcMode

Bit rate control mode. The values are as follows:
  • 0 (default): default mode. For the Atlas 200/300/500 inference product, the default mode is CBR. For the Atlas inference products, the default mode is VBR.
  • 1: variable bit rate (VBR) mode
  • 2: constant bit rate (CBR) mode

maxBitRate

Output bit rate, in kbit/s. The default value is 300.

  • For the Atlas 200/300/500 inference product, the value ranges from 10 to 30000.
  • For the Atlas inference products, the value ranges from 2 to 614400.

ipProp

I-frame to P-frame bit allocation ratio within a GOP. The value ranges from 1 to 100 and defaults to 70.

Recommended Configuration

The following table lists the recommended parameter settings that ensure good video encoding quality during video collection. In other scenarios, adjust the parameter settings as required.

Picture Quality/Resolution

srcRate

keyFrameInterval

maxBitRate

4K

3840 * 2160/4096 * 2160

25 or 30

50 or 60

  • H.264: 8000 to 12000
  • H.265: 8000 to 12000

2K

2560 x 1440

25 or 30

50 or 60

  • H.264: 6000 to 10000
  • H.265: 6000 to 10000

1080p (Blu-ray)

1920 x 1080

25 or 30

50 or 60

  • H.264: 2000 to 6000
  • H.265: 1000 to 4000

720p (HD)

1280 x 720

25 or 30

50 or 60

  • H.264: 1000 to 3000
  • H.265: 800 to 2000

480p/D1_N (SD)

854 x 480/720 x 480

25 or 30

50 or 60

  • H.264: 600 to 1400
  • H.265: 300 to 700

576P/D1 (SD)

720 x 576

25 or 30

50 or 60

  • H.264: 600 to 1400
  • H.265: 300 to 700

270p (smooth)

480 x 270

25 or 30

50 or 60

-

CIF P/N

352 x 288/320 x 240

25 or 30

50 or 60

  • H.264: 250
  • H.265: 250