openharmony 鸿蒙 capi-avtranscoder-h

2026-08-25 浏览 (1)

avtranscoder.h

Overview

The file declares the native APIs provided by the AVTranscoder. You can use the APIs to transcode a source video file into a new video file.

File to include: <multimedia/player_framework/avtranscoder.h>

Library: libavtranscoder.so

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Related module: AVTranscoder

Sample: AVPlayerNDKVideo

Summary

Functions

NameDescription
OH_AVTranscoder_Config *OH_AVTranscoderConfig_Create()Creates an instance of the transcoding configuration parameters.
OH_AVErrCode OH_AVTranscoderConfig_Release(OH_AVTranscoder_Config* config)Releases the resources of the transcoding configuration parameters.
After a successful call, the instance specified by config is released and set to nullptr.
OH_AVErrCode OH_AVTranscoderConfig_SetSrcFD(OH_AVTranscoder_Config *config, int32_t srcFd, int64_t srcOffset, int64_t length)Sets the file descriptor of the source video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstFD(OH_AVTranscoder_Config *config, int32_t dstFd)Sets the file descriptor of the output video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoType(OH_AVTranscoder_Config *config, const char *mimeType)Sets the encoding format of the output video for transcoding.
Currently, only AVC and HEVC are supported. If the source video is in HEVC format, the default value is HEVC. Otherwise, the default value is AVC.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstAudioType(OH_AVTranscoder_Config *config, const char *mimeType)Sets the encoding format of the output audio for transcoding.
Currently, only AAC is supported. If this parameter is not set, AAC is used by default.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstFileType(OH_AVTranscoder_Config *config, OH_AVOutputFormat mimeType)Sets the container format of the output video file for transcoding.
Currently, only MP4 is supported.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstAudioBitrate(OH_AVTranscoder_Config *config, int32_t bitrate)Sets the bit rate of the output audio for transcoding.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoBitrate(OH_AVTranscoder_Config *config, int32_t bitrate)Sets the bit rate of the output video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoResolution(OH_AVTranscoder_Config *config, int32_t width, int32_t height)Sets the resolution of the output video for transcoding, in px, where width is the width of the output video frame and height is the height of the output video frame.
This function must be called before OH_AVTranscoder_Prepare.
OH_AVErrCode OH_AVTranscoderConfig_EnableBFrame(OH_AVTranscoder_Config *config, bool enabled)Enables B-frame encoding for the output video during transcoding.
For details about the constraints on B-frame video encoding, see Constraints in B-Frame Video Encoding.
If the current environment does not meet these constraints, B-frames will be skipped, and encoding will proceed as if B-frame video encoding were not enabled.
OH_AVTranscoder *OH_AVTranscoder_Create(void)Creates an AVTranscoder instance.
OH_AVErrCode OH_AVTranscoder_Prepare(OH_AVTranscoder *transcoder, OH_AVTranscoder_Config *config)Sets the parameters for video transcoding and prepares for transcoding.
This function must be called before OH_AVTranscoder_Start. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_PREPARED state.
OH_AVErrCode OH_AVTranscoder_Start(OH_AVTranscoder *transcoder)Starts transcoding.
This function must be called after a successful call to OH_AVTranscoder_Prepare. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_STARTED state.
OH_AVErrCode OH_AVTranscoder_Pause(OH_AVTranscoder *transcoder)Pauses transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_STARTED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_PAUSED state.
OH_AVErrCode OH_AVTranscoder_Resume(OH_AVTranscoder *transcoder)Resumes transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_PAUSED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_STARTED state again.
OH_AVErrCode OH_AVTranscoder_Cancel(OH_AVTranscoder *transcoder)Cancels transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_STARTED or AVTRANSCODER_PAUSED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_CANCELLED state.
OH_AVErrCode OH_AVTranscoder_Release(OH_AVTranscoder *transcoder)Releases an AVTranscoder instance.
OH_AVErrCode OH_AVTranscoder_SetStateCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnStateChange callback, void *userData)Registers a callback for transcoding state change events.
This callback is invoked when the state of the transcoding process changes.
An application can subscribe to only one transcoding state change event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.
OH_AVErrCode OH_AVTranscoder_SetErrorCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnError callback, void *userData)Registers a callback for transcoding error events.
This callback is invoked when an error occurs during the transcoding process.
If this event is reported, call OH_AVTranscoder_Release to exit the transcoding.
An application can subscribe to only one transcoding error event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.
OH_AVErrCode OH_AVTranscoder_SetProgressUpdateCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnProgressUpdate callback, void *userData)Registers a callback for transcoding progress update events.
This callback is invoked when the progress of the transcoding process is updated.
An application can subscribe to only one transcoding error event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.

Function Description

OH_AVTranscoderConfig_Create()

OH_AVTranscoder_Config *OH_AVTranscoderConfig_Create()

Description

Creates an instance of the transcoding configuration parameters.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Returns

TypeDescription
OH_AVTranscoder_Config *Pointer to the OH_AVTranscoder_Config instance created. If the operation fails, nullptr is returned.

OH_AVTranscoderConfig_Release()

OH_AVErrCode OH_AVTranscoderConfig_Release(OH_AVTranscoder_Config* config)

Description

Releases the resources of the transcoding configuration parameters.
After a successful call, the instance specified by config is released and set to nullptr.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config* configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The release operation is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr.

OH_AVTranscoderConfig_SetSrcFD()

OH_AVErrCode OH_AVTranscoderConfig_SetSrcFD(OH_AVTranscoder_Config *config, int32_t srcFd, int64_t srcOffset, int64_t length)

Description

Sets the file descriptor of the source video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
int32_t srcFdFile descriptor of the source video.
int64_t srcOffsetOffset of the source video in the file descriptor, in bytes.
int64_t lengthSize of the source video, in bytes.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the parameters related to the source video file are incorrect.

OH_AVTranscoderConfig_SetDstFD()

OH_AVErrCode OH_AVTranscoderConfig_SetDstFD(OH_AVTranscoder_Config *config, int32_t dstFd)

Description

Sets the file descriptor of the output video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
int32_t dstFdFile descriptor of the output video.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the output video file descriptor is invalid.

OH_AVTranscoderConfig_SetDstVideoType()

OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoType(OH_AVTranscoder_Config *config, const char *mimeType)

Description

Sets the encoding format of the output video for transcoding.
Currently, only AVC and HEVC are supported. If the source video is in HEVC format, the default value is HEVC. Otherwise, the default value is AVC.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
const char *mimeTypePointer to the encoding format of the output video. For details, see native_avcodec_base.h.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of mimeType is not allowed.

OH_AVTranscoderConfig_SetDstAudioType()

OH_AVErrCode OH_AVTranscoderConfig_SetDstAudioType(OH_AVTranscoder_Config *config, const char *mimeType)

Description

Sets the encoding format of the output audio for transcoding.
Currently, only AAC is supported. If this parameter is not set, AAC is used by default.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
const char *mimeTypePointer to the encoding format of the output audio. For details, see native_avcodec_base.h.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of mimeType is not allowed.

OH_AVTranscoderConfig_SetDstFileType()

OH_AVErrCode OH_AVTranscoderConfig_SetDstFileType(OH_AVTranscoder_Config *config, OH_AVOutputFormat mimeType)

Description

Sets the container format of the output video file for transcoding.
Currently, only MP4 is supported.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
OH_AVOutputFormat mimeTypeContainer format of the output video. For details, see native_avcodec_base.h.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of mimeType is invalid.

OH_AVTranscoderConfig_SetDstAudioBitrate()

OH_AVErrCode OH_AVTranscoderConfig_SetDstAudioBitrate(OH_AVTranscoder_Config *config, int32_t bitrate)

Description

Sets the bit rate of the output audio for transcoding.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
int32_t bitrateBit rate of the output audio, in bit/s. The value range is [1, 500000]. The default value is 48 kbit/s.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of bitrate is invalid.

OH_AVTranscoderConfig_SetDstVideoBitrate()

OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoBitrate(OH_AVTranscoder_Config *config, int32_t bitrate)

Description

Sets the bit rate of the output video for transcoding.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
int32_t bitrateBit rate of the output video, in bit/s. The default bit rate is set according to the resolution of the output video.
For the resolution range [240p, 480p], the default bit rate is 1 Mbit/s.
For the resolution range (480p, 720p], the default bit rate is 2 Mbit/s.
For the resolution range (240p, 1080p], the default bit rate is 4 Mbit/s.
For the resolution 1080p or above, the default bit rate is 8 Mbit/s.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of bitrate is invalid.

OH_AVTranscoderConfig_SetDstVideoResolution()

OH_AVErrCode OH_AVTranscoderConfig_SetDstVideoResolution(OH_AVTranscoder_Config *config, int32_t width, int32_t height)

Description

Sets the resolution of the output video for transcoding, in px, where width is the width of the output video frame and height is the height of the output video frame.
This function must be called before OH_AVTranscoder_Prepare.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
int32_t widthWidth of the output video frame. The value range is [240, 3840]. The default value is the width of the source video frame.
int32_t heightHeight of the output video frame. The value range is [240, 2160]. The default value is the height of the source video frame.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr, or the value of width or height is invalid.

OH_AVTranscoderConfig_EnableBFrame()

OH_AVErrCode OH_AVTranscoderConfig_EnableBFrame(OH_AVTranscoder_Config *config, bool enabled)

Description

Enables B-frame encoding for the output video during transcoding.
For details about the constraints on B-frame video encoding, see Constraints in B-Frame Video Encoding.
If the current environment does not meet these constraints, B-frames will be skipped, and encoding will proceed as if B-frame video encoding were not enabled.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance, which is created by running OH_AVTranscoderConfig_Create.
bool enabledWhether to enable B-frame encoding. The values include true (yes) and false (no). The default value is false.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The setting is successful.
AV_ERR_INVALID_VAL: The input parameter config is nullptr.

OH_AVTranscoder_Create()

OH_AVTranscoder *OH_AVTranscoder_Create(void)

Description

Creates an AVTranscoder instance.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Returns

TypeDescription
OH_AVTranscoder *Pointer to the OH_AVTranscoder instance created. If the operation fails, nullptr is returned.

OH_AVTranscoder_Prepare()

OH_AVErrCode OH_AVTranscoder_Prepare(OH_AVTranscoder *transcoder, OH_AVTranscoder_Config *config)

Description

Sets the parameters for video transcoding and prepares for transcoding.
This function must be called before OH_AVTranscoder_Start. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_PREPARED state.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.
OH_AVTranscoder_Config *configPointer to an OH_AVTranscoder_Config instance,
which is created by running OH_AVTranscoderConfig_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The video transcoding parameters are set successfully, and the AVTranscoder enters the AVTRANSCODER_PREPARED state.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Prepare operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Prepare operation is not allowed in the current state, or the format is not supported.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_Start()

OH_AVErrCode OH_AVTranscoder_Start(OH_AVTranscoder *transcoder)

Description

Starts transcoding.
This function must be called after a successful call to OH_AVTranscoder_Prepare. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_STARTED state.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: Transcoding starts successfully, and the AVTranscoder enters the AVTRANSCODER_STARTED state.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Start operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Start operation is not allowed in the current state.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_Pause()

OH_AVErrCode OH_AVTranscoder_Pause(OH_AVTranscoder *transcoder)

Description

Pauses transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_STARTED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_PAUSED state.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: Transcoding is paused successfully, and the AVTranscoder enters the AVTRANSCODER_PAUSED state.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Pause operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Pause operation is not allowed in the current state.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_Resume()

OH_AVErrCode OH_AVTranscoder_Resume(OH_AVTranscoder *transcoder)

Description

Resumes transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_PAUSED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_STARTED state again.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: Transcoding is resumed successfully, and the AVTranscoder enters the AVTRANSCODER_STARTED state.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Resume operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Resume operation is not allowed in the current state.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_Cancel()

OH_AVErrCode OH_AVTranscoder_Cancel(OH_AVTranscoder *transcoder)

Description

Cancels transcoding.
This function must be called when the AVTranscoder is in the AVTRANSCODER_STARTED or AVTRANSCODER_PAUSED state. Upon a successful call to this function, the AVTranscoder enters the AVTRANSCODER_CANCELLED state.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: Transcoding is canceled successfully, and the AVTranscoder enters the AVTRANSCODER_CANCELLED state.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Cancel operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Cancel operation is not allowed in the current state.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_Release()

OH_AVErrCode OH_AVTranscoder_Release(OH_AVTranscoder *transcoder)

Description

Releases an AVTranscoder instance.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The AVTranscoder instance is successfully released.
AV_ERR_INVALID_VAL: The input parameter transcoder is nullptr, or the Release operation fails.
AV_ERR_OPERATE_NOT_PERMIT: The Release operation is not allowed in the current state.
AV_ERR_IO: An I/O access error occurs.
AV_ERR_SERVICE_DIED: The media service is stopped.

OH_AVTranscoder_SetStateCallback()

OH_AVErrCode OH_AVTranscoder_SetStateCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnStateChange callback, void *userData)

Description

Registers a callback for transcoding state change events.
This callback is invoked when the state of the transcoding process changes.
An application can subscribe to only one transcoding state change event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.
OH_AVTranscoder_OnStateChange callbackCallback invoked when the state of the transcoding process changes. For details, see OH_AVTranscoder_OnStateChange.
void *userDataPointer to user-defined data.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The registration is successful.
AV_ERR_INVALID_VAL: The input parameter transcoder or callback is nullptr.

OH_AVTranscoder_SetErrorCallback()

OH_AVErrCode OH_AVTranscoder_SetErrorCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnError callback, void *userData)

Description

Registers a callback for transcoding error events.
This callback is invoked when an error occurs during the transcoding process.
If this event is reported, call OH_AVTranscoder_Release to exit the transcoding.
An application can subscribe to only one transcoding error event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.
OH_AVTranscoder_OnError callbackCallback invoked when an error occurs during the transcoding process. For details, see OH_AVTranscoder_OnError.
void *userDataPointer to user-defined data.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The registration is successful.
AV_ERR_INVALID_VAL: The input parameter transcoder or callback is nullptr.

OH_AVTranscoder_SetProgressUpdateCallback()

OH_AVErrCode OH_AVTranscoder_SetProgressUpdateCallback(OH_AVTranscoder *transcoder, OH_AVTranscoder_OnProgressUpdate callback, void *userData)

Description

Registers a callback for transcoding progress update events.
This callback is invoked when the progress of the transcoding process is updated.
An application can subscribe to only one transcoding error event. When the application initiates multiple subscriptions to this event, the last subscription is applied.
The callback must be registered before OH_AVTranscoder_Prepare is called.

System capability: SystemCapability.Multimedia.Media.AVTranscoder

Since: 20

Parameters

NameDescription
OH_AVTranscoder *transcoderPointer to an OH_AVTranscoder instance, which is created by running OH_AVTranscoder_Create.
OH_AVTranscoder_OnProgressUpdate callbackCallback invoked when the progress of the transcoding process is updated. For details, see OH_AVTranscoder_OnProgressUpdate.
void *userDataPointer to user-defined data.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The registration is successful.
AV_ERR_INVALID_VAL: The input parameter transcoder or callback is nullptr.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-avrecorder-oh-avrecorder-range

openharmony 鸿蒙 errorcode-media

openharmony 鸿蒙 capi-avplayer

openharmony 鸿蒙 capi-avplayer-base-h

openharmony 鸿蒙 capi-avimage-generator-h

openharmony 鸿蒙 capi-avscreencapture-oh-rect

openharmony 鸿蒙 capi-videoprocessing-videoprocessing-callback

openharmony 鸿蒙 capi-avsinkbase

openharmony 鸿蒙 capi-avmetadataextractor

openharmony 鸿蒙 capi-avscreencapture-oh-multidisplaycapability

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/iJ5dJziI