• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# AVCodec Supported Formats
2
3<!--Kit: AVCodec Kit-->
4<!--Subsystem: Multimedia-->
5<!--Owner: @zhanghongran; @mr-chencxy-->
6<!--Designer: @dpy2650--->
7<!--Tester: @cyakee-->
8<!--Adviser: @zengyawen-->
9
10## Media Codec
11
12### Video Decoding
13
14Currently, the following decoding capabilities are supported:
15
16| Video Hardware Decoding Type      | Video Software Decoding Type  |
17| --------------------- | ---------------- |
18| AVC (H.264), HEVC (H.265)<!--RP14--><!--RP14End--> | MPEG2, MPEG4, H.263, AVC (H.264)<!--RP12--><!--RP12End--> |
19
20When you attempt to create a decoder using the MIME type, the system preferentially creates a hardware decoder instance. If the system platform does not support the hardware decoder or the hardware decoder resources are insufficient, the system creates a software decoder instance.
21
22The system supports the following software decoder formats:
23- MPEG2 (OH_AVCODEC_MIMETYPE_VIDEO_MPEG2)
24- MPEG4 (OH_AVCODEC_MIMETYPE_VIDEO_MPEG4_PART2)
25- H.263 (OH_AVCODEC_MIMETYPE_VIDEO_H263)
26- H.264 (OH_AVCODEC_MIMETYPE_VIDEO_AVC)
27<!--RP13--><!--RP13End-->
28
29The hardware decoding capability provided by the system is closely related to the platform hardware capability. You can obtain the hardware decoding capability and capability specifications of the system by following the instructions provided in [Obtaining Supported Codecs](obtain-supported-codecs.md).
30
31For example, you can query the <!--RP16-->hardware decoding capabilities of H.264 and H.265<!--RP16End--> by using <!--RP15-->**OH_AVCODEC_MIMETYPE_VIDEO_AVC** and **OH_AVCODEC_MIMETYPE_VIDEO_HEVC**<!--RP15End-->.
32
33For details about the development guide, see [Video Decoding](video-decoding.md).
34
35### Video Encoding
36
37Currently, the following encoding capabilities are supported:
38
39| Video Encoding Type                |
40| ---------------------------- |
41| HEVC (H.265), AVC (H.264)|
42
43Only hardware encoding is supported. When an encoder is created based on the MIME type, H.264 (OH_AVCODEC_MIMETYPE_VIDEO_AVC) and H.265 (OH_AVCODEC_MIMETYPE_VIDEO_HEVC) are supported.
44
45For details about the range of each encoding capability, see [Obtaining Supported Codecs](obtain-supported-codecs.md).
46
47For details about the development guide, see [Video Encoding](video-encoding.md).
48
49
50### Audio Decoding
51
52Currently, the following decoding capabilities are supported:
53
54AAC, MPEG (MP3), FLAC, Vorbis, AMR (AMR-NB and AMR-WB), G711mu, APE, G711a<!--RP1--><!--RP1End-->
55
56For details about the development guide, see [Audio Decoding](audio-decoding.md).
57
58
59### Audio Encoding
60
61Currently, the following encoding capabilities are supported:
62
63AAC, FLAC, MP3, G711mu<!--RP3--><!--RP3End-->
64
65For details about the development guide, see [Audio Encoding](audio-encoding.md).
66
67
68## Media Data Multiplexing and Demultiplexing
69
70### Media Data Demultiplexing
71
72The following formats are supported:
73
74| Media Format | Container Format                     | Track Format                     |
75| -------- | :----------------------------| :----------------------------|
76| Audio/Video    | mp4                        |<!--RP4-->Video track: AVC (H.264), MPEG4<br>Audio track: AAC, MPEG (MP3)<br>Subtitle track: WEBVTT<br>Auxiliary track: AUXL (AAC, MP3)<br>Timed metadata track<!--RP4End-->|
77| Audio/Video    | fmp4                       |<!--RP5-->Video track: AVC (H.264)<br>Audio track: AAC, MPEG (MP3)<!--RP5End-->|
78| Audio/Video    | mkv                        |<!--RP6-->Video track: AVC (H.264)<br>Audio track: AAC, MPEG (MP3), OPUS<!--RP6End-->|
79| Audio/Video    | mpeg-ts                    |<!--RP7-->Video track: AVC (H.264), MPEG2, MPEG4<br>Audio track: AAC, MPEG (MP3)<!--RP7End-->|
80| Audio/Video    | flv                        |<!--RP8-->Video track: AVC (H.264)<br>Audio track: AAC<!--RP8End-->|
81| Audio/Video    | mpeg-ps                    |Video track: AVC (H.264), MPEG2<br>Audio track: MPEG (MP2, MP3)|
82| Audio/Video    | avi                        |Video track: H.263, AVC (H.264), MPEG2, MPEG4<br>Audio track: AAC, MPEG (MP2, MP3), PCM|
83| Audio      | m4a                        |<!--RP9-->Audio track: AAC<!--RP9End-->|
84| Audio      | aac                        |Audio track: AAC|
85| Audio      | mp3                        |Audio track: MPEG (MP3)|
86| Audio      | ogg                        |Audio track: Vorbis|
87| Audio      | flac                       |Audio track: FLAC|
88| Audio      | wav                        |Audio track: PCM, G711mu, G711a|
89| Audio      | amr                        |Audio track: AMR (amrnb and amrwb)|
90| Audio      | ape                        |Audio track: APE|
91| External subtitle  | srt                        |Subtitle track: SRT|
92| External subtitle  | webvtt                     |Subtitle track: WEBVTT|
93
94The DRM demultiplexing capability supports the following formats: <!--RP10-->mp4 (H.264 and AAC) and mpeg-ts (H.264 and AAC)<!--RP10End-->.
95
96For details about the development guide, see [Media Data Demultiplexing](audio-video-demuxer.md).
97
98
99### Media Data Multiplexing
100
101Currently, the following muxer capabilities are supported:
102
103| Container Format| Video Codec Type       | Audio Codec Type  | Cover Type      |
104| -------- | --------------------- | ---------------- | -------------- |
105| mp4      | AVC (H.264) <!--RP11--><!--RP11End-->    | AAC, MPEG (MP3)| jpeg, png, bmp|
106| m4a      | -                     | AAC              | jpeg, png, bmp|
107| mp3      | -                     | MPEG (MP3)     | -              |
108| amr      | -                     | AMR (AMR-NB and AMR-WB)| -             |
109| wav      | -                     | G711mu (pcm-mulaw), raw (pcm)| -             |
110| aac      | -                     | AAC               | -             |
111| flac     | -                     | Flac              | jpeg, png, bmp|
112
113> **NOTE**
114>
115> - 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.
116> - 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.
117
118Key values of configuration options are described as follows:
119
120mp4 container format:
121   |                key                 |         Description        |   aac  |   mp3  |  H.264  |  H.265  |  jpg   |  png   |  bmp   |
122   | ---------------------------------- | :------------------: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
123   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |  Mandatory |   -    |   -    |   -   |   -   |   -   |
124   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |  Mandatory |   -    |   -    |   -   |   -   |   -   |
125   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |  Optional |   -    |   -    |   -   |   -   |   -   |
126   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |  Optional |   -    |   -    |   -   |   -   |   -   |
127   | OH_MD_KEY_PROFILE                  | Encoding profile.             |  Optional |   -   |   -    |   -    |   -   |   -   |   -   |
128   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |  Optional |  Optional |  Optional |   -   |   -   |   -   |
129   | OH_MD_KEY_CODEC_CONFIG             | Codec-specific data.      |  Optional |   -   |  Optional |  Optional |   -   |   -   |   -   |
130   | OH_MD_KEY_WIDTH                    | Width.                 |   -   |   -   |  Mandatory |  Mandatory |  Mandatory |  Mandatory |  Mandatory |
131   | OH_MD_KEY_HEIGHT                   | Height.                 |   -   |   -   |  Mandatory |  Mandatory |  Mandatory |  Mandatory |  Mandatory |
132   | OH_MD_KEY_FRAME_RATE               | Video stream frame rate.           |   -   |   -   |  Optional |  Optional |   -   |   -   |   -   |
133   | OH_MD_KEY_COLOR_PRIMARIES          | Video color gamut.             |   -   |   -   |  Optional |  Optional |   -   |   -   |   -   |
134   | OH_MD_KEY_TRANSFER_CHARACTERISTICS | Video transfer characteristics function.         |   -   |   -   |  Optional |  Optional |   -   |   -   |   -   |
135   | OH_MD_KEY_MATRIX_COEFFICIENTS      | Video matrix coefficient.         |   -   |   -   |  Optional |  Optional |   -   |   -   |   -   |
136   | OH_MD_KEY_RANGE_FLAG               | Value range flag.             |   -   |   -   |  Optional |  Optional |   -   |   -   |   -   |
137   | OH_MD_KEY_VIDEO_IS_HDR_VIVID       | Whether the video track is an HDR Vivid.|   -   |   -   |   -    |  Optional |   -   |   -   |   -   |
138
139MP4 container format of the auxiliary track:
140   |                key                 |         Description        |   aac  |   mp3  |  H.264  |  H.265  |
141   | ---------------------------------- | :------------------: | :----: | :----: | :----: | :----: |
142   | OH_MD_KEY_TRACK_TYPE               | Media type of the track.         |  Mandatory |  Mandatory |  Mandatory  |  Mandatory  |
143   | OH_MD_KEY_TRACK_REFERENCE_TYPE     | Reference type of the track.         |  Mandatory |  Mandatory |  Mandatory  |  Mandatory  |
144   | OH_MD_KEY_TRACK_DESCRIPTION        | Track ID.             |  Mandatory |  Mandatory |  Mandatory  |  Mandatory  |
145   | OH_MD_KEY_REFERENCE_TRACK_IDS      | Reference track number.         |  Mandatory |  Mandatory |  Mandatory  |  Mandatory  |
146   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |  Mandatory |   -    |   -    |
147   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |  Mandatory |   -    |   -    |
148   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |  Optional |   -    |   -    |
149   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |  Optional |   -    |   -    |
150   | OH_MD_KEY_PROFILE                  | Encoding profile.             |  Optional |   -   |   -    |   -    |
151   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |  Optional |  Optional |  Optional |
152   | OH_MD_KEY_CODEC_CONFIG             | Codec-specific data.      |  Optional |   -   |  Optional |  Optional |
153   | OH_MD_KEY_WIDTH                    | Width.                 |   -   |   -   |  Mandatory |  Mandatory |
154   | OH_MD_KEY_HEIGHT                   | Height.                 |   -   |   -   |  Mandatory |  Mandatory |
155   | OH_MD_KEY_FRAME_RATE               | Video stream frame rate.           |   -   |   -   |  Optional |  Optional |
156   | OH_MD_KEY_COLOR_PRIMARIES          | Video color gamut.             |   -   |   -   |  Optional |  Optional |
157   | OH_MD_KEY_TRANSFER_CHARACTERISTICS | Video transfer characteristics function.         |   -   |   -   |  Optional |  Optional |
158   | OH_MD_KEY_MATRIX_COEFFICIENTS      | Video matrix coefficient.         |   -   |   -   |  Optional |  Optional |
159   | OH_MD_KEY_RANGE_FLAG               | Value range flag.             |   -   |   -   |  Optional |  Optional |
160   | OH_MD_KEY_VIDEO_IS_HDR_VIVID       | Whether the video track is an HDR Vivid.|   -   |   -   |   -    |  Optional |
161
162m4a container format:
163   |                key                 |         Description        |   aac  |  jpg   |  png   |  bmp   |
164   | ---------------------------------- | :------------------: | :----: | :----: | :----: | :----: |
165   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory  |   -   |   -   |   -   |
166   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory  |   -   |   -   |   -   |
167   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional  |   -   |   -   |   -   |
168   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional  |   -   |   -   |   -   |
169   | OH_MD_KEY_PROFILE                  | Encoding profile.             |  Optional |   -   |   -   |   -   |
170   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional  |   -   |   -   |   -   |
171   | OH_MD_KEY_CODEC_CONFIG             | Codec-specific data.      |  Optional |   -   |   -   |   -   |
172   | OH_MD_KEY_WIDTH                    | Width.                 |   -   |  Mandatory |  Mandatory |  Mandatory |
173   | OH_MD_KEY_HEIGHT                   | Height.                 |   -   |  Mandatory |  Mandatory |  Mandatory |
174
175amr container format:
176   |                key                 |         Description        | amr_nb | amr_wb |
177   | ---------------------------------- | :------------------: | :----: | :----: |
178   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |  Mandatory |
179   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |  Mandatory |
180   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |  Optional |
181   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |  Optional |
182   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |  Optional |
183
184mp3 container format:
185   |                key                 |         Description        |   mp3  |  jpg   |
186   | ---------------------------------- | :------------------: | :----: | :----: |
187   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |   -   |
188   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |   -   |
189   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |   -   |
190   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |   -   |
191   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |   -   |
192   | OH_MD_KEY_WIDTH                    | Width.                 |   -   |  Mandatory |
193   | OH_MD_KEY_HEIGHT                   | Height.                 |   -   |  Mandatory |
194
195wav container format:
196   |                key                 |         Description        | g711mu  | raw  |
197   | ---------------------------------- | :------------------: | :----: | :----: |
198   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |  Mandatory |
199   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |  Mandatory |
200   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |  Mandatory |
201   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |  Optional |
202   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Mandatory |  Optional |
203
204aac container format:
205   |                key                 |         Description        |  aac   |
206   | ---------------------------------- | :------------------: | :----: |
207   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |
208   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |
209   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Optional |
210   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |
211   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |
212   | OH_MD_KEY_PROFILE                  | Encoding profile.             |  Mandatory |
213   | OH_MD_KEY_AAC_IS_ADTS              | Whether the format is ADTS.       |  Mandatory |
214
215flac container format:
216   |                key                 |         Description        |  flac   |
217   | ---------------------------------- | :------------------: | :----: |
218   | OH_MD_KEY_AUD_SAMPLE_RATE          | Sample rate.               |  Mandatory |
219   | OH_MD_KEY_AUD_CHANNEL_COUNT        | Audio channel count.               |  Mandatory |
220   | OH_MD_KEY_AUDIO_SAMPLE_FORMAT      | Output audio stream format.        |  Mandatory |
221   | OH_MD_KEY_CHANNEL_LAYOUT           | Channel layout.             |  Optional |
222   | OH_MD_KEY_BITRATE                  | Bit rate.                 |  Optional |
223   | OH_MD_KEY_CODEC_CONFIG             | Codec-specific data.      |  Optional |
224
225For details about the development guide, see [Media Data Multiplexing](audio-video-muxer.md).
226