AVCodec Supported Formats

The capabilities for encoding and decoding audio and video, as well as for multiplexing and demultiplexing file formats, vary across different platforms in terms of functionality and specifications. You can obtain the supported capabilities and specifications by following the instructions provided in Obtaining Supported Codecs.

Media Codec

Video Decoding

Currently, the following decoding capabilities are supported:

Video Decoding Type MIME Type for Video Decoding Format
MSVIDEO122+ OH_AVCODEC_MIMETYPE_VIDEO_MSVIDEO1
WMV322+ OH_AVCODEC_MIMETYPE_VIDEO_WMV3
MJPEG22+ OH_AVCODEC_MIMETYPE_VIDEO_MJPEG
MPEG2 OH_AVCODEC_MIMETYPE_VIDEO_MPEG2
MPEG4 OH_AVCODEC_MIMETYPE_VIDEO_MPEG4
H.263 OH_AVCODEC_MIMETYPE_VIDEO_H263
AVC(H.264) OH_AVCODEC_MIMETYPE_VIDEO_AVC
HEVC(H.265) OH_AVCODEC_MIMETYPE_VIDEO_HEVC
AV123+ OH_AVCODEC_MIMETYPE_VIDEO_AV1
VP923+ OH_AVCODEC_MIMETYPE_VIDEO_VP9
VP823+ OH_AVCODEC_MIMETYPE_VIDEO_VP8
RV3023+ OH_AVCODEC_MIMETYPE_VIDEO_RV30
RV4023+ OH_AVCODEC_MIMETYPE_VIDEO_RV40
WVC123+ OH_AVCODEC_MIMETYPE_VIDEO_WVC1
DVVIDEO23+ OH_AVCODEC_MIMETYPE_VIDEO_DVVIDEO
RAWVIDEO23+ OH_AVCODEC_MIMETYPE_VIDEO_RAWVIDEO
MPEG123+ OH_AVCODEC_MIMETYPE_VIDEO_MPEG1

When you attempt to create a decoder using the MIME type, if the system supports hardware decoding, the system preferentially creates a hardware decoder instance. If the system does not support hardware decoding or the hardware decoder resources are insufficient, the system creates a software decoder instance.

The decoding capability provided by the system is closely related to the device. You can obtain the supported capabilities and specifications by following the instructions provided in Obtaining Supported Codecs. For example, you can query the hardware decoding capabilities of H.264 and H.265 by using OH_AVCODEC_MIMETYPE_VIDEO_AVC and OH_AVCODEC_MIMETYPE_VIDEO_HEVC.

For details about the development guide, see Video Decoding.

Video Encoding

Currently, the following encoding capabilities are supported:

Video Encoding Type MIME Type for Video Encoding Format
HEVC(H.265) OH_AVCODEC_MIMETYPE_VIDEO_HEVC
AVC(H.264) OH_AVCODEC_MIMETYPE_VIDEO_AVC

If the system does not support the required encoding capability, the encoder instance fails to be created.

Supported MIME types for encoder creation include H.264 (OH_AVCODEC_MIMETYPE_VIDEO_AVC) and H.265 (OH_AVCODEC_MIMETYPE_VIDEO_HEVC). You can obtain the supported capabilities and specifications by following the instructions provided in Obtaining Supported Codecs.

For details about the development guide, see Video Encoding.

Audio Decoding

Currently, the following decoding capabilities are supported:

