AVPlayer does not keep the slo-motion effect - ios

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 ?

Related

Is there any way to record video with AVCaptureMovieFileOutput and change cameras?

I want to record a video with AVFoundation and AVCaptureSession using AVCaptureMovieFileOutput.
I want to record a video like Instagram Stories, so I want to change the camera while the video is recording. The problem with AVCaptureMovieFileOutput is that when I change the captureDevice in the captureSession the delegate method AVCaptureFileOutputRecordingDelegate sends an error with the text Recording stopped and everything stops.
I've thought about stopping the front camera video before I change the camera, and save it, then save the back camera video and join them in the same video. Is this a good option? Or Should I use AVCaptureVideoDataOutput to achieve this?

Record video with custom camera UI but prevent save

I'm using AVCaptureFileOutputRecordingDelegate - didFinishRecordingToOutputFileAt inside my custom camera UI, but I don't want to pass for this method because the video is been saved when it finish recording.
For legacy reasons I can't save the video locally, then to take it in a static instance and delete it from local.
How can I do that ?
AVFoundation framework has only the following output for a capture session.
AVCaptureMovieFileOutput - to record and output a movie file
AVCaptureVideoDataOutput - process frames from video being captures
AVCaptureAudioDataOuput - process audio data being captures
AVCaptureStillImageOutput - to capture still image output
Since you don't want to save the recorded video to a file. The other best option would be using AVCaptureVideoDataOutput and get each frame on a continuous recording video and create a video from image buffer. To make a note you will not have audio output in this case. Again we can add AVCaptureAudioDataOuput and embed the audio separately on our recorded video. But this workaround will not work for higher frame rates. So best suggestion to save the video into temp folder and delete it later.

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.

Why does audio cut out briefly when changing video input on an AVCaptureSession?

I am using the sample code from Switch cameras with avcapturesession to swap from the iPhone's front camera to its back one during a recording session. Only the video AVCaptureDeviceInput is changed; neither the audio input device nor the AVCaptureSession itself is changed. Even so, there's a clear break in the audio during the camera swap. Why is this?
And is there any workaround? For instance, would using an AVAudioRecorder instead to record the audio separately allow for continuous audio recording during a camera flip? I could then stitch it to the video later, even though that would be a pain.
When switching the video camera, the audio input also changes. When recording with the front camera, the front mic is used. Some audio packets are lost in this process.
I encountered the same problem, and using AVAudioRecorder to record the audio separately and AVMutableComposition to combine the audio and video tracks after recording worked perfectly.

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