1. 程式人生 > >Android MediaPlayer支援的音視訊格式和協議

Android MediaPlayer支援的音視訊格式和協議

一,對比Mediaplayer和IjkMediaPlayer

在寫完MediaPlayer的demo(紅米6.0.1系統)的時候,準備接入一下bilibili開源的ijkplayer的時候,在做對比的時候發現—
Mediaplayer對於:
1,raw下資原始檔主要指.mp4 .mkv
2,sd卡下的mp4,mkv
3,http協議下的MP4
4,https協議下的MP4
5,rm,rmvb格式視訊不支援

而對於ijkplayer的IjkMediaPlayer
1,raw下資原始檔
2,sd卡下的mp4,mkv
3,http協議下的MP4
這些是支援的,但是對於https,rm,rmvb的竟然不支援。後來發現在編譯的指定.so檔案以後就會支援https和更多其他格式的視訊檔案。
這個時候不禁想,那Mediaplayer到底支援哪些格式的檔案。所以才有了這篇文章。

二,支援格式

Supported Media Formats

This document describes the media codec, container, and network protocol support provided by the Android platform.

As an application developer, you can use any media codec that is available on any Android-powered device, including those provided by the Android platform and those that are device-specific. However, it is a best practice to use media encoding profiles that are device- agnostic.

The tables below describe the media format support built into the Android platform. Codecs that are not guaranteed to be available on all Android platform versions are noted in parentheses, for example: (Android 3.0+). Note that any given mobile device might support other formats or file types that are not listed in the table.

Section 5 of the Android Compatibility Definition specifies the media formats a device must support to be compatible with Android 8.1.
這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述

Video decoding recommendations

Device implementations must support dynamic video resolution and frame rate switching through the standard Android APIs within the same stream for all VP8, VP9, H.264, and H.265 codecs in real time and up to the maximum resolution supported by each codec on the device.

Implementations that support the Dolby Vision decoder must follow these guidelines:

Provide a Dolby Vision-capable extractor.
Properly display Dolby Vision content on the device screen or on a standard video output port (e.g., HDMI).
Set the track index of backward-compatible base-layer(s) (if present) to be the same as the combined Dolby Vision layer’s track index.

Video streaming requirements

For video content that is streamed over HTTP or RTSP, there are additional requirements:

For 3GPP and MPEG-4 containers, the moov atom must precede any mdat atoms, but must succeed the ftyp atom.
For 3GPP, MPEG-4, and WebM containers, audio and video samples corresponding to the same time offset may be no more than 500 KB apart. To minimize this audio/video drift, consider interleaving audio and video in smaller chunk sizes.

這裡寫圖片描述

以上就是官方文件。後續待ijkplayer研究完畢我會貼出我的github程式碼。歡迎關注