本文介绍了从m3u流获取流的带宽的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将AVURAsset与HLS网址一起使用.响应如下所示

I'm using AVURAsset with a HLS url. The response is like below

    QualityLevels(1020000)/Manifest(video,format=m3u8-aapl)
    #EXT-X-I-FRAME-STREAM-   INF:BANDWIDTH=1189576,RESOLUTION=668x376,CODECS="avc1.4d401f",URI="QualityLevels(1020000)/Manifest(video,format=m3u8-aapl,type=keyframes)"
    #EXT-X-STREAM-INF:BANDWIDTH=1810952,RESOLUTION=924x520,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="audio"


   QualityLevels(1628000)/Manifest(video,format=m3u8-aapl)
   #EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1810952,RESOLUTION=924x520,CODECS="avc1.4d401f",URI="QualityLevels(1628000)/Manifest(video,format=m3u8-aapl,type=keyframes)"
   #EXT-X-STREAM-INF:BANDWIDTH=2803314,RESOLUTION=1280x720,CODECS="avc1.640029,mp4a.40.2",AUDIO="audio"

我可以使用AVFoundation类从此播放列表文件中获取元数据吗,例如带宽,分辨率?

Can I get the metadata from this playlist file with AVFoundation class, like bandwidth, resolution?

推荐答案

您可以按照自然尺寸来获得视频的分辨率,如下

You can get the resolution of video as its natural size as following AVURLAsset getting video size

关于带宽,它可能是视频的比特率.您可以尝试此实现

Regarding bandwidth, it is probably bit-rate of video. You can try this implementation

- (int)getBandwidth:(AVPlayer *)moviePlayer {
    VPlayerItemAccessLog *log = [moviePlayer.currentItem accessLog];
    NSArray *events = [log events];
    AVPlayerItemAccessLogEvent *event = [events lastObject];
    return ((int) ceilf(event.indicatedBitrate / 1000.0));
}

我希望这会有所帮助.

这篇关于从m3u流获取流的带宽的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 13:58