How to change Video PlayBack Quality with AVPlayer? - ios

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

Related

How can I forbid AVPlayer switching to audio only tracks in HLS stream

The main source of my worries comes from the m3u8 manifests I use to play video in my app.
They contain variants with audio & video and some containing only audio.
The problem occurs when I load this type of manifest in avplayercontroller/avplayer while having a bad network or low bandwidth.
In every case avplayer witch to the tracks with no video to clear some bandwidth, resulting in no image appearing on the player.
I would like to know if there is a way to force avplayer or avplayercontroller to only focus on the manifest tracks containing audio and video and forbid audio only tracks to be selected, loaded, and played.
Thank you in advance to any tips or pointers you can give me on this subject.

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.

How can i change AVPlayer Video Quality while playing

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.

iOS : How to apply audio effect on recorded video

I am developing an application which require to apply audio effect on recorded video.
I am recording video using GPUImage library. I can successfully done with it. Now, I need to apply audio effect like Chipmunk, Gorila, Large Room, etc.
I looked into Apple's document and it say that AudioEngine can't apply AVAudioUnitTimePitch on Input Node (as Microphone).
For solving this problem, I use following mechanism.
Record video & audio at same time.
Play video. While playing video, start AudioEngine on Audio file and apply AVAudioUnitTimePitch on it.
[playerNode play]; // Start playing audio file with video preview
Merge video and new effected audio file.
Problem :
User have to preview a full video for audio effect merge. This is not a good solution.
If I set volume of playerNode to 0 (zero). Then It record mute video.
Please provide any better suggestion to do this things. Thanks in advance.

iOS Capture Video from Camera and Mixing with audio file in real time

I am trying to capture video from iPhone camera and save the movie mixed with an audio file.
I can capture the video with the audio (from mic) with no problems. What I want to do is capture the video but instead of mic audio, use a music track (a .caf file).
I am capturing the video with AVAssetWriter. I've tried to set up an AVAssetReader to read the audio file, but I couldn't make it work with the AVAssetWriter (maybe because the decoding of audio happens real fast).
Also, I don't want to save the movie without audio and mix it afterwards with an AVAssetExportSession. It would be to slow for my purpose.
Any Ideas ? Thanks in advance.
Capture the video using AVAssetWriter, Capture audio lets say with AvAudioRecorder , then mix audio and video using AVExportSession , lots of posts on this topic.
If you do it after (with AVAssetExportSession) , you will problem with the sync. and short delay (time...) between the video and the audio...didn't find better solution

Resources