avfoundation

AVAssetWriterInput, impossible to choose video resolution?

荒凉一梦 提交于 2019-11-30 09:47:51
问题 It looks like no matter what AVVideoWidthKey , AVVideoHeightKey , AVVideoCleanApertureWidthKey , AVVideoCleanApertureHeightKey I choose, my video resolution will be either 320x240 or 480x360. I'm trying to save a video at 480p and all my buffers are 640x480, my session is at AVCaptureSessionPreset640x480 , everything is at 640x480 but still my output video is scaled down. I'm using AVAssetWriterInputPixelBufferAdaptor and the CMSampleBufferRef that I've pass into it it's at 640x480. I've

AVAudioPlayer.play() does not play sound

一笑奈何 提交于 2019-11-30 09:47:35
问题 Why doesn't the following code play a sound? It returns "true" for play(), but I cannot hear anything. let path = "/Users/account/Music/sound.mp3"; let fileURL = NSURL(fileURLWithPath: path) var Player = AVAudioPlayer(contentsOfURL:fileURL, error:nil); Player.delegate = self; Player.prepareToPlay(); Player.volume = 1.0; var res = Player.play(); println(res); If I use the following code instead, I can hear the sound. var inFileURL:CFURL = fileURL!; var mySound = UnsafeMutablePointer

Apple Mach-O Linker (ld) Error Group with Swift 3 & Xcode 9 GM

寵の児 提交于 2019-11-30 08:25:33
问题 This was running fine till GM Xcode (and iOS 11). Now I get these errors: Apple Mach-O Linker (ld) Error Group "__T0So20AVCapturePhotoOutputC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: xxxxxxxxxx "__T012AVFoundation37_AVCapturePhotoOutputSwiftNativeTypesPAAE012availableRawc11PixelFormatG0SaySo8NSNumberCGfg", referenced from: xxxxxxxxx " "__T0So22AVCapturePhotoSettingsC12AVFoundation01_abC16SwiftNativeTypesACWP", referenced from: xxxxxxxxxx ld: symbol(s) not found for

iPhone song lyrics access

…衆ロ難τιáo~ 提交于 2019-11-30 07:58:35
I'm trying to get the lyrics for a song on an iOS device and the examples I've found on the web and stackoverflow show getting the song's MPMediaItem (i.e. using a [MPMediaQuery songsQuery] with MPMediaItemPropertyPersistentID as a predicate) and then retrieving the lyrics using: [mediaItem valueForProperty:MPMediaItemPropertyLyrics] The problem is that this only works if you first open the song in the iPod music app and view the lyric there. Even if you do that the next time you sync it may stop working again. How can we get reliable access to lyrics? Solved: The following approach gets

Play multiple Audio Files with AVPlayer

余生颓废 提交于 2019-11-30 07:56:12
问题 I'm trying to play multiple sounds at the same time. The approach initially I've taken was to create several players , but it seems wrong one. What's the best way to play several audio files at the same time. Is it through making them AVAssets, but in this case how would I stop and play them whenever I want. Really appreciate your help. The reason I need AVPlayer is to fetch sounds from the iPod Library. I finally got an answer from TechSupport of Apple Dev Team and it seems I'm on the right

Swift 2.0: Type of Expression is ambiguous without more context?

*爱你&永不变心* 提交于 2019-11-30 07:49:55
The following used to work in Swift 1.2: var recordSettings = [ AVFormatIDKey: kAudioFormatMPEG4AAC, AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue, AVEncoderBitRateKey : 320000, AVNumberOfChannelsKey: 2, AVSampleRateKey : 44100.0] Now, it gives the error: "Type expression is ambiguous without more context". Stephan To comply to the required [String : AnyObject] format required by recordSettings parameter; In addition to @Unheilig's answer, you'll need to convert your ints and floats to NSNumber : let recordSettings : [String : AnyObject] = [ AVFormatIDKey: NSNumber(unsignedInt:

Captured photo is stretched with AVCaptureSession sessionPreset = AVCaptureSessionPresetPhoto

五迷三道 提交于 2019-11-30 07:31:45
问题 IMPORTANT: if I use: session.sessionPreset = AVCaptureSessionPresetHigh; my preview image is not stretched !! If I save the photo to the device UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); the image is normal, only in the preview it is stretched. I m using AVFoundation to capture photo. session = [[AVCaptureSession alloc] init]; session.sessionPreset = AVCaptureSessionPresetHigh; CALayer *viewLayer = vImagePreview.layer; NSLog(@"viewLayer = %@", viewLayer); AVCaptureVideoPreviewLayer

How to take UIImage of AVCaptureVideoPreviewLayer instead of AVCapturePhotoOutput capture

江枫思渺然 提交于 2019-11-30 07:15:00
问题 I want to "stream" the preview layer to my server, however, I only want specific frames to be sent. Basically, I want to take a snapshot of the AVCaptureVideoPreviewLayer, scale it down to 28*28, turn it into an intensity array, and send it to my socket layer where my python backend handles the rest. Problem here is that AVCapturePhotoOutput's capture function is insanely slow. I can't repeatedly call the function. Not to mention it always makes a camera shutter sound haha. The other problem

Video Recording using AVFoundation

≯℡__Kan透↙ 提交于 2019-11-30 07:13:48
I am trying to record video using AVFoundation. When I add video input only to the session, everything works fine but when I add an audio input to it, it stops recording the video.(Delegate method is called immediately after recording starts). Here is my code: -(void) recordVideo { self.session = [[AVCaptureSession alloc] init]; if([session canSetSessionPreset:AVCaptureSessionPresetMedium]) session.sessionPreset = AVCaptureSessionPresetMedium; CALayer *viewLayer = [self.cameraView layer]; AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession

I want to call 20 times per second the installTapOnBus:bufferSize:format:block:

给你一囗甜甜゛ 提交于 2019-11-30 07:02:29
I want to waveform display in real-time input from the microphone. I have been implemented using the installTapOnBus:bufferSize:format:block:, This function is called three times in one second. I want to set this function to be called 20 times per second. Where can I set? AVAudioSession *audioSession = [AVAudioSession sharedInstance]; NSError* error = nil; if (audioSession.isInputAvailable) [audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error:&error]; if(error){ return; } [audioSession setActive:YES error:&error]; if(error){ retur; } self.engine = [[[AVAudioEngine alloc] init]