目录

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

[h2]Video Decoding

Currently, the following decoding capabilities are supported:

, VVC (H.266)

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 capabilities provided by the system platform are device-dependent. For details about the software and hardware decoding capabilities and capability specifications supported by the system platform, see Obtaining Supported Codecs.

For example, you can query the hardware decoding capabilities of H.264, H.265, and H.266 by using OH_AVCODEC_MIMETYPE_VIDEO_AVC, OH_AVCODEC_MIMETYPE_VIDEO_HEVC, OH_AVCODEC_MIMETYPE_VIDEO_VVC.

For details about the development guide, see Video Decoding.

[h2]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).

For details about the platform support status and the capability range of each encoding type, see Obtaining Supported Codecs.

For details about the development guide, see Video Encoding.

[h2]Audio Decoding

Currently, the following decoding capabilities are supported:

, Audio ViVid11+, Opus

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.

[h2]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

, AMR (AMR-NB, AMR-WB), Opus

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

[h2]Media Data Demultiplexing

The following formats are supported:

Media Format Multiplexing Format Track Format
Audio/Video mp4

Video track: AVC (H.264), HEVC (H.265), VVC (H.266), MPEG4

Audio track: AAC, MPEG (MP3), Audio Vivid

Subtitle track: WEBVTT

Auxiliary track: PREY (H.265), DEPTH (H.265), AUXL (AAC and MP3)

Timed metadata track

Audio/Video fmp4

Video track: AVC (H.264), HEVC(H.265)

Audio track: AAC, MPEG (MP3), Audio Vivid

Audio/Video mkv

Video track: AVC (H.264), HEVC(H.265)

Audio track: AAC, MPEG (MP3), Opus

Audio/Video mpeg-ts

Video track: AVC (H.264), HEVC (H.265), MPEG2, MPEG4

Audio track: AAC, MPEG (MP3), Audio Vivid

Audio/Video flv

Video track: AVC (H.264), HEVC(H.265)

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+

, HEVC (H.265)

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, Audio Vivid
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 sunAU24+ Audio track: PCM, ADPCM_G722, ADPCM_G726LE, G711mu, G711a
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, H.265, and AAC), MPEG-TS (H.264, H.265, and AAC).

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

[h2]Media Data Multiplexing

Currently, the following muxer capabilities are supported:

Container Format Video Codec Type Audio Codec Type Cover Type
mp4 AVC (H.264), HEVC (H.265) AAC, MPEG (MP3) jpg, png, bmp
m4a - AAC jpg, png, bmp
mp3 - MPEG (MP3) jpg
amr - AMR (AMR-NB and AMR-WB) -
wav - G711mu (pcm-mulaw), raw (pcm) -
aac - AAC -
flac - Flac jpg, png, bmp
ogg23+ - Vorbis, OPUS -
flv AVC (H.264), HEVC (H.265) AAC -
  • When the multiplexing 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 multiplexing format is mp4 or m4a and the audio codec type is AAC, the channel count ranges from 1 to 7.
  • Starting from API version 26.0.0, flv format multiplexing is supported. When the multiplexing format is flv, only one audio track and one video track are supported. Rotation angle setting, cover tracks, and auxiliary tracks are not supported.

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.
OH_MD_KEY_LATITUDE Key for latitude. The value type is float, with a range of [-90.0, 90.0]. Represents the latitude in geographic location information (supported from API version 24).
OH_MD_KEY_LONGITUDE Key for longitude. The value type is float, with a range of [-180.0, 180.0]. Represents the longitude in geographic location information (supported from API version 24).
OH_MD_KEY_ALTITUDE Key for altitude. The value type is float. This key is optional. Represents the altitude in geographic location information (supported from API version 24).

When the multiplexing format is mp4, custom keys must start with "com.openharmony.". The value type can be int32_t, float, or string. uint8_t* is also supported starting from API version 20.

When the multiplexing format is flv, custom keys must start with "com.openharmony.". The value type is string.

Key values of configuration options are described as follows:

mp4 container format:

key Description aac mp3 H.264 H.265 Cover Type (jpg, png, bmp)
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate Mandatory Mandatory - - -
OH_MD_KEY_AUD_CHANNEL_COUNT 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 Bitrate Optional Optional Optional Optional -
OH_MD_KEY_CODEC_CONFIG Codec specific data Optional - Optional Optional -
OH_MD_KEY_WIDTH Width - - Mandatory Mandatory Mandatory
OH_MD_KEY_HEIGHT Height - - 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 - - Optional Optional -
OH_MD_KEY_MATRIX_COEFFICIENTS Video matrix coefficients - - Optional Optional -
OH_MD_KEY_RANGE_FLAG Value domain flag - - Optional Optional -
OH_MD_KEY_VIDEO_IS_HDR_VIVID Whether the video track is 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 Cover Type (jpg, png, bmp)
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate Mandatory -
OH_MD_KEY_AUD_CHANNEL_COUNT 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 Bitrate Optional -
OH_MD_KEY_CODEC_CONFIG Codec specific data Optional -
OH_MD_KEY_WIDTH Width - Mandatory
OH_MD_KEY_HEIGHT Height - 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 Cover Type (jpg)
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate Mandatory -
OH_MD_KEY_AUD_CHANNEL_COUNT 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 Bitrate 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 Cover Type (jpg, png, bmp)
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate Mandatory -
OH_MD_KEY_AUD_CHANNEL_COUNT 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 Bitrate Optional -
OH_MD_KEY_CODEC_CONFIG Codec specific data Optional -
OH_MD_KEY_WIDTH Width - Mandatory
OH_MD_KEY_HEIGHT Height - Mandatory

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

flv multiplexing format (supported since API version 26.0.0):

key Description aac H.264 H.265
OH_MD_KEY_AUD_SAMPLE_RATE Sample rate Mandatory - -
OH_MD_KEY_AUD_CHANNEL_COUNT Channel count Mandatory - -
OH_MD_KEY_CHANNEL_LAYOUT Channel layout Optional - -
OH_MD_KEY_PROFILE Encoding profile Optional - -
OH_MD_KEY_BITRATE Bitrate 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 - Optional Optional
OH_MD_KEY_MATRIX_COEFFICIENTS Video matrix coefficients - Optional Optional
OH_MD_KEY_RANGE_FLAG Value domain flag - Optional Optional

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