Audio Decoding Type MIME Type for Audio Decoding Format
AAC OH_AVCODEC_MIMETYPE_AUDIO_AAC
MPEG(MP3) OH_AVCODEC_MIMETYPE_AUDIO_MPEG
Flac OH_AVCODEC_MIMETYPE_AUDIO_FLAC
Vorbis OH_AVCODEC_MIMETYPE_AUDIO_VORBIS
AMR (AMR-NB and AMR-WB) OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB and OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB
G711mu OH_AVCODEC_MIMETYPE_AUDIO_G711MU
APE OH_AVCODEC_MIMETYPE_AUDIO_APE
G711a20+ OH_AVCODEC_MIMETYPE_AUDIO_G711A
ALAC22+ OH_AVCODEC_MIMETYPE_AUDIO_ALAC
AC322+ OH_AVCODEC_MIMETYPE_AUDIO_AC3
WMA22+(V1, V2, PRO) OH_AVCODEC_MIMETYPE_AUDIO_WMAV1, OH_AVCODEC_MIMETYPE_AUDIO_WMAV2, and OH_AVCODEC_MIMETYPE_AUDIO_WMAPRO
GSM22+ OH_AVCODEC_MIMETYPE_AUDIO_GSM
GSM_MS22+ OH_AVCODEC_MIMETYPE_AUDIO_GSM_MS

If the system does not support the required decoding capability, the decoder instance fails to be created.

The decoding capability provided by the system is closely related to the device. You can obtain the supported capabilities and specifications by following the instructions provided in Obtaining Supported Codecs.

Supported since API version 23: TWINVQ, ILBC, TRUEHD, DVAUDIO, DTS, and COOK

For details about the development guide, see Audio Decoding.

Audio Encoding

Currently, the following encoding capabilities are supported:

Audio Encoding Type MIME Type for Audio Encoding Format
AAC OH_AVCODEC_MIMETYPE_AUDIO_AAC
Flac OH_AVCODEC_MIMETYPE_AUDIO_FLAC
MPEG(MP3) OH_AVCODEC_MIMETYPE_AUDIO_MPEG
G711mu OH_AVCODEC_MIMETYPE_AUDIO_G711MU

If the system does not support the required encoding capability, the encoder instance fails to be created.

The encoding capability provided by the system is closely related to the device. You can obtain the supported capabilities and specifications by following the instructions provided in Obtaining Supported Codecs.

For details about the development guide, see Audio Encoding.

Media Data Multiplexing and Demultiplexing

Media Data Demultiplexing

The following formats are supported:

Media Format Container Format Track Format
Audio/Video mp4 Video track: AVC (H.264), MPEG4
Audio track: AAC, MPEG (MP3), ALAC22+, TRUEHD23+, DTS23+
Subtitle track: WEBVTT
Auxiliary track: AUXL (such as audio raw information and video depth information)
Timed metadata track: time-related description information, such as frame-level maintenance and debugging information and sensor information.
Audio/Video fmp4 Video track: AVC (H.264)
Audio track: AAC, MPEG (MP3), TRUEHD23+, DTS23+
Audio/Video mkv Video track: AVC (H.264), MSVIDEO122+
Audio track: AAC, MPEG (MP3), OPUS, ADPCM_YAMAHA22+, ADPCM_G72222+, ALAC22+, TRUEHD23+, DTS23+
Audio/Video mpeg-ts Video track: AVC (H.264), MPEG2, MPEG4
Audio track: AAC, MPEG (MP3), TRUEHD23+, DTS23+
Audio/Video flv Video track: AVC (H.264)
Audio track: AAC
Audio/Video mpeg-ps Video track: AVC (H.264), MPEG2
Audio track: MPEG (MP2, MP3), DTS23+
Audio/Video avi Video track: H.263, AVC(H.264), MPEG2, MPEG4, MJPEG22+, MSVIDEO122+
Audio track: AAC, MPEG(MP2, MP3), PCM, GSM_MS22+, ADPCM_YAMAHA22+, ADPCM_G72222+, DVAUDIO23+, DTS23+
Audio/Video 3gp22+ Video track: H.263, AVC (H.264), MPEG4
Audio track: AAC, AMR (amrnb and amrwb)
Audio/Video 3g222+ Video track: H.263, AVC (H.264), MPEG4
Audio track: AAC, AMR (amrnb and amrwb)
Audio/Video m4v22+ Video track: AVC (H.264), MPEG4
Audio track: AAC, ALAC, AC3
Audio/Video wmv22+ Video track: AVC (H.264), WMV3
Audio track: WMAV1, WMAV2, WMAPRO
Audio/Video rm23+, rmvb23+ Video track: RV30, RV40
Audio track: AAC, AC3, COOK
Audio m4a Audio track: AAC, ALAC22+
Audio aac Audio track: AAC
Audio mp3 Audio track: MPEG (MP3)
Audio ogg Audio track: Vorbis
Audio flac Audio track: FLAC
Audio wav Audio track: PCM, G711mu, G711a, GSM_MS22+, ADPCM_YAMAHA22+, ADPCM_G72222+, ADPCM_G72622+, DVAUDIO23+, DTS23+
Audio amr Audio track: AMR (amrnb and amrwb)
Audio ape Audio track: APE
Audio wma22+ Audio track: AC3, WMAV1, WMAV2, Vorbis, Flac, AMR (amrnb, amrwb), AAC, MPEG (MP2, MP3), GSM_MS, G711mu, G711a, PCM, ADPCM_G722, ADPCM_G726, ADPCM_IMA_WAV, ADPCM_MS, ADPCM_YAMAHA, DVAUDIO23+, DTS23+
Audio dts23+ Audio track: DTS
External subtitle srt Subtitle track: SRT
External subtitle webvtt Subtitle track: WEBVTT

The DRM demultiplexing capability supports the following formats: mp4 (H.264 and AAC) and mpeg-ts (H.264 and AAC).

For details about the development guide, see Media Data Demultiplexing.

Media Data Multiplexing

Currently, the following muxer capabilities are supported:

Container Format Video Codec Type Audio Codec Type Cover Type
mp4 AVC (H.264) AAC, MPEG (MP3) jpeg, png, bmp
m4a - AAC jpeg, png, bmp
mp3 - MPEG (MP3) -
amr - AMR (AMR-NB and AMR-WB) -
wav - G711mu (pcm-mulaw), raw (pcm) -
aac - AAC -
flac - Flac jpeg, png, bmp
ogg23+ - Vorbis, OPUS -

NOTE

  • When the container format is mp4 and the audio codec type is MPEG (MP3), the sample rate must be greater than or equal to 16000 Hz.
  • When the container format is mp4 or m4a and the audio codec type is AAC, the number of audio channels ranges from 1 to 7.

The keys defined for file-level data are as follows:

key Description
OH_MD_KEY_CREATION_TIME Media file creation time. The value type is string. This key is supported since API version 14.
OH_MD_KEY_COMMENT Comment in a media file. The value type is string. This key is supported since API version 20.
OH_MD_KEY_ENABLE_MOOV_FRONT Whether the moov metadata should be at the front of a media file. The value type is int32_t. This key is supported since API version 20.

NOTE

Custom keys must start with com.openharmony.. The value type can be int32_t, float, or string. The value type uint8_t* is supported since API version 20.

Key values of configuration options are described as follows:

mp4 container format:

key Description aac mp3 H.264 H.265 jpg png bmp
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory Mandatory - - - - -
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory Mandatory - - - - -
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional Optional - - - - -
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional Optional - - - - -
OH_MD_KEY_PROFILE Encoding profile. Optional - - - - - -
OH_MD_KEY_BITRATE Bit rate. Optional Optional Optional Optional - - -
OH_MD_KEY_CODEC_CONFIG Codec-specific data. Optional - Optional Optional - - -
OH_MD_KEY_WIDTH Width. - - Mandatory Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_HEIGHT Height. - - Mandatory Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_FRAME_RATE Video stream frame rate. - - Optional Optional - - -
OH_MD_KEY_COLOR_PRIMARIES Video color gamut. - - Optional Optional - - -
OH_MD_KEY_TRANSFER_CHARACTERISTICS Video transfer characteristics function. - - Optional Optional - - -
OH_MD_KEY_MATRIX_COEFFICIENTS Video matrix coefficient. - - Optional Optional - - -
OH_MD_KEY_RANGE_FLAG Value range flag. - - Optional Optional - - -
OH_MD_KEY_VIDEO_IS_HDR_VIVID Whether the video track is an HDR Vivid. - - - Optional - - -

MP4 container format of the auxiliary track:

key Description aac mp3 H.264 H.265
OH_MD_KEY_TRACK_TYPE Media type of the track. Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_TRACK_REFERENCE_TYPE Reference type of the track. Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_TRACK_DESCRIPTION Track ID. Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_REFERENCE_TRACK_IDS Reference track number. Mandatory Mandatory Mandatory Mandatory
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory Mandatory - -
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory Mandatory - -
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional Optional - -
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional Optional - -
OH_MD_KEY_PROFILE Encoding profile. Optional - - -
OH_MD_KEY_BITRATE Bit rate. Optional Optional Optional Optional
OH_MD_KEY_CODEC_CONFIG Codec-specific data. Optional - Optional Optional
OH_MD_KEY_WIDTH Width. - - Mandatory Mandatory
OH_MD_KEY_HEIGHT Height. - - Mandatory Mandatory
OH_MD_KEY_FRAME_RATE Video stream frame rate. - - Optional Optional
OH_MD_KEY_COLOR_PRIMARIES Video color gamut. - - Optional Optional
OH_MD_KEY_TRANSFER_CHARACTERISTICS Video transfer characteristics function. - - Optional Optional
OH_MD_KEY_MATRIX_COEFFICIENTS Video matrix coefficient. - - Optional Optional
OH_MD_KEY_RANGE_FLAG Value range flag. - - Optional Optional
OH_MD_KEY_VIDEO_IS_HDR_VIVID Whether the video track is an HDR Vivid. - - - Optional

m4a container format:

key Description aac jpg png bmp
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory - - -
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory - - -
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional - - -
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional - - -
OH_MD_KEY_PROFILE Encoding profile. Optional - - -
OH_MD_KEY_BITRATE Bit rate. Optional - - -
OH_MD_KEY_CODEC_CONFIG Codec-specific data. Optional - - -
OH_MD_KEY_WIDTH Width. - Mandatory Mandatory Mandatory
OH_MD_KEY_HEIGHT Height. - Mandatory Mandatory Mandatory

amr container format:

key Description amr_nb amr_wb
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory Mandatory
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory Mandatory
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional Optional
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional Optional
OH_MD_KEY_BITRATE Bit rate. Optional Optional

mp3 container format:

key Description mp3 jpg
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory -
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory -
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional -
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional -
OH_MD_KEY_BITRATE Bit rate. Optional -
OH_MD_KEY_WIDTH Width. - Mandatory
OH_MD_KEY_HEIGHT Height. - Mandatory

wav container format:

key Description g711mu raw
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory Mandatory
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory Mandatory
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional Mandatory
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional Optional
OH_MD_KEY_BITRATE Bit rate. Mandatory Optional

aac container format:

key Description aac
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Optional
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional
OH_MD_KEY_BITRATE Bit rate. Optional
OH_MD_KEY_PROFILE Encoding profile. Mandatory
OH_MD_KEY_AAC_IS_ADTS Whether the format is ADTS. Mandatory

flac container format:

key Description flac
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory
OH_MD_KEY_AUDIO_SAMPLE_FORMAT Output audio stream format. Mandatory
OH_MD_KEY_CHANNEL_LAYOUT Channel layout. Optional
OH_MD_KEY_BITRATE Bit rate. Optional
OH_MD_KEY_CODEC_CONFIG Codec-specific data. Optional

ogg container format (supported since API version 23):

key Description Vorbis OPUS
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate. Mandatory Mandatory
OH_MD_KEY_AUD_CHANNEL_COUNT Audio channel count. Mandatory Mandatory
OH_MD_KEY_CODEC_CONFIG Codec-specific data. Mandatory Mandatory

For details about the development guide, see Media Data Multiplexing.