AVAssetWriter: preview recorded .mp4 before calling `finishWriting`? - ios

I am using AVAssetWriter to record a video (with audio) form iOS camera. Everything works great.
I now want to allow the user to preview the video before saving, meaning, before calling finishWriting on the AVAssetWriter instance.
My original thought was to copy the current file the writer is writing to during recoding to a preview url, and then use another AVAssetWriter to finalize that file and then play it.
However, I am not sure how to properly initialize a second AVAssetWriter for preview purposes, so I can call finishWriting on it at the preview url...
Anyone knows how I could implement preview functionality to allow a user to preview the currently recorded mp4 before calling finishWriting?

Anyone knows how I could implement preview functionality to allow a user to preview the currently recorded mp4 before calling finishWriting?
You must call finishWriting in order to have a viewable mp4 file.
So call finishWriting, let the user preview the resulting file and then decide whether to delete it or keep it.

Related

Playing audio from a .mov file with Swift

Basically, my app allows the user to select a video from photo library, and I want to be able to play back the audio exclusively. However, AVAudioPlayer doesn't seem to accept .mov file paths, is there any way to work around this??

How to get the video path of the Replay Kit?

Our app is a live app, do a video screen function, i use the replaykit. I want to customize the video preview, but i can not get the video of the recorded path.

Blocking default player to play audio files ios

My App has functionality to record and play audio using AVAudioRecorder/AVAudioPlayer respectively. Whenever I download an audio file from the server, the file is opened automatically using the default player with a black screen as shown:
However, I actually have my own user interface to play audio files. How can I block this option programmatically?

How to implement screen recording with audio in iOS programmatically?

I have a requirement where I have screen recording with audio as well. I have done some Google and got to know about how can we implement screen recording but I am wondering how to save audio while screen recording.
Is there any possibility that we can merge the video and audio and then save the final data on disk?
But I am not sure that will it be feasible because there will be difference in syncing with audio and video frames.
For screen recording I got a link of ScreenCaptureView which actually lets you save the screen recording.
On iOS9 there is ReplayKit it's a framework that can be used to make screen recording on video games. It seems that you can use also for common screen capture.
For lower platforms it's a kind of big deal, video screen capturing exists but is a private framework ( I guess IOSurface). There are some work arounds as in this project , basically it starts to grab sigle screenshot and append them into a movie file, without audio

Play mp4/youtube movie while recording with camera

I'm developing my first iOS app, and I need to record a video with the camera while playing a youtube video embedded in a UIWebView. The problem is, the video stops playing when I start the capture.
Is there any workaround? I thought of playing the video in an openGL texture, then play the audio at the same time, but I don't know how to do. I don't need the player to have control buttons, etc.
I've tried to use the RosyWriter sample code and change the input source.
How can this be done?
[EDIT]
I finnaly solved my problem in another way. I don't use RosyWriter anymore, but AVCamRecorder, and for playing video, I get the url of the .mp4 file with PSYoutubeExtractor, then i play it via MPMoviePlayer.
I had to set [[AVAudioSession sharedInstance] setCategory:AVAudioSessionSetCategoryPlayAndRecord error:nil]
Hope this will help someone.
I don't uderstand what you are trying to do. PSYoutubeExtractor doen't record anything, it's only designed to give you the direct MP4 url. To record a tune/movie, you should use an AVAsset, then export it to mp3/mp4.
I'm really sorry, but this project was for my internship in a company, and I havn't keep any piece of code anymore. But if you have a precise problem I already faced, I can try to help you.
Good luck.

Resources