venc_set_chn_attr
Applicability
Product |
Supported (√/x) |
|---|---|
x |
|
x |
|
x |
|
√ |
|
√ |
Function Usage
Sets the attributes of an encoding channel.
Prototype
- C Prototype
1hi_s32 hi_mpi_venc_set_chn_attr(hi_venc_chn chn, const hi_venc_chn_attr *chn_attr);
- Python Function
1ret = acl.himpi.venc_set_chn_attr(chn, chn_attr)
Parameter Description
Parameter |
Description |
|---|---|
chn |
Int, encoding channel ID.
|
chn_attr |
Dict, encoding channel attribute. For details, see hi_venc_chn_attr. |
Return Value Description
Return Value |
Description |
|---|---|
ret |
Int, error code.
|
Restrictions
- Only H.264/H.265 encoding channels support this API.
- It is recommended that acl.himpi.venc_get_chn_attr be called before this API to obtain the attributes of the current encoding channel.
- Encoding channel attributes include the encoder attribute, frame structure GOP attribute, and RC attribute.
The attributes of a VENC channel are classified into dynamic attributes and static attributes. The static attributes are configured when the VENC channel is created and cannot be modified after the VENC channel is created. The values of the dynamic attributes are configured when a channel is created. Some parameters cannot be modified. The parameters that can be modified can be modified before the channel is destroyed.
Error codes are returned if you set static attributes or modify parameters that cannot be modified. For details about static attributes, whether they are modifiable, and attribute value ranges, see hi_venc_chn_attr.
- If gop_mode is not changed when configuring encoding channel attributes, the channel attributes take effect immediately. If gop_mode is changed, the channel attributes will take effect after a delay. The following lists the maximum delays (the HI_VENC_GOP_MODE_LOW_DELAY_B mode is not supported currently).
- After the HI_VENC_GOP_MODE_LOW_DELAY_B mode is changed to the non-HI_VENC_GOP_MODE_LOW_DELAY_B mode, the maximum delay change (using the number of encoded frames as the unit) is 1 + b_frame_num.
- After the non-HI_VENC_GOP_MODE_LOW_DELAY_B mode is changed to the other modes, the maximum delay change (using the number of encoded frames as the unit) is 1.
- When changing the gop_mode, the I-slice refreshing for P-frames, frame skipping reference attributes (H.264/H.265), and pic_order_cnt_type (H.264 ) of the channel are restored to the default values. You need to re-configure them for further use.
- If either the GOP or RC attribute is modified, the RC module is reinitialized, and all advanced RC parameters are restored to default values. If advanced parameters of the RC are adjusted in the client program, you need to set the parameters again. For details about the advanced parameters of the RC, see acl.himpi.venc_set_rc_param.
- If gop_mode and rc_mode are modified at the same time, the modification may take effect with a delay (see the preceding table). It is recommended that you do not perform any operation until the parameters take effect after the delay. Otherwise the RC parameter value obtained by calling acl.himpi.venc_get_rc_param may be inaccurate.
- By calling this API, you can change the channel width (pic_width) and height (pic_height) during video encoding. However, you need to note the following:
- When you change the width and height by calling this API, the system discards the video data that is not completely encoded. As a result, part of the video data is lost.
- After this API is called to change the width and height, the values of width and height delivered by hi_mpi_venc_send_frame must be the same as the values of pic_width and pic_height.
- If you change the width and height between an hi_mpi_venc_get_stream call and an hi_mpi_venc_release_stream call, the HI_ERR_VENC_ILLEGAL_PARAM error code will be returned when hi_mpi_venc_release_stream releases the received stream.