Skip to content

androidProbeMediaInfo

xinbaicheng edited this page Aug 4, 2016 · 9 revisions

探测视频信息功能

此功能主要有类KSYProbeMediaInfo实现

功能描述

探测视频,可得到该视频的文件封装格式、视频编码格式、视频宽高、音频编码格式、采样率、声道数等信息

版本要求

v1.4.4 及以上

基本示例

支持多线程同时探测多个视频

KSYProbeMediaInfo probeMediaInfo = new KSYProbeMediaInfo();
String url = "rtmp://live.hkstv.hk.lxdns.com/live/hks";
int probeTimeOutSecond = 10; // 超时阈值,单位为秒
// 探测视频信息
probeMediaInfo.probeMediaInfo(url, probeTimeOutSecond);

Log.e(TAG, "Media format:"+probeMediaInfo.getMediaFormat().toString()+", bitrate:"+probeMediaInfo.getMediaBitrate() +", video stream count:"+probeMediaInfo.getVideoStreamCount() + ", audio stream count:"+probeMediaInfo.getAudioStreamCount());

ArrayList<KSYProbeMediaInfo.KSYProbeMediaData> videoArray = probeMediaInfo.getVideoStreams();
for(KSYProbeMediaInfo.KSYProbeMediaData video : videoArray)
{
    Log.e(TAG, "Video codec type:"+video.getVideoCodecType().toString() + ",width:"+video.getVideoWidth()+", height:"+video.getVideoHeight());
}

ArrayList<KSYProbeMediaInfo.KSYProbeMediaData> audioArray = probeMediaInfo.getAudioStreams();
for(KSYProbeMediaInfo.KSYProbeMediaData audio : audioArray)
{
    Log.e(TAG, "Audio codec type:"+audio.getAudioCodecType().toString()+", channel:"+audio.getAudioChannel()+", sample rate:"+audio.getAudioSampleRate());
    Log.e(TAG, "Audio bitrate:"+audio.getAudioBitrate()+", frame size:"+audio.getAudioFrameSize()+", fmt:"+audio.getAudioFormat());
}
Clone this wiki locally