Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adjust Quality while streaming video with AVPlayer

How can I able to set low or high quality video withstreaming video with AVPlayer?

My code is as follow:

self.videoPlayerItem = [AVPlayerItem playerItemWithURL:videoUrl];

    videoPlayer = [AVPlayer playerWithPlayerItem:self.videoPlayerItem];
    videoPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
    CGRect frame = self.frame;
    videoPlayerLayer = [AVPlayerLayer layer];
    [videoPlayerLayer setPlayer:videoPlayer];
    [videoPlayerLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill];

Thanks for your time

like image 293
user2526811 Avatar asked Mar 04 '26 15:03

user2526811


1 Answers

You can lower the video quality/bitrate by setting AVPlayerItem's preferredPeakBitRate.

Re-set it to zero to get the usual "highest quality/bitrate supported by your connection" behaviour.

N.B. A bitrate less than or equal to preferredPeakBitRate must be available for this to work, e.g. in an HLS stream.

like image 71
Rhythmic Fistman Avatar answered Mar 07 '26 04:03

Rhythmic Fistman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!