Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Video PlayBack Quality with AVPlayer?

How can I change Video Quality like YouTube?

Currently, I am playing with original quality and I am giving options like 360p, 480p, 720p for changing quality.

How can I change it?

like image 838
Kuldeep Avatar asked Apr 05 '17 07:04

Kuldeep


3 Answers

You cant do that simply with AVplayer. you require diffrent URL for different quality video. When user select other quality, you can switch to that video with replaceCurrentItemWithPlayerItem method fo AVPlayer.

AVPlayerItem *playeriem= [AVPlayerItem playerItemWithURL:urlOfSelectedQualityVideo];
[playeriem seekToTime:player.currentTime];
[player replaceCurrentItemWithPlayerItem:playeriem];
like image 78
PlusInfosys Avatar answered Nov 16 '22 03:11

PlusInfosys


In order to do such things like converting video you should use FFmpeg library. Try to look for some libraries that use ffmpeg on github.

Like this one: https://github.com/iMoreApps/ffmpeg-avplayer-for-ios-tvos

You can't do that with AVPlayer. When just streaming you use M3U index files, TS files containing the video data and just switch streams.

Check out Apple's HLS Documentation and playlist Examples.

like image 3
Oleh Zayats Avatar answered Nov 16 '22 02:11

Oleh Zayats


You can also create multiple renditions of m3u8 one with lower quality video bitrates say 128k to 650k and another one with 650k + to higher bitrates and use a higher quality stream URL suggested in the answer above

AVPlayerItem *playeriem= [AVPlayerItem playerItemWithURL:urlOfSelectedQualityVideo];
like image 2
Umar Cheema Avatar answered Nov 16 '22 03:11

Umar Cheema