API Call Sequence

For the Ascend 910 AI Processor, this function is not supported in the current version.

If video encoding is involved during app development, ensure that your app contains the code logic for such video encoding. For details about the API call sequence, see API Call Sequence. For details about the VENC functions, see Functions and Restrictions.

Figure 1 Video encoding

This module implements video encoding. The key APIs are described as follows:

  1. Call aclvencCreateChannel to create a video encoding channel.
    • Perform the following steps before creating a video encoding channel.
      1. Call aclvencCreateChannelDesc to create a channel description.
      2. Call aclvencSetChannelDescParam to set the channel description, including the thread, callback function, video coding protocol, and input image format.
        1. The callback function needs to be created by the user in advance. It is used to obtain the encoding output and destroy allocations in a timely manner. For details about the callback function prototype, see aclvencCallback.

          After the encoding is complete, free the input buffer and destroy the image description in the callback function in a timely manner. The output buffer is managed by the system, and therefore does not need to be freed by the user.

        2. The user needs to create a thread and define a thread function in advance. Once aclrtProcessReport is called in the thread function, the created callback function in 1.b.i will be triggered after a specified period of time.

        aclvencSetChannelDescParam is recommended for setting the channel description attributes. You can set a particular attribute by passing the corresponding enum value to this API call.

        The aclvencSetChannelDesc series of earlier versions are also supported, where each attribute is set using a separate API.

    • The following APIs are encapsulated in aclvencCreateChannel and do not need to be called separately:
      1. aclrtCreateStream: explicitly creates a stream. It is internally used by VENC.
      2. aclrtSubscribeReport: subscribes to a thread for handling the callback function in a stream. The callback function and thread are specified by the aclvencSetChannelDescParam call.
  2. Call aclvencSendFrame to encode YUV420SP images into an H.264/H.265 video stream.
  3. Call aclvencDestroyChannel to destroy the channel.
    • The channel is destroyed only after the transmitted frames are encoded and the callback function is processed.
    • The following APIs are encapsulated in aclvencDestroyChannel and do not need to be called separately:
    • After destroying the channel, call aclvencDestroyChannelDesc to destroy the channel description.
    • After destroying the channel description, destroy the thread created in 1.b.ii.