avfoundation

Creating a movie file of a animation with avassetwriter

北慕城南 提交于 2019-12-04 14:28:02
问题 I have a animation created using normal core animation methods. If there any way to create a movie file using avassetwriter? Ive seen other questions which show the how to use avassetwriter to create a movie using images, but i would like to create a movie using a animation created with core animation. Thank in advance 回答1: Run a timer (or whatever) to periodically convert the animation's CALayer to a UIImage (see here), then write that image to the AVAssetWriter as seen in the other examples

What's the SIMPLEST way to play a sound clip in an iPhone app?

纵饮孤独 提交于 2019-12-04 14:05:50
问题 I want to be able to play a sound clip in an iPhone OS app. I've seen info on both NSSound as well as AVFoundation as being means for getting sound clips played on an iPhone OS device, but I'm still not clear on the subject and could use some help. No need to spell it out for me step-by-step in actual code, but if someone could give me a hint as to the general direction (i.e. which classes I should be focusing on) in which I should start moving I'll fill in the blanks myself. So, what's the

Modify AVCaptureSession before saving with AVCaptureMovieFileOutput

眉间皱痕 提交于 2019-12-04 14:00:16
问题 Use Case: I want to capture input from the camera, draw on top of the captured frames (and sound) and save the result as a .mov file. I see that I can capture input for the camera using AVCaptureSession. I can save this to a .mov file using AVCaptureMovieFileOutput. AVVideoComposition can be used to add Core Animation for playback. I assume for recording somehow too? Problem: I can't see how to modify the input before it is saved to file. 回答1: The RosyWriter was almost doing what I wanted.

How to route to kAudioSessionProperty_OverrideCategoryEnableBluetoothInput without using AudioSessionSetProperty

柔情痞子 提交于 2019-12-04 13:42:39
My iOS6 and working code to set bluetooth as an output: // create and set up the audio session AVAudioSession* audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory: AVAudioSessionCategoryPlayAndRecord error: nil]; [audioSession setActive: YES error: nil]; // set up for bluetooth microphone input UInt32 allowBluetoothInput = 1; OSStatus stat = 0; stat = AudioSessionSetProperty ( kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput ); The method AudioSessionSetProperty is deprecated since iOS7. Following this thread

Record video while other video is playing

橙三吉。 提交于 2019-12-04 13:42:18
问题 I am using UIImagePickerController to record a video. and am using AVPlayer to play a video. and adding AVPlayerLayer to UIImagePickerController's cameraOverlayView so that i can see video while recording. My requirement is I need to watch video while recording video using UIImagePickerController using headset i need to listen audio from playing video need to record my voice to recording video only my voice should be recorded but not playing video's audio. every thing working but 4. audio

how to monitor audio input on ios using swift - example?

扶醉桌前 提交于 2019-12-04 13:34:30
I want to write a simple app that 'does something' when the sound level at the mic reaches a certain level, showing the audio input levels for extra credit cant find any examples in swift that get to this -- dont want to record, just monitor have been checking out the docs on the AVFoundation classes but cant get off the ground thanks Let you can use below code : func initalizeRecorder () { do { try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord) try AVAudioSession.sharedInstance().setActive(true) }catch{ print(error); } let stringDir:NSString = self

iOS rotate every frame of video

非 Y 不嫁゛ 提交于 2019-12-04 13:33:21
问题 I need to rotate a video because of iPhone back camera is recording as if it were always on landscape left. I need to physically rotate video because settings orientation don't work on all browser (ex. Chrome). So I setup some code to read recorded video and saving it after rotation. I used AVAssetExportSession which seems to work quite well apart two problems: - the exported video have some black frames at the beginning - some videos won't be exported. Is it possible to have some insight

Making CIContext.render(CIImage, CVPixelBuffer) work with AVAssetWriter

五迷三道 提交于 2019-12-04 12:44:10
I want to use Core Image for processing a bunch of CGImage objects and turning them into a QuickTime movie on macOS . The following code demonstrates what's needed, but the output contains a lot of blank (black) frames : import AppKit import AVFoundation import CoreGraphics import Foundation import CoreVideo import Metal // Video output url. let url: URL = try! FileManager.default.url(for: .downloadsDirectory, in: .userDomainMask, appropriateFor: nil, create: false).appendingPathComponent("av.mov") try? FileManager.default.removeItem(at: url) // Video frame size, total frame count, frame rate

load a pcm into a AVAudioPCMBuffer

*爱你&永不变心* 提交于 2019-12-04 12:31:42
问题 I have this code: func loadSoundfont(_ pitch : String) { let path: String = Bundle.main.path(forResource: "\(self.id)/\(pitch)", ofType: "f32")! let url = URL(fileURLWithPath: path) do { let file = try AVAudioFile(forReading: url, commonFormat: AVAudioCommonFormat.pcmFormatFloat32, interleaved: true) let format = file.processingFormat let capacity = AVAudioFrameCount(file.length) self.buffer = AVAudioPCMBuffer(pcmFormat: format, frameCapacity: capacity) try file.read(into: self.buffer!) }

Video not rotating using AVMutableVideoCompositionLayerInstruction

我是研究僧i 提交于 2019-12-04 12:31:34
问题 I'm trying to merge two videos I get after recording using the camera as a UIImagePickerController. I've succeeded with combining the videos into one but I have some problems with the orientation of the videos. As I've understood it with the UIImagePickerController is that all videos are captured in landscape, this means that the videos recorded in portrait are rotated 90°. After each recording I add the new video to an array func imagePickerController(picker: UIImagePickerController!,