1e41f4b71Sopenharmony_ci# VideoEncoder
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci## Overview
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ciThe VideoEncoder module provides the APIs for video encoding.
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.VideoEncoder
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci**Since**: 9
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciThe following figures show the APIs supported by each version and the APIs that can be called in different states.
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci![meaning](figures/meaning.PNG)
15e41f4b71Sopenharmony_ci
16e41f4b71Sopenharmony_ci![desciption of encode api history](figures/video-encode-api.PNG)
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ci## Summary
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci### Files
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name| Description| 
24e41f4b71Sopenharmony_ci| -------- | -------- |
25e41f4b71Sopenharmony_ci| [native_avcodec_videoencoder.h](native__avcodec__videoencoder_8h.md) | Declares the APIs used for video encoding. |
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci### Types
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci| Name| Description| 
31e41f4b71Sopenharmony_ci| -------- | -------- |
32e41f4b71Sopenharmony_ci| typedef void(\* [OH_VideoEncoder_OnNeedInputParameter](#oh_videoencoder_onneedinputparameter)) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index, OH_AVFormat \*parameter, void \*userData) | Defines the pointer to the function that is called when new input parameters are required for a frame with the specified index. It takes effect only in surface mode. | 
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci### Enums
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci| Name| Description| 
37e41f4b71Sopenharmony_ci| -------- | -------- |
38e41f4b71Sopenharmony_ci| [OH_VideoEncodeBitrateMode](#oh_videoencodebitratemode) { CBR = 0, VBR = 1, CQ = 2 } | Enumerates the bit rate modes of a video encoder. | 
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci### Functions
42e41f4b71Sopenharmony_ci
43e41f4b71Sopenharmony_ci| Name| Description| 
44e41f4b71Sopenharmony_ci| -------- | -------- |
45e41f4b71Sopenharmony_ci| [OH_AVCodec](_codec_base.md#oh_avcodec) \* [OH_VideoEncoder_CreateByMime](#oh_videoencoder_createbymime) (const char \*mime) | Creates a video encoder instance based on a Multipurpose Internet Mail Extension (MIME) type. This function is recommended. |
46e41f4b71Sopenharmony_ci| [OH_AVCodec](_codec_base.md#oh_avcodec) \* [OH_VideoEncoder_CreateByName](#oh_videoencoder_createbyname) (const char \*name) | Creates a video encoder instance based on an encoder name. |
47e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Destroy](#oh_videoencoder_destroy) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Clears the internal resources of a video encoder and destroys the encoder instance. | 
48e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_SetCallback](#oh_videoencoder_setcallback) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) callback, void \*userData) | Sets an OH_AVCodecCallback callback so that your application can respond to events generated by a video encoder. (This function is deprecated in API version 11.) |
49e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_RegisterCallback](#oh_videoencoder_registercallback) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, [OH_AVCodecCallback](_o_h___a_v_codec_callback.md) callback, void \*userData) | Registers an OH_AVCodecCallback callback so that your application can respond to events generated by a video encoder. | 
50e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_RegisterParameterCallback](#oh_videoencoder_registerparametercallback) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, [OH_VideoEncoder_OnNeedInputParameter](#oh_videoencoder_onneedinputparameter) onInputParameter, void \*userData) | Registers an OH_AVCodecCallback input parameter callback so that your application can respond to events generated by a video encoder. | 
51e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Configure](#oh_videoencoder_configure) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, OH_AVFormat \*format) | Configures a video encoder. Typically, you need to configure the description information about the video track to be encoded, such as the width, height, and pixel format. |
52e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Prepare](#oh_videoencoder_prepare) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Prepares internal resources for a video encoder. | 
53e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Start](#oh_videoencoder_start) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Starts a video encoder. This function should be called after a successful call of **OH_VideoEncoder_Prepare**. |
54e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Stop](#oh_videoencoder_stop) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Stops a video encoder and releases the input and output buffers. |
55e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Flush](#oh_videoencoder_flush) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Clears the input and output data and parameters, for example, H.264 PPS/SPS, cached in a video encoder. |
56e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_Reset](#oh_videoencoder_reset) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Resets a video encoder. The encoder returns to the initial state. |
57e41f4b71Sopenharmony_ci| OH_AVFormat \* [OH_VideoEncoder_GetOutputDescription](#oh_videoencoder_getoutputdescription) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Obtains the OH_AVFormat information about the output data of a video encoder. |
58e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_SetParameter](#oh_videoencoder_setparameter) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, OH_AVFormat \*format) | Set the OH_AVFormat information when a video encoder is running. | 
59e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_GetSurface](#oh_videoencoder_getsurface) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, [OHNativeWindow](_codec_base.md#ohnativewindow) \*\*window) | Obtains the input surface from a video encoder. |
60e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_FreeOutputData](#oh_videoencoder_freeoutputdata) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index) | Frees an output buffer of a video encoder. (This function is deprecated in API version 11.)  |
61e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_NotifyEndOfStream](#oh_videoencoder_notifyendofstream) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Notifies a video encoder that input streams end. | 
62e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_PushInputData](#oh_videoencoder_pushinputdata) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) attr) | Pushes the input buffer filled with data to a video encoder. (This function is deprecated in API version 11.)  |
63e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_PushInputBuffer](#oh_videoencoder_pushinputbuffer) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index) | Pushes the OH_AVBuffer corresponding to the index to a video encoder in buffer mode. |
64e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_PushInputParameter](#oh_videoencoder_pushinputparameter) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index) | Pushes the parameter configured for a frame with the given index to a video encoder in surface mode. | 
65e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_FreeOutputBuffer](#oh_videoencoder_freeoutputbuffer) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, uint32_t index) | Returns the processed OH_AVBuffer corresponding to the index to a video encoder. | 
66e41f4b71Sopenharmony_ci| OH_AVFormat \* [OH_VideoEncoder_GetInputDescription](#oh_videoencoder_getinputdescription) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec) | Obtains the description of the image received by a video encoder. |
67e41f4b71Sopenharmony_ci| [OH_AVErrCode](_core.md#oh_averrcode) [OH_VideoEncoder_IsValid](#oh_videoencoder_isvalid) ([OH_AVCodec](_codec_base.md#oh_avcodec) \*codec, bool \*isValid) | Checks whether a video encoder instance is valid. | 
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci
70e41f4b71Sopenharmony_ci## Type Description
71e41f4b71Sopenharmony_ci
72e41f4b71Sopenharmony_ci### OH_VideoEncoder_OnNeedInputParameter
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci```
75e41f4b71Sopenharmony_citypedef void(* OH_VideoEncoder_OnNeedInputParameter) (OH_AVCodec *codec, uint32_t index, OH_AVFormat *parameter, void *userData)
76e41f4b71Sopenharmony_ci```
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci**Description**
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ciDefines the pointer to the function that is called when new input parameters are required for a frame with the specified index.
81e41f4b71Sopenharmony_ci
82e41f4b71Sopenharmony_ciThis callback can be used only in surface mode after it is registered by calling OH_VideoEncoder_RegisterParameterCallback.
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ciIn buffer mode, OH_AVBuffer can directly carry the encoding parameter associated with each frame. Currently, it can manage parameters, including **QPMin**, **QPMax**, and reference frames for Long Term Reference (LTR), on a per-frame basis.
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ci**Since**: 12
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci**Parameters**
91e41f4b71Sopenharmony_ci
92e41f4b71Sopenharmony_ci| Name| Description| 
93e41f4b71Sopenharmony_ci| -------- | -------- |
94e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
95e41f4b71Sopenharmony_ci| index | Index of the frame to encode. | 
96e41f4b71Sopenharmony_ci| parameter | Pointer to the encoding parameter | 
97e41f4b71Sopenharmony_ci| userData | Pointer to the data on which the caller depends when executing the callback. |
98e41f4b71Sopenharmony_ci
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ci## Enum Description
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci### OH_VideoEncodeBitrateMode
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci```
106e41f4b71Sopenharmony_cienum OH_VideoEncodeBitrateMode
107e41f4b71Sopenharmony_ci```
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**Description**
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ciEnumerates the bit rate modes of a video encoder.
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
114e41f4b71Sopenharmony_ci
115e41f4b71Sopenharmony_ci**Since**: 9
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci| Value| Description| 
118e41f4b71Sopenharmony_ci| -------- | -------- |
119e41f4b71Sopenharmony_ci| CBR  | Constant bit rate.  | 
120e41f4b71Sopenharmony_ci| VBR  | Variable bit rate.  | 
121e41f4b71Sopenharmony_ci| CQ  | Constant quality.  | 
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci## Function Description
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci### OH_VideoEncoder_Configure()
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci```
130e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Configure (OH_AVCodec *codec, OH_AVFormat *format )
131e41f4b71Sopenharmony_ci```
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci**Description**
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ciConfigures a video encoder. Typically, you need to configure the description information about the video track to be encoded, such as the width, height, and pixel format. This function must be called prior to **OH_VideoEncoder_Prepare**.
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ciThis function is used to verify the validity of configuration parameters. Some invalid parameters are not forcibly verified. The default values are used or discarded. Some invalid parameters are forcibly verified. The rules are as follows:
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciThe value ranges of the following parameters can be obtained from [Capability Query](../../media/avcodec/obtain-supported-codecs.md). All the values of **OH_MD_KEY_I_FRAME_INTERVAL** are supported.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ciIf the current platform does not support **OH_MD_KEY_VIDEO_ENCODER_ENABLE_TEMPORAL_SCALABILITY** or **OH_MD_KEY_VIDEO_ENCODER_LTR_FRAME_COUNT**, no error is reported and the normal encoding process is used.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ciParameter verification rules are as follows:
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci| Key                                                                       | Value Within the Range| Value Out of Range| No Value Configured|
146e41f4b71Sopenharmony_ci| ------------------------------------------------------------------------- | -------- | -------- | ------ |
147e41f4b71Sopenharmony_ci| OH_MD_KEY_WIDTH                                                           | AV_ERR_OK       | AV_ERR_INVALID_VAL       | AV_ERR_INVALID_VAL     |
148e41f4b71Sopenharmony_ci| OH_MD_KEY_HEIGHT                                                          | AV_ERR_OK       | AV_ERR_INVALID_VAL       | AV_ERR_INVALID_VAL     |
149e41f4b71Sopenharmony_ci| OH_MD_KEY_PIXEL_FORMAT<br>For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).| AV_ERR_OK       | AV_ERR_UNSUPPORT       | AV_ERR_OK    |
150e41f4b71Sopenharmony_ci| OH_MD_KEY_FRAME_RATE                                                       | AV_ERR_OK       | AV_ERR_INVALID_VAL       |AV_ERR_OK        |
151e41f4b71Sopenharmony_ci| OH_MD_KEY_PROFILE<br>For details, see [OH_MD_KEY_PROFILE](_codec_base.md#oh_md_key_profile).   | AV_ERR_OK       | AV_ERR_INVALID_VAL       |AV_ERR_OK       |
152e41f4b71Sopenharmony_ci| OH_MD_KEY_I_FRAME_INTERVAL                                                 | AV_ERR_OK       | \\       | AV_ERR_OK       |
153e41f4b71Sopenharmony_ci
154e41f4b71Sopenharmony_ci| OH_MD_KEY_<br>BITRATE | OH_MD_KEY_<br>QUALITY | OH_MD_KEY_<br>VIDEO_ENCODER_BITRATE_MODE | Return Value| Description                    |
155e41f4b71Sopenharmony_ci| :-------------------- | :-------------------- | :--------------------------------------- | ---- | ---------------------- |
156e41f4b71Sopenharmony_ci| \\                    | \\                    | \\                                       |  AV_ERR_OK    | The default value of the encoder is used.              |
157e41f4b71Sopenharmony_ci| Out of range                 | Out of range                 | Unsupported mode                                  | AV_ERR_INVALID_VAL   | An error is reported for all abnormal values.                |
158e41f4b71Sopenharmony_ci| Normal value                  | Normal value                  | \\                                       | AV_ERR_INVALID_VAL   | The bit rate conflicts with the quality.  |
159e41f4b71Sopenharmony_ci| Normal value                  | \\                    | \\                                       | AV_ERR_OK     | The default bit rate control mode is enabled.              |
160e41f4b71Sopenharmony_ci| Normal value                  | \\                    | VBR and CBR                                 | AV_ERR_OK     |                        |
161e41f4b71Sopenharmony_ci| Normal value                  | \\                    | CQ                                       | AV_ERR_INVALID_VAL   | The bit rate conflicts with the CQ mode.     |
162e41f4b71Sopenharmony_ci| \\                    | Normal value                  | \\                                       | AV_ERR_OK     | The CQ mode is enabled.              |
163e41f4b71Sopenharmony_ci| \\                    | Normal value                  | CQ                                       | AV_ERR_OK     |                        |
164e41f4b71Sopenharmony_ci| \\                    | Normal value                  | VBR and CBR                                 | AV_ERR_INVALID_VAL   | The quality conflicts with the VBR or CBR mode.|
165e41f4b71Sopenharmony_ci| \\                    | \\                    | VBR and CBR                                 | AV_ERR_OK     | The default bit rate of the encoder is used.             |
166e41f4b71Sopenharmony_ci| \\                    | \\                    | CQ                                       | AV_ERR_OK    | The default quality is used. |
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci**Since**: 9
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci**Parameters**
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci| Name| Description| 
176e41f4b71Sopenharmony_ci| -------- | -------- |
177e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
178e41f4b71Sopenharmony_ci| format | Pointer to an **OH_AVFormat** instance, which provides the description information about the video track to be encoded. | 
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci**Returns**
181e41f4b71Sopenharmony_ci
182e41f4b71Sopenharmony_ciReturns any of the following result codes:
183e41f4b71Sopenharmony_ci
184e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
185e41f4b71Sopenharmony_ci
186e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
187e41f4b71Sopenharmony_ci
188e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**:
189e41f4b71Sopenharmony_ci
190e41f4b71Sopenharmony_ci    1. The value of **codec** is a null pointer or does not point to an encoder instance.
191e41f4b71Sopenharmony_ci    2. The format is not supported.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is not called prior to **OH_VideoEncoder_Prepare**.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci### OH_VideoEncoder_CreateByMime()
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci```
203e41f4b71Sopenharmony_ciOH_AVCodec* OH_VideoEncoder_CreateByMime (const char *mime)
204e41f4b71Sopenharmony_ci```
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ci**Description**
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ciCreates a video encoder instance based on a MIME type. This function is recommended.
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**Since**: 9
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**Parameters**
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci| Name| Description| 
217e41f4b71Sopenharmony_ci| -------- | -------- |
218e41f4b71Sopenharmony_ci| mime | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](_codec_base.md#variables).| 
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**Returns**
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ciReturns the pointer to the video encoder instance created if the operation is successful; returns NULL if the encoder type is not supported or the memory is insufficient.
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci
225e41f4b71Sopenharmony_ci### OH_VideoEncoder_CreateByName()
226e41f4b71Sopenharmony_ci
227e41f4b71Sopenharmony_ci```
228e41f4b71Sopenharmony_ciOH_AVCodec* OH_VideoEncoder_CreateByName (const char *name)
229e41f4b71Sopenharmony_ci```
230e41f4b71Sopenharmony_ci
231e41f4b71Sopenharmony_ci**Description**
232e41f4b71Sopenharmony_ci
233e41f4b71Sopenharmony_ciCreates a video encoder instance based on an encoder name. Tho use this function, you must know the exact name of the encoder. The encoder name can be obtained through capability query.
234e41f4b71Sopenharmony_ci
235e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
236e41f4b71Sopenharmony_ci
237e41f4b71Sopenharmony_ci**Since**: 9
238e41f4b71Sopenharmony_ci
239e41f4b71Sopenharmony_ci**Parameters**
240e41f4b71Sopenharmony_ci
241e41f4b71Sopenharmony_ci| Name| Description| 
242e41f4b71Sopenharmony_ci| -------- | -------- |
243e41f4b71Sopenharmony_ci| name | Pointer to a video encoder name. | 
244e41f4b71Sopenharmony_ci
245e41f4b71Sopenharmony_ci**Returns**
246e41f4b71Sopenharmony_ci
247e41f4b71Sopenharmony_ciReturns the pointer to the video encoder instance created if the operation is successful; returns NULL if the encoder name is not supported or the memory is insufficient.
248e41f4b71Sopenharmony_ci
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci### OH_VideoEncoder_Destroy()
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci```
253e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Destroy (OH_AVCodec *codec)
254e41f4b71Sopenharmony_ci```
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**Description**
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ciClears the internal resources of a video encoder and destroys the encoder instance. You only need to call the function once.
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
261e41f4b71Sopenharmony_ci
262e41f4b71Sopenharmony_ci**Since**: 9
263e41f4b71Sopenharmony_ci
264e41f4b71Sopenharmony_ci**Parameters**
265e41f4b71Sopenharmony_ci
266e41f4b71Sopenharmony_ci| Name| Description| 
267e41f4b71Sopenharmony_ci| -------- | -------- |
268e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
269e41f4b71Sopenharmony_ci
270e41f4b71Sopenharmony_ci**Returns**
271e41f4b71Sopenharmony_ci
272e41f4b71Sopenharmony_ciReturns any of the following result codes:
273e41f4b71Sopenharmony_ci
274e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
275e41f4b71Sopenharmony_ci
276e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
277e41f4b71Sopenharmony_ci
278e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
279e41f4b71Sopenharmony_ci
280e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
281e41f4b71Sopenharmony_ci
282e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
283e41f4b71Sopenharmony_ci
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci### OH_VideoEncoder_Flush()
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci```
288e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Flush (OH_AVCodec *codec)
289e41f4b71Sopenharmony_ci```
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci**Description**
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ciClears the input and output data and parameters, for example, H.264 PPS/SPS, cached in a video encoder.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ciThis function invalidates the indexes of all buffers previously reported through the asynchronous callback. Therefore, before calling this function, ensure that the buffers with the specified indexes are no longer required. This function cannot be called consecutively.
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Since**: 9
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**Parameters**
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci| Name| Description| 
304e41f4b71Sopenharmony_ci| -------- | -------- |
305e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci**Returns**
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ciReturns any of the following result codes:
310e41f4b71Sopenharmony_ci
311e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci
324e41f4b71Sopenharmony_ci### OH_VideoEncoder_FreeOutputBuffer()
325e41f4b71Sopenharmony_ci
326e41f4b71Sopenharmony_ci```
327e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_FreeOutputBuffer (OH_AVCodec *codec, uint32_t index )
328e41f4b71Sopenharmony_ci```
329e41f4b71Sopenharmony_ci
330e41f4b71Sopenharmony_ci**Description**
331e41f4b71Sopenharmony_ci
332e41f4b71Sopenharmony_ciReturns the processed OH_AVBuffer corresponding to the index to a video encoder. You need to call this function to release the output buffer in a timely manner. Otherwise, the encoding process is blocked.
333e41f4b71Sopenharmony_ci
334e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
335e41f4b71Sopenharmony_ci
336e41f4b71Sopenharmony_ci**Since**: 11
337e41f4b71Sopenharmony_ci
338e41f4b71Sopenharmony_ci**Parameters**
339e41f4b71Sopenharmony_ci
340e41f4b71Sopenharmony_ci| Name| Description| 
341e41f4b71Sopenharmony_ci| -------- | -------- |
342e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
343e41f4b71Sopenharmony_ci| index | Index of the output buffer. The index is obtained from [OH_AVCodecOnNewOutputBuffer](_codec_base.md#oh_avcodeconnewoutputbuffer).|
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci**Returns**
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ciReturns any of the following result codes:
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**:
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci    1. The value of **codec** is a null pointer or does not point to an encoder instance.
356e41f4b71Sopenharmony_ci    2. The format is not supported.
357e41f4b71Sopenharmony_ci    3. The index is invalid or the same index is used consecutively. This error does not affect the subsequent encoding process.
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
360e41f4b71Sopenharmony_ci
361e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci### OH_VideoEncoder_GetInputDescription()
367e41f4b71Sopenharmony_ci
368e41f4b71Sopenharmony_ci```
369e41f4b71Sopenharmony_ciOH_AVFormat* OH_VideoEncoder_GetInputDescription (OH_AVCodec *codec)
370e41f4b71Sopenharmony_ci```
371e41f4b71Sopenharmony_ci
372e41f4b71Sopenharmony_ci**Description**
373e41f4b71Sopenharmony_ci
374e41f4b71Sopenharmony_ciObtains the description of the image received by a video encoder. This function must be called after [OH_VideoEncoder_Configure](#oh_videoencoder_configure) is called.
375e41f4b71Sopenharmony_ci
376e41f4b71Sopenharmony_ciThe caller must call [OH_AVFormat_Destroy](_core.md#oh_avformat_destroy) to manually release the **OH_AVFormat** instance in the return value.
377e41f4b71Sopenharmony_ci
378e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
379e41f4b71Sopenharmony_ci
380e41f4b71Sopenharmony_ci**Since**: 10
381e41f4b71Sopenharmony_ci
382e41f4b71Sopenharmony_ci**Parameters**
383e41f4b71Sopenharmony_ci
384e41f4b71Sopenharmony_ci| Name| Description| 
385e41f4b71Sopenharmony_ci| -------- | -------- |
386e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
387e41f4b71Sopenharmony_ci
388e41f4b71Sopenharmony_ci**Returns**
389e41f4b71Sopenharmony_ci
390e41f4b71Sopenharmony_ciReturns the pointer to an **OH_AVFormat** instance if the operation is successful; returns NULL if the value of **codec** is a null pointer or does not point to an encoder instance.
391e41f4b71Sopenharmony_ci
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ci### OH_VideoEncoder_GetOutputDescription()
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ci```
396e41f4b71Sopenharmony_ciOH_AVFormat* OH_VideoEncoder_GetOutputDescription (OH_AVCodec *codec)
397e41f4b71Sopenharmony_ci```
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**Description**
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ciObtains the OH_AVFormat information about the output data of a video encoder.
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ciThe caller must call **OH_AVFormat_Destroy()** to release the **OH_AVFormat** instance in the return value.
404e41f4b71Sopenharmony_ci
405e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci**Since**: 9
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ci**Parameters**
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ci| Name| Description| 
412e41f4b71Sopenharmony_ci| -------- | -------- |
413e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**Returns**
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ciReturns the pointer to an **OH_AVFormat** instance if the operation is successful; returns NULL if the value of **codec** is a null pointer or does not point to an encoder instance.
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci
420e41f4b71Sopenharmony_ci### OH_VideoEncoder_GetSurface()
421e41f4b71Sopenharmony_ci
422e41f4b71Sopenharmony_ci```
423e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_GetSurface (OH_AVCodec *codec, OHNativeWindow ** window )
424e41f4b71Sopenharmony_ci```
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci**Description**
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_ciSets an input surface for a video encoder. This function must be called prior to **OH_VideoEncoder_Prepare**.
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**Since**: 9
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**Parameters**
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci| Name| Description| 
437e41f4b71Sopenharmony_ci| -------- | -------- |
438e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
439e41f4b71Sopenharmony_ci| window | Pointer to an **OHNativeWindow** instance. For details, see [OHNativeWindow](_codec_base.md#ohnativewindow). The application manages the lifecycle of the window and calls **OH_NativeWindow_DestroyNativeWindow** to release the window when the lifecycle ends. | 
440e41f4b71Sopenharmony_ci
441e41f4b71Sopenharmony_ci**Returns**
442e41f4b71Sopenharmony_ci
443e41f4b71Sopenharmony_ciReturns any of the following result codes:
444e41f4b71Sopenharmony_ci
445e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
446e41f4b71Sopenharmony_ci
447e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
448e41f4b71Sopenharmony_ci
449e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
450e41f4b71Sopenharmony_ci
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci### OH_VideoEncoder_IsValid()
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci```
455e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_IsValid (OH_AVCodec *codec, bool *isValid )
456e41f4b71Sopenharmony_ci```
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci**Description**
459e41f4b71Sopenharmony_ci
460e41f4b71Sopenharmony_ciChecks whether a video encoder instance is valid.
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_ci**Since**: 10
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ci**Parameters**
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ci| Name| Description| 
469e41f4b71Sopenharmony_ci| -------- | -------- |
470e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
471e41f4b71Sopenharmony_ci| isValid | Pointer of the Boolean type. The value **true** means that the encoder instance is valid and **false** means the opposite. It is recommended that the caller initialize **isValid** to **false**. |
472e41f4b71Sopenharmony_ci
473e41f4b71Sopenharmony_ci**Returns**
474e41f4b71Sopenharmony_ci
475e41f4b71Sopenharmony_ciReturns either of the following result codes:
476e41f4b71Sopenharmony_ci
477e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
478e41f4b71Sopenharmony_ci
479e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
480e41f4b71Sopenharmony_ci
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci### OH_VideoEncoder_NotifyEndOfStream()
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_ci```
485e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_NotifyEndOfStream (OH_AVCodec *codec)
486e41f4b71Sopenharmony_ci```
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**Description**
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ciNotifies a video encoder that input streams end. You are advised to use this function for notification. This function is used only in surface mode. In buffer mode, OH_AVBuffer is used to carry the EOS information to notify the end of the input stream.
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci**Since**: 9
495e41f4b71Sopenharmony_ci
496e41f4b71Sopenharmony_ci**Parameters**
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ci| Name| Description| 
499e41f4b71Sopenharmony_ci| -------- | -------- |
500e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ci**Returns**
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ciReturns any of the following result codes:
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
513e41f4b71Sopenharmony_ci
514e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci
519e41f4b71Sopenharmony_ci### OH_VideoEncoder_Prepare()
520e41f4b71Sopenharmony_ci
521e41f4b71Sopenharmony_ci```
522e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Prepare (OH_AVCodec *codec)
523e41f4b71Sopenharmony_ci```
524e41f4b71Sopenharmony_ci
525e41f4b71Sopenharmony_ci**Description**
526e41f4b71Sopenharmony_ci
527e41f4b71Sopenharmony_ciPrepares internal resources for a video encoder. This function must be called after **OH_VideoEncoder_Configure**.
528e41f4b71Sopenharmony_ci
529e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
530e41f4b71Sopenharmony_ci
531e41f4b71Sopenharmony_ci**Since**: 9
532e41f4b71Sopenharmony_ci
533e41f4b71Sopenharmony_ci**Parameters**
534e41f4b71Sopenharmony_ci
535e41f4b71Sopenharmony_ci| Name| Description| 
536e41f4b71Sopenharmony_ci| -------- | -------- |
537e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci**Returns**
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ciReturns any of the following result codes:
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
546e41f4b71Sopenharmony_ci
547e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
548e41f4b71Sopenharmony_ci
549e41f4b71Sopenharmony_ci
550e41f4b71Sopenharmony_ci### OH_VideoEncoder_PushInputBuffer()
551e41f4b71Sopenharmony_ci
552e41f4b71Sopenharmony_ci```
553e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputBuffer (OH_AVCodec *codec, uint32_t index )
554e41f4b71Sopenharmony_ci```
555e41f4b71Sopenharmony_ci
556e41f4b71Sopenharmony_ci**Description**
557e41f4b71Sopenharmony_ci
558e41f4b71Sopenharmony_ciPushes the OH_AVBuffer corresponding to the index to a video encoder in buffer mode.
559e41f4b71Sopenharmony_ci
560e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
561e41f4b71Sopenharmony_ci
562e41f4b71Sopenharmony_ci**Since**: 11
563e41f4b71Sopenharmony_ci
564e41f4b71Sopenharmony_ci**Parameters**
565e41f4b71Sopenharmony_ci
566e41f4b71Sopenharmony_ci| Name| Description| 
567e41f4b71Sopenharmony_ci| -------- | -------- |
568e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
569e41f4b71Sopenharmony_ci| index | Index of the input buffer. The index is obtained from [OH_AVCodecOnNeedInputBuffer](_codec_base.md#oh_avcodeconneedinputbuffer).| 
570e41f4b71Sopenharmony_ci
571e41f4b71Sopenharmony_ci**Returns**
572e41f4b71Sopenharmony_ci
573e41f4b71Sopenharmony_ciReturns any of the following result codes:
574e41f4b71Sopenharmony_ci
575e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**:
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci    1. The value of **codec** is a null pointer or does not point to an encoder instance.
582e41f4b71Sopenharmony_ci    2. The format is not supported.
583e41f4b71Sopenharmony_ci
584e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
585e41f4b71Sopenharmony_ci
586e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ci
591e41f4b71Sopenharmony_ci### OH_VideoEncoder_PushInputParameter()
592e41f4b71Sopenharmony_ci
593e41f4b71Sopenharmony_ci```
594e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputParameter (OH_AVCodec *codec, uint32_t index)
595e41f4b71Sopenharmony_ci```
596e41f4b71Sopenharmony_ci
597e41f4b71Sopenharmony_ci**Description**
598e41f4b71Sopenharmony_ci
599e41f4b71Sopenharmony_ciPushes the parameter configured for a frame with the given index to a video encoder in surface mode.
600e41f4b71Sopenharmony_ci
601e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
602e41f4b71Sopenharmony_ci
603e41f4b71Sopenharmony_ci**Since**: 12
604e41f4b71Sopenharmony_ci
605e41f4b71Sopenharmony_ci**Parameters**
606e41f4b71Sopenharmony_ci
607e41f4b71Sopenharmony_ci| Name| Description| 
608e41f4b71Sopenharmony_ci| -------- | -------- |
609e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
610e41f4b71Sopenharmony_ci| index | Index of the input parameter buffer. The index is obtained from [OH_VideoEncoder_OnNeedInputParameter](#oh_videoencoder_onneedinputparameter). | 
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ci**Returns**
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ciReturns any of the following result codes:
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
621e41f4b71Sopenharmony_ci
622e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ci
629e41f4b71Sopenharmony_ci### OH_VideoEncoder_RegisterCallback()
630e41f4b71Sopenharmony_ci
631e41f4b71Sopenharmony_ci```
632e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_RegisterCallback (OH_AVCodec *codec, OH_AVCodecCallback callback, void *userData )
633e41f4b71Sopenharmony_ci```
634e41f4b71Sopenharmony_ci
635e41f4b71Sopenharmony_ci**Description**
636e41f4b71Sopenharmony_ci
637e41f4b71Sopenharmony_ciRegisters an OH_AVCodecCallback callback so that your application can respond to events generated by a video encoder. This function must be called prior to **OH_VideoEncoder_Prepare**.
638e41f4b71Sopenharmony_ci
639e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
640e41f4b71Sopenharmony_ci
641e41f4b71Sopenharmony_ci**Since**: 11
642e41f4b71Sopenharmony_ci
643e41f4b71Sopenharmony_ci**Parameters**
644e41f4b71Sopenharmony_ci
645e41f4b71Sopenharmony_ci| Name| Description| 
646e41f4b71Sopenharmony_ci| -------- | -------- |
647e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
648e41f4b71Sopenharmony_ci| callback | Callback function to set. For details, see [OH_AVCodecCallback](_o_h___a_v_codec_callback.md). | 
649e41f4b71Sopenharmony_ci| userData | Pointer to the data on which the caller depends when executing the callback. | 
650e41f4b71Sopenharmony_ci
651e41f4b71Sopenharmony_ci**Returns**
652e41f4b71Sopenharmony_ci
653e41f4b71Sopenharmony_ciReturns any of the following result codes:
654e41f4b71Sopenharmony_ci
655e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
656e41f4b71Sopenharmony_ci
657e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
658e41f4b71Sopenharmony_ci
659e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
660e41f4b71Sopenharmony_ci
661e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
662e41f4b71Sopenharmony_ci
663e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
664e41f4b71Sopenharmony_ci
665e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is not called prior to **OH_VideoEncoder_Prepare**.
666e41f4b71Sopenharmony_ci
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci### OH_VideoEncoder_RegisterParameterCallback()
669e41f4b71Sopenharmony_ci
670e41f4b71Sopenharmony_ci```
671e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_RegisterParameterCallback (OH_AVCodec *codec, OH_VideoEncoder_OnNeedInputParameter onInputParameter, void *userData)
672e41f4b71Sopenharmony_ci```
673e41f4b71Sopenharmony_ci
674e41f4b71Sopenharmony_ci**Description**
675e41f4b71Sopenharmony_ci
676e41f4b71Sopenharmony_ciRegisters an OH_AVCodecCallback input parameter callback so that your application can respond to events generated by a video encoder. In surface encoding mode, this function must be called when frame parameters need to be set, and it must be called before [OH_VideoEncoder_Configure](#oh_videoencoder_configure).
677e41f4b71Sopenharmony_ci
678e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
679e41f4b71Sopenharmony_ci
680e41f4b71Sopenharmony_ci**Since**: 12
681e41f4b71Sopenharmony_ci
682e41f4b71Sopenharmony_ci**Parameters**
683e41f4b71Sopenharmony_ci
684e41f4b71Sopenharmony_ci| Name| Description| 
685e41f4b71Sopenharmony_ci| -------- | -------- |
686e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
687e41f4b71Sopenharmony_ci| onInputParameter | Pointer to the input parameter callback. For details, see [OH_VideoEncoder_OnNeedInputParameter](#oh_videoencoder_onneedinputparameter). | 
688e41f4b71Sopenharmony_ci| userData | Pointer to the data on which the caller depends when executing the callback. |
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci**Returns**
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_ciReturns any of the following result codes:
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
703e41f4b71Sopenharmony_ci
704e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is not called prior to **OH_VideoEncoder_Prepare**.
705e41f4b71Sopenharmony_ci
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci### OH_VideoEncoder_Reset()
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_ci```
710e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Reset (OH_AVCodec *codec)
711e41f4b71Sopenharmony_ci```
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci**Description**
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ciResets a video encoder. The encoder returns to the initial state. To continue encoding, you must call **OH_VideoEncoder_Configure** to configure the encoder again.
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci**Since**: 9
720e41f4b71Sopenharmony_ci
721e41f4b71Sopenharmony_ci**Parameters**
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci| Name| Description| 
724e41f4b71Sopenharmony_ci| -------- | -------- |
725e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ci**Returns**
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ciReturns any of the following result codes:
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
736e41f4b71Sopenharmony_ci
737e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_ci
742e41f4b71Sopenharmony_ci### OH_VideoEncoder_SetParameter()
743e41f4b71Sopenharmony_ci
744e41f4b71Sopenharmony_ci```
745e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_SetParameter (OH_AVCodec *codec, OH_AVFormat *format )
746e41f4b71Sopenharmony_ci```
747e41f4b71Sopenharmony_ci
748e41f4b71Sopenharmony_ci**Description**
749e41f4b71Sopenharmony_ci
750e41f4b71Sopenharmony_ciSet the OH_AVFormat information when a video encoder is running.
751e41f4b71Sopenharmony_ci
752e41f4b71Sopenharmony_ciThis function can be called only after the encoder is started. Incorrect parameter settings may cause encoding failure.
753e41f4b71Sopenharmony_ci
754e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
755e41f4b71Sopenharmony_ci
756e41f4b71Sopenharmony_ci**Since**: 9
757e41f4b71Sopenharmony_ci
758e41f4b71Sopenharmony_ci**Parameters**
759e41f4b71Sopenharmony_ci
760e41f4b71Sopenharmony_ci| Name| Description| 
761e41f4b71Sopenharmony_ci| -------- | -------- |
762e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
763e41f4b71Sopenharmony_ci| format | Pointer to an **OH_AVFormat** instance. | 
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci**Returns**
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ciReturns any of the following result codes:
768e41f4b71Sopenharmony_ci
769e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**:
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ci    1. The value of **codec** is a null pointer or does not point to an encoder instance.
776e41f4b71Sopenharmony_ci    2. The format is not supported.
777e41f4b71Sopenharmony_ci
778e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
779e41f4b71Sopenharmony_ci
780e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
781e41f4b71Sopenharmony_ci
782e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
783e41f4b71Sopenharmony_ci
784e41f4b71Sopenharmony_ci
785e41f4b71Sopenharmony_ci### OH_VideoEncoder_Start()
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci```
788e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Start (OH_AVCodec *codec)
789e41f4b71Sopenharmony_ci```
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci**Description**
792e41f4b71Sopenharmony_ci
793e41f4b71Sopenharmony_ciStarts a video encoder. This function should be called after a successful call of **OH_VideoEncoder_Prepare**. After being started, the encoder starts to report the registered event.
794e41f4b71Sopenharmony_ci
795e41f4b71Sopenharmony_ciIn surface mode, when there is a correct input on the surface, **OnNewOutputBuffer** is triggered each time a frame is encoded.
796e41f4b71Sopenharmony_ci
797e41f4b71Sopenharmony_ciIn buffer mode, the encoder immediately triggers the input callback. Each time the caller completes an input, the encoder performs encoding. **OnNewOutputBuffer** is triggered each time a frame is encoded.
798e41f4b71Sopenharmony_ci
799e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
800e41f4b71Sopenharmony_ci
801e41f4b71Sopenharmony_ci**Since**: 9
802e41f4b71Sopenharmony_ci
803e41f4b71Sopenharmony_ci**Parameters**
804e41f4b71Sopenharmony_ci
805e41f4b71Sopenharmony_ci| Name| Description| 
806e41f4b71Sopenharmony_ci| -------- | -------- |
807e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
808e41f4b71Sopenharmony_ci
809e41f4b71Sopenharmony_ci**Returns**
810e41f4b71Sopenharmony_ci
811e41f4b71Sopenharmony_ciReturns any of the following result codes:
812e41f4b71Sopenharmony_ci
813e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
814e41f4b71Sopenharmony_ci
815e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
816e41f4b71Sopenharmony_ci
817e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
818e41f4b71Sopenharmony_ci
819e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
820e41f4b71Sopenharmony_ci
821e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
822e41f4b71Sopenharmony_ci
823e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
824e41f4b71Sopenharmony_ci
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ci### OH_VideoEncoder_Stop()
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci```
829e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_Stop (OH_AVCodec *codec)
830e41f4b71Sopenharmony_ci```
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci**Description**
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_ciStops a video encoder and releases the input and output buffers. After the video encoder is stopped, you can call **OH_VideoEncoder_Start** to enter the running state again.
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci**Since**: 9
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ci**Parameters**
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci| Name| Description| 
843e41f4b71Sopenharmony_ci| -------- | -------- |
844e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
845e41f4b71Sopenharmony_ci
846e41f4b71Sopenharmony_ci**Returns**
847e41f4b71Sopenharmony_ci
848e41f4b71Sopenharmony_ciReturns any of the following result codes:
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
851e41f4b71Sopenharmony_ci
852e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
853e41f4b71Sopenharmony_ci
854e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
855e41f4b71Sopenharmony_ci
856e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
861e41f4b71Sopenharmony_ci
862e41f4b71Sopenharmony_ci
863e41f4b71Sopenharmony_ci## Description of Deprecated Functions
864e41f4b71Sopenharmony_ci
865e41f4b71Sopenharmony_ci
866e41f4b71Sopenharmony_ci### OH_VideoEncoder_SetCallback()
867e41f4b71Sopenharmony_ci
868e41f4b71Sopenharmony_ci```
869e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_SetCallback (OH_AVCodec *codec, OH_AVCodecAsyncCallback callback, void *userData )
870e41f4b71Sopenharmony_ci```
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ci**Description**
873e41f4b71Sopenharmony_ci
874e41f4b71Sopenharmony_ciSets an OH_AVCodecCallback callback so that your application can respond to events generated by a video encoder. This function must be called prior to **OH_VideoEncoder_Prepare**.
875e41f4b71Sopenharmony_ci
876e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
877e41f4b71Sopenharmony_ci
878e41f4b71Sopenharmony_ci**Since**: 9
879e41f4b71Sopenharmony_ci
880e41f4b71Sopenharmony_ci**Deprecated from**: 11
881e41f4b71Sopenharmony_ci
882e41f4b71Sopenharmony_ci**Substitute API**: [OH_VideoEncoder_RegisterCallback](#oh_videoencoder_registercallback)
883e41f4b71Sopenharmony_ci
884e41f4b71Sopenharmony_ci**Parameters**
885e41f4b71Sopenharmony_ci
886e41f4b71Sopenharmony_ci| Name| Description| 
887e41f4b71Sopenharmony_ci| -------- | -------- |
888e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
889e41f4b71Sopenharmony_ci| callback | Callback function to set. For details, see [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md). | 
890e41f4b71Sopenharmony_ci| userData | Pointer to the data on which the caller depends when executing the callback. |
891e41f4b71Sopenharmony_ci
892e41f4b71Sopenharmony_ci**Returns**
893e41f4b71Sopenharmony_ci
894e41f4b71Sopenharmony_ciReturns any of the following result codes:
895e41f4b71Sopenharmony_ci
896e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
897e41f4b71Sopenharmony_ci
898e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
899e41f4b71Sopenharmony_ci
900e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
901e41f4b71Sopenharmony_ci
902e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
903e41f4b71Sopenharmony_ci
904e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
905e41f4b71Sopenharmony_ci
906e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is not called prior to **OH_VideoEncoder_Prepare**.
907e41f4b71Sopenharmony_ci
908e41f4b71Sopenharmony_ci
909e41f4b71Sopenharmony_ci### OH_VideoEncoder_PushInputData()
910e41f4b71Sopenharmony_ci
911e41f4b71Sopenharmony_ci```
912e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_PushInputData (OH_AVCodec *codec, uint32_t index, OH_AVCodecBufferAttr attr )
913e41f4b71Sopenharmony_ci```
914e41f4b71Sopenharmony_ci
915e41f4b71Sopenharmony_ci**Description**
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ciPushes the input buffer filled with data to a video encoder.
918e41f4b71Sopenharmony_ci
919e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
920e41f4b71Sopenharmony_ci
921e41f4b71Sopenharmony_ci**Since**: 10
922e41f4b71Sopenharmony_ci
923e41f4b71Sopenharmony_ci**Deprecated from**: 11
924e41f4b71Sopenharmony_ci
925e41f4b71Sopenharmony_ci**Substitute API**: [OH_VideoEncoder_PushInputBuffer](#oh_videoencoder_pushinputbuffer)
926e41f4b71Sopenharmony_ci
927e41f4b71Sopenharmony_ci**Parameters**
928e41f4b71Sopenharmony_ci
929e41f4b71Sopenharmony_ci| Name| Description| 
930e41f4b71Sopenharmony_ci| -------- | -------- |
931e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
932e41f4b71Sopenharmony_ci| index | Index of the input buffer. The index is obtained from [OH_AVCodecOnNeedInputData](_codec_base.md#oh_avcodeconneedinputdata). | 
933e41f4b71Sopenharmony_ci| attr | Description of the data contained in the buffer. | 
934e41f4b71Sopenharmony_ci
935e41f4b71Sopenharmony_ci**Returns**
936e41f4b71Sopenharmony_ci
937e41f4b71Sopenharmony_ciReturns any of the following result codes:
938e41f4b71Sopenharmony_ci
939e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
940e41f4b71Sopenharmony_ci
941e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
942e41f4b71Sopenharmony_ci
943e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
944e41f4b71Sopenharmony_ci
945e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
946e41f4b71Sopenharmony_ci
947e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
948e41f4b71Sopenharmony_ci
949e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
950e41f4b71Sopenharmony_ci
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci### OH_VideoEncoder_FreeOutputData()
953e41f4b71Sopenharmony_ci
954e41f4b71Sopenharmony_ci```
955e41f4b71Sopenharmony_ciOH_AVErrCode OH_VideoEncoder_FreeOutputData (OH_AVCodec *codec, uint32_t index )
956e41f4b71Sopenharmony_ci```
957e41f4b71Sopenharmony_ci
958e41f4b71Sopenharmony_ci**Description**
959e41f4b71Sopenharmony_ci
960e41f4b71Sopenharmony_ciFrees an output buffer of a video encoder.
961e41f4b71Sopenharmony_ci
962e41f4b71Sopenharmony_ci**System capability**: SystemCapability.Multimedia.Media.VideoEncoder
963e41f4b71Sopenharmony_ci
964e41f4b71Sopenharmony_ci**Since**: 9
965e41f4b71Sopenharmony_ci
966e41f4b71Sopenharmony_ci**Deprecated from**: 11
967e41f4b71Sopenharmony_ci
968e41f4b71Sopenharmony_ciSubstitute API: [OH_VideoEncoder_FreeOutputBuffer](#oh_videoencoder_freeoutputbuffer)
969e41f4b71Sopenharmony_ci
970e41f4b71Sopenharmony_ci**Parameters**
971e41f4b71Sopenharmony_ci
972e41f4b71Sopenharmony_ci| Name| Description| 
973e41f4b71Sopenharmony_ci| -------- | -------- |
974e41f4b71Sopenharmony_ci| codec | Pointer to a video encoder instance. | 
975e41f4b71Sopenharmony_ci| index | Index of the output buffer. The index is obtained from [OH_AVCodecOnNewOutputData](_codec_base.md#oh_avcodeconnewoutputdata). | 
976e41f4b71Sopenharmony_ci
977e41f4b71Sopenharmony_ci**Returns**
978e41f4b71Sopenharmony_ci
979e41f4b71Sopenharmony_ciReturns any of the following result codes:
980e41f4b71Sopenharmony_ci
981e41f4b71Sopenharmony_ci**AV_ERR_OK**: The operation is successful.
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci**AV_ERR_NO_MEMORY**: An internal exception occurs in the encoder instance, for example, a null pointer internally.
984e41f4b71Sopenharmony_ci
985e41f4b71Sopenharmony_ci**AV_ERR_INVALID_VAL**: The value of **codec** is a null pointer or does not point to an encoder instance.
986e41f4b71Sopenharmony_ci
987e41f4b71Sopenharmony_ci**AV_ERR_UNKNOWN**: An unknown error occurs.
988e41f4b71Sopenharmony_ci
989e41f4b71Sopenharmony_ci**AV_ERR_OPERATE_NOT_PERMIT**: An internal execution error occurs.
990e41f4b71Sopenharmony_ci
991e41f4b71Sopenharmony_ci**AV_ERR_INVALID_STATE**: The function is called in an incorrect state.
992