Skip to content
shixuemei edited this page Sep 21, 2016 · 12 revisions

文件格式探测

描述

无需启动播放即可得到文件的音视频信息描述,如文件封装格式、视频编码格式、视频宽高、音频编码格式、采样率、声道数等信息

功能实现

示例代码

NSURL *url = [NSURL URLWithString:@"http://maichang.kssws.ks-cdn.com/upload20150716161913.mp4"];
KSYMediaInfoProber *prober = [[KSYMediaInfoProber alloc] initWithContentURL: url];
KSYMediaInfo *mediaInfo = prober.ksyMediaInfo;
if(mediaInfo)
{
    NSLog(@"mux type:%d", mediaInfo.type);
    NSLog(@"bitrate:%lld", mediaInfo.bitrate);

    for (KSYVideoInfo  *videoInfo in mediaInfo.videos) {
        NSLog(@"video codec:%d", videoInfo.vcodec);
        NSLog(@"video frame width:%d", videoInfo.frame_width);
        NSLog(@"video frame height:%d", videoInfo.frame_height);
    }
        
    for(KSYAudioInfo  *audioInfo in mediaInfo.audios)
    {
        NSLog(@"audio codec:%d", audioInfo.acodec);
        NSLog(@"audio language:%@", audioInfo.language);
        NSLog(@"audio bitrate:%lld", audioInfo.bitrate);
        NSLog(@"audio channels:%d", audioInfo.channels);
        NSLog(@"audio frame_size:%d", audioInfo.framesize);
        NSLog(@"audio sample_format:%d", audioInfo.sample_format);
        NSLog(@"audio samplerate:%d", audioInfo.samplerate);
    }
}
Clone this wiki locally