As an application developer, you can use any media codecs in any format that are valid on Android devices for free, including the codecs provided by Android platforms and devices. However, it is best to use a device-independent Media Encoding configuration file.
Network Protocol
The following network protocols are supported for audio and video playback:
1. RTSP (RTP, SDP)
2. HTTP/HTTPS real-time stream
3. HTTP/HTTPS Live Streaming draft protocol:
Only for MPEG-2 TS Streaming Media files;
Protocol Version 3 (Android4.0 or later)
Protocol Version 2 (Android3.x)
Not Supported before android
Note: HTTPS is not supported before Android3.1.
Core media format
The following table describes the media formats supported by the Android platform. Note: any given mobile device can support other media formats not listed in this list.
Note: The encoding and decoding of these media are not guaranteed to be valid on all Android platforms. Note the annotations in brackets, for example, "(Android3.0 + )"
Table 1. Core media formats and CODEC support
Type |
Format/codecs |
Encoder |
Decoder |
Details |
Supported file types/containers and formats |
Audio |
Aac lc/LTP |
• |
• |
Use a standard bit rate of up to kbps and a sampling frequency of 8 to 48 khz to freely combine single-channel/Stereo content. |
• 3GPP (. 3gp) • MPEG-4 (.mp4,. m4a) • ADTS raw AAC (. aac, decoding: Android 3.1 +, encoding: Android 4.0 +, ADIF not supported) • MPEG-TS (. ts, unaddressable Android 3.0 +) |
The HE-AACv1 (AAC +) |
|
• |
The HE-AACv2 (enhanced AAC +) |
|
• |
AMR-NB |
• |
• |
4.75-kbps bit stream sampled with 8 kHz |
3GPP (. 3gp) |
AMR-WB |
• |
• |
The bitstream from 6.6 kbit/s to 23.85 kbit/s sampled at 16 kHz |
3GPP (. 3gp) |
FLAC |
|
• (Android3.1 +) |
Single or stereo (no multi-channel ). The maximum sampling rate is 48 kHz (the maximum sampling rate is 44.1 kHZ, because the sampling rate between 48 and 44.1 does not include low-pass filtering ). 16-bit sampling is recommended. The 24-bit sampling size is suitable for non-jitters. |
Only exist (.flac) |
MP3 |
|
• |
Single-channel or stereo 8-kbps fixed (CBR) or variable (VBR) playback rate |
Mp3(metadata) |
MIDI |
|
• |
MIDI types 0 and 1. DLS versions 1 and 2. XMF and mobile XMF. Supported ringtone formats: RTTTL/RTX, OTA, and iMelody |
1. Type 0 and 1 (. mid, xmf, mxmf) 2. RTTTL/RTX (. rtttl, rtx) 3. OTA (. ota) 4. iMelody (. imy) |
Vorbis |
|
• |
|
1. Ogg(.ogg) 2. Matroska(.mkv, Android4.0 +) |
PCM/WAVE |
|
• |
8-bit and 16-bit PCM (the maximum sampling rate is limited by hardware) |
WAVE(.wav) |
Image |
JPEG |
• |
• |
Basic + Real-Time |
Certificate (.jpg) |
GIF |
|
• |
|
GIF(.gif) |
PNG |
• |
• |
|
PNG(.png) |
BMP |
|
• |
|
BMP (.bmp) |
WEBP |
• (Android4.0 +) |
• (Android4.0 +) |
|
WebP (. webp) |
Video |
H.263 |
• |
• |
|
1. 3GPP (. 3gp) 2. MPEG-4(.mp4) |
H.264 AVC |
• (Android3.0 +) |
• |
Baseline Profile (BP) |
1. 3GPP (. 3gp) 2. MPEG-4(.mp4) 3. PEG-TS (. ts, only AAC audio, unaddressable, Android3.0 +) |
MPEG-4 (SP) |
|
• |
|
3GPP (. 3gp) |
VP8 |
|
• (Android2.3.3 +) |
Only Android4.0 and above can be streamed |
1. WebM (. webm) 2. Matroska(.mkv, Android4.0 +) |
Video Encoding suggestions
Table 2 lists the video encoding Profile and parameter examples supported by the Android media framework. In addition to these encoding parameters, the available video recording Profile of the device can be used as a proxy for media playback. These profiles can be checked using the CamcorderProfile class after API Level 8.
Table 2. Examples of supported video encoding Parameters
|
SD (low quality) |
SD (high quality) |
HD (not all devices are available) |
Video codec |
H.264 Baseline Profile |
H.264 Baseline Profile |
H.264 Baseline Profile |
Video resolution |
176 x 144px |
480 x 360px |
1280 x 720px |
Video frame rate |
12fps |
30fps |
30fps |
Video bitrate |
56 Kbps |
500 Kbps |
2 Mbps |
Audio codec |
AAC-LC |
AAC-LC |
AAC-LC |
Audio channels |
1 (mono) |
2 (stereo) |
2 (stereo) |
Audio bitrate |
24 Kbps |
128 Kbps |
192 Kbps |
There are some additional requirements for streaming video content over HTTP or RTSP:
1. For 3GPP and MPEG-4 containers, the moov atom must be prior to any mdat atom, and the ftyp atom must be successful.
2. For 3GPP, MPEG-4 and WebM containers, the same time offset corresponding to audio and video sampling cannot exceed 500KB. We consider using small audio and video data blocks for crossover.