VideoEncodeConfig
Description
Stores video encoding parameters.
Structure Definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | struct VideoEncodeConfig { uint32_t maxPicWidth = 4096; uint32_t maxPicHeight = 4096; uint32_t width = 1920; uint32_t height = 1080; StreamFormat outputVideoFormat = StreamFormat::H264_MAIN_LEVEL; ImageFormat inputImageFormat = ImageFormat::YUV_SP_420; VideoEncodeCallBack callbackFunc = nullptr; uint32_t keyFrameInterval = 30; uint32_t srcRate = 30; uint32_t rcMode = 0; uint32_t shortTermStatsTime = 60; uint32_t longTermStatsTime = 120; uint32_t longTermMaxBitRate = 300; uint32_t longTermMinBitRate = 0; uint32_t maxBitRate = 300; uint32_t ipProp = 70; uint32_t sceneMode = 0; uint32_t displayRate = 30; uint32_t statsTime = 1; uint32_t firstFrameStartQp = 32; std::vector<uint32_t> thresholdI = {0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255}; std::vector<uint32_t> thresholdP = {0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255}; std::vector<uint32_t> thresholdB = {0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255}; uint32_t direction = 8; uint32_t rowQpDelta = 1; }; |
Parameters
Parameter |
Description |
|---|---|
maxPicWidth |
Maximum reserved width of an encoding channel, in pixels. The value range is [128, 4096]. The default value is 4096. It must be greater than width. Currently, only Atlas inference product support this parameter. |
maxPicHeight |
Maximum reserved height of an encoding channel, in pixels. The value range is [128, 4096]. The default value is 4096. It must be greater than height. Currently, only Atlas inference product support this parameter. |
width |
Width of the encoded video frame data. The value must be the same as the width (originalSize) of the image to be encoded. The default value is 1920.
|
height |
Height of the encoded video frame data. The value must be the same as the height (originalSize) of the image to be encoded. The default value is 1080.
|
outputVideoFormat |
Output video format after encoding. The default value is StreamFormat::H264_MAIN_LEVEL. |
inputImageFormat |
Input image format. The default value is ImageFormat::YUV_SP_420.
|
callbackFunc |
Callback function after encoding. It cannot be a null pointer. |
keyFrameInterval |
I-frame interval. The default value is 30.
|
srcRate |
Frame rate of input streams, in fps. The default value is 30.
|
rcMode |
Bit rate control mode.
|
shortTermStatsTime |
Short-term statistical time of the bit rate, in seconds. The value range is [1, 120]. The default value is 60. This parameter takes effect only when rcMode is set to 5 on Atlas inference product. |
longTermStatsTime |
Long-term statistical time of the bit rate, in minutes. The value range is [1, 1440]. The default value is 120. This parameter takes effect only when rcMode is set to 5 on Atlas inference product. |
longTermMaxBitRate |
Maximum long-term output bit rate of the encoder, in kbps. The default value is 300. Value range: [2, maxBitRate]. This parameter takes effect only when rcMode is set to 5 on Atlas inference product. |
longTermMinBitRate |
Minimum long-term output bit rate of the encoder, in kbps. The default value is 0. Value range: [0, longTermMaxBitRate]. This parameter takes effect only when rcMode is set to 5 on Atlas inference product. |
maxBitRate |
Output bit rate, in kbps. The default value is 300.
|
ipProp |
I-frame to P-frame bit allocation ratio within a GOP. The value range is [1, 100]. The default value is 70. |
sceneMode |
Scene mode.
This parameter takes effect only on Atlas inference product. NOTE:
When the output video format is set to H.264 and sceneMode is set to 1, the value of sceneMode is automatically switched to 0 because H.264 does not support motion scenes where the bit rate is high. |
displayRate |
Frame rate for playing the output video. The value range is [1, 120]. The default value is 30. This parameter takes effect only on Atlas inference product. |
statsTime |
Bit rate statistical time, in seconds. The value range is [1, 60]. The default value is 1. This parameter takes effect only on Atlas inference product. |
firstFrameStartQp |
Start QP value of the first frame. The default value is 32. Different modes have different value ranges:
This parameter takes effect only on Atlas inference product. |
thresholdI |
MADi threshold for the macroblock-level bit rate of I-frames, used to measure the spatial texture complexity of the current frame. The value range is [0, 255]. The default value is [0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255]. If the value of the subtraction direction is set to 0 or the value of the addition direction is set to 255, the current profile is disabled. This parameter takes effect only on Atlas inference product. |
thresholdP |
MADi threshold for the macroblock-level bit rate of P-frames, used to measure the spatial texture complexity of the current frame. The value range is [0, 255]. The default value is [0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255]. If the value of the subtraction direction is set to 0 or the value of the addition direction is set to 255, the current profile is disabled. This parameter takes effect only on Atlas inference product. |
thresholdB |
MADi threshold for the macroblock-level bit rate of B-frames, used to measure the spatial texture complexity of the current frame. The value range is [0, 255]. The default value is [0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255]. If the value of the subtraction direction is set to 0 or the value of the addition direction is set to 255, the current profile is disabled. This parameter takes effect only on Atlas inference product. |
direction |
Addition or subtraction direction control during texture-based macroblock-level bit rate control The value range is [0, 16]. The default value is 8. This parameter takes effect only on Atlas inference product. |
rowQpDelta |
Maximum row-level adjustment range within one frame. The unit is the macroblock row. A larger adjustment amplitude indicates that the allowed QP row-level adjustment range is larger and the bit rate is more stable. In the scenarios where the image complexity is unevenly distributed, the image quality may be uneven if the value of this parameter is too large. The value range is [0, 10]. The default value is 1. If the value is set to 0, row-based macroblock-level bit rate control is disabled. This parameter takes effect only on Atlas inference product. |
Recommended Configuration
The following table lists the recommended parameter settings that ensure good video encoding quality during video capture. In other scenarios, adjust the parameter settings as required.
Image Quality/Resolution |
srcRate |
keyFrameInterval |
maxBitRate |
|---|---|---|---|
4K 3840 x 2160/4096 x 2160 |
25 or 30 |
50 or 60 |
|
2K 2560 x 1440 |
25 or 30 |
50 or 60 |
|
1080p (Blu-ray) 1920 x 1080 |
25 or 30 |
50 or 60 |
|
720p (HD) 1280 x 720 |
25 or 30 |
50 or 60 |
|
480p/D1_N (SD) 854 x 480/720 x 480 |
25 or 30 |
50 or 60 |
|
576P/D1 (SD) 720 x 576 |
25 or 30 |
50 or 60 |
|
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 |
|