3

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).

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.

Please help me how can i do that?

Vikky
  • 736
  • 1
  • 5
  • 15
Kuldeep
  • 3,841
  • 6
  • 25
  • 50

1 Answers1

5

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. 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.

Wladek Surala
  • 2,392
  • 1
  • 23
  • 30
  • 1
    can you help me with demo code. like how can i achieve that? – Kuldeep Apr 05 '17 at 07:22
  • I suggest that you should update your question with your solution attempt (code) based on information I provided for you and then maybe can help you more. SO is not "free code" site, at least try to learn. – Wladek Surala Apr 05 '17 at 07:35
  • If i use this way to change resolution too lower size, will it help to save memory? – Frank Cheng Mar 08 '19 at 03:13
  • @FrankCheng probably, you can check it by running your app and looking at memory consumption in top-left corner of the Xcode interface (where? check this awesome graphic: https://cdn-images-1.medium.com/max/1200/1*ygeMI3iHCHnWVlbz_z8qvA.png), and voilaszek!:) – Wladek Surala Mar 08 '19 at 09:44