播放时如何更改AVPlayer视频质量

播放时如何更改AVPlayer视频质量

本文介绍了播放时如何更改AVPlayer视频质量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用库来播放URL中的视频,并且能够播放视频

I used this library for playing video from URL, and I am able to play video.

现在,我想更改当前播放的视频质量,例如(低,中,高).

Now I want to change the currently playing video quality like (low, medium, high).

图书馆使用AVPlayer,如何使用AVPlayer改变质量?

Library uses AVPlayer and how can i change quality with AVPlayer?

我听过首选峰值速率,但我对此一无所知.

I listen about preferred​Peak​Bit​Rate but I have no idea about it.

请帮助我该怎么做?

推荐答案

您不能直接在AVPlayer上设置视频质量,但是,可以通过访问AVPlayerItem上的videoComposition属性来实现此目的,然后将其提供给AVPlayer(例如,通过replaceCurrentItem:方法或在AVPlayer初始化时).所以:

You cannot set video quality directly on the AVPlayer, however, you can do this by accessing videoComposition property on AVPlayerItem which is then supplied to AVPlayer (via for example replaceCurrentItem: method or on AVPlayer initialization). So:

  1. 创建或获取AVPlayerItemAVVideoComposition实例,并将其设置为frameDurationrenderSizerenderScale属性.在文档中查看以获取更多信息.
  2. 将其设置为您的电影" videoComposition属性,AVPlayerItem实例(同样,请查看 docs 了解详情).
  3. 在播放器中播放.
  1. Create or get you AVPlayerItem's AVVideoComposition instance, and set it's frameDuration, renderSize and renderScale properties. Take a look in docs for more info.
  2. Set it to your "movie" videoComposition property, AVPlayerItem instance (again, look in docs for details).
  3. Play that in your player.

如果您想在播放电影时即时执行此操作,我想应该调整播放器项目的时间.

If you want to do this on the fly while playing movie, adjustments of time for player item should be done I guess.

这篇关于播放时如何更改AVPlayer视频质量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 20:35