在检索比特率时无法使用HLS获取AVAsset的轨道 [英] Unable to get tracks of AVAsset using HLS while retrieveing bitrate

查看:220
本文介绍了在检索比特率时无法使用HLS获取AVAsset的轨道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用HLS流,我正在使用AVPlayer。
现在我想使用AVAsset获得视频轨道的比特率。虽然我添加了观察者和其他东西,但我总是将轨道数组视为空。我是在正确的轨道上还是遗漏了什么?

I am using HLS streaming in my application and I am using AVPlayer. Now I want to get bitrate of the video track using AVAsset. Although I have added observer and other stuff I am getting tracks array as empty always.Am I on right track or missing anything?

推荐答案

HLS是自适应的,因此,比特率可以基于各种条件在流的持续时间内变化。你在完全错误的轨道上,不像播放文件,无论是本地还是网络URL,currentItem.asset.tracks将始终为零。

HLS is adaptive, therefore, bitrate can vary across the duration of the stream based on various conditions. You are on completely the wrong track, unlike playing a file, either local or from a network URL, currentItem.asset.tracks will always be nil.

你需要查询AVPlayer的currentItem的accessLog并检查相应的事件。

You'll need to query the AVPlayer's currentItem's accessLog and inspect the appropriate "events".

文档中的以下内容应该为您提供所需的信息;

The following from the documentation should give you the information you need;

看看;

AVPlayerItemAccessLog

AVPlayerItemAccessLogEvent

编辑:

您可能会从阅读apple的实时流媒体概述
这将使您更好地了解.m3u8索引文件,特别是媒体文件可以是以各种比特率编码以适应不同的网络吞吐量/拥塞。客户端负责在以不同比特率编码的段之间切换。

You might benefit from reading apple's Live streaming overview this will give you a better understanding of the .m3u8 index files, specifically that the media file can be encoded for various bit rates to accommodate different network throughput/congestion. The client is responsible for switching between segments encoded at different bit rates.

observeMinBitrate和observedMaxBitrate可能是您认为最有用的属性,但是知道你的预期用途,如果有任何意义就足够了。请注意,根据文档,这些是每段(请参阅概述以更好地理解段)。

The observedMinBitrate and observedMaxBitrate are likely to be the properties you'll find most useful, however withought knowing your intended use, it's hart to say if any will suffice. Keep in mind also, as per the Docs, these are Per Segment (refer to the overview for a better understanding of segment).

这篇关于在检索比特率时无法使用HLS获取AVAsset的轨道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