How can i change AVPlayer Video Quality while playing - ios

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?

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:
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.
Set it to your "movie" videoComposition property, AVPlayerItem instance (again, look in docs for details).
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.

Related

Manual Bit rate control of video in swift

I wanted to implement a video quality control in video player in swift.I have used preferredPeakBitRate of avplayer item but I am not able to change the quality of video while the video is playing.I have the manifest file URL that contains different bit rates of video.Kindly suggest me any third party video player that used manual video quality control or tell me how I can achieve using avplayer in swift.

AVPlayer does not keep the slo-motion effect

After recording a slo-motion video (the activeFormat, the activeVideoMinFrameDuration and the activeVideoMaxFrameDuration properties on the AVCaptureDevice object have been changed to the proper values), the slo-motion effect is missing when the video is played directly after the didFinishRecordingToOutputFileAt method has been called.
I tried to reduce the rate of the player and the video slows down but it's not the same as if I saved the video into the Library and then I play it.
Any idea on how I can achieve this ?

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?
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];
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.
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];

AVMutableComposition play blank with AVPlayer but export fine with AVAssetExportSession

I create an AVMutableComposition containing videos imported from the library. I pass an AVMutableVideoComposition containing an array of AVMutableVideoCompositionInstruction in order to transform (scale, rotate) and fade (opacity) between video tracks.
With most videos no problem occurs. I can play the composition using AVPlayer or export it using AVAssetExportSession without any problem. But for some videos when the composition is passed to an AVPlayer I get a black screen like when the timing of the differents AVMutableVideoCompositionInstruction are not set correctly. However when I export the exact same composition containing the exact same instruction and timing (actually the same composition) to an AVAssetExportSession the movie exports perfectly. If I play the imported video alone as simple AVAsset using the AVPlayer, the video play fine.
I tried to raise the time scale of my movie to 60000 instead of 600 hopping it was the duration of the imported video that was an issue (floating point being lost) but it is not the case.
It happens under iOS8 but may also happens under iOS7 I dont know.
PS: I didn't post code because there are far too many lines.

change avplayer play rate and then save video as a movie file

I have a video which I play by using avplayer.
And then I have a feature where user can change rate of the movie to go faster or slower. Is there a way to say this fast or slowed down movie?
I have looked into avassetwriter but I can't find a way to pass in a rate prperty.

Resources