avfoundation

How to generate an UIImage from AVCapturePhoto with correct orientation?

浪子不回头ぞ 提交于 2019-12-04 08:37:44
问题 I am calling AVFoundation 's delegate method to handle a photo capture, but I am having difficulty converting the AVCapturePhoto it generates into an UIImage with the correct orientation. Although the routine below is successful, I always get a right-oriented UIImage ( UIImage.imageOrientation = 3). I have no way of providing an orientation when using the UIImage(data: image) and attempting to first use photo.cgImageRepresentation()?.takeRetainedValue() also doesn't help. Please assist. Image

Creating CMSampleBufferRef from the data

时间秒杀一切 提交于 2019-12-04 08:37:16
问题 I am trying to create a CMSampleBuffer Ref from the data and trying to feed it to AVAssetWriter. But asset writer is failing to create the movie from the data. Following is the code to create the CMSampleBufferRef. CVImageBufferRef cvimgRef = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(cvimgRef,0); uint8_t *buf=(uint8_t *)CVPixelBufferGetBaseAddress(cvimgRef); int width = 480; int height = 360; int bitmapBytesPerRow = width*4; int bitmapByteCount =

How to generate audio wave form programmatically while recording Voice in iOS?

拟墨画扇 提交于 2019-12-04 07:46:52
问题 How to generate audio wave form programmatically while recording Voice in iOS? m working on voice modulation audio frequency in iOS... everything is working fine ...just need some best simple way to generate audio wave form on detection noise... Please dont refer me the code tutorials of...speakhere and auriotouch... i need some best suggestions from native app developers. I have recorded the audio and i made it play after recording . I have created waveform and attached screenshot . But it

Weird behaviour of AVMutableComposition freezing while using AVMutableVideoComposition

喜夏-厌秋 提交于 2019-12-04 07:33:09
I am trying to merge multiple videos using AVMutableComposition . The problem I face is that whenever I try to add any AVMutableVideoComposition for applying any instructions, my playback freezes in AVPlayer at exact 6 seconds duration. Another interesting thing is that it plays fine if I play it in Photos app of iPad after exporting using same videoComposition . So why does it freezes in AVPlayer at 6 seconds? Code: AVMutableComposition *mutableComposition = [AVMutableComposition composition]; AVMutableCompositionTrack *videoCompositionTrack = [mutableComposition addMutableTrackWithMediaType

Reloading keys in AVAsset when status is AVKeyValueStatusFailed

依然范特西╮ 提交于 2019-12-04 07:15:23
I'm doing the following: Create a new AVAsset with a given URL. That URL points to a video on a remote web server. Attempt to load the tracks property by calling loadValuesAsynchronouslyForKeys:completionHandler: The initial request fails, because no internet connection exists I notice that the request failed by calling statusOfValueForKey:error: I then wait for the connection to re-appear (using some reachability code). As soon as it does, I call loadValuesAsynchronouslyForKeys:completionHandler: again. Here's where the problems begin. I would imagine that the AVAsset goes ahead and attempts

How to add external WebVTT subtitles into HTTP Live Stream on iOS client

浪子不回头ぞ 提交于 2019-12-04 07:14:55
We have videos encoded via bitmovin.com and provided as HTTP Live Streams (Fairplay HLS), but subtitles although in WebVTT format are exposed separately as direct URLs for the whole file, not individual segments and are not part of the HLS m3u8 playlist. I am looking for the way how an external .vtt file downloaded separately can still be included in the HLS stream and be available as a subtitle in AVPlayer. I know Apple's recommendation is to include segmented VTT subtitles into the HLS playlist, but I can't change the server implementation right now, so I want to clarify if it is even

How to get lyrics for Now Playing song in iOS10 (Swift 3)

て烟熏妆下的殇ゞ 提交于 2019-12-04 06:59:59
I want to display lyrics from song that is currently playing by iOS system player. Here is my custom player: import UIKit import MediaPlayer import AVFoundation class NowPlayingController: NSObject { var musicPlayer: MPMusicPlayerController { if musicPlayer_Lazy == nil { musicPlayer_Lazy = MPMusicPlayerController.systemMusicPlayer() let center = NotificationCenter.default center.addObserver(self, selector: #selector(self.playingItemDidChange), name: NSNotification.Name.MPMusicPlayerControllerNowPlayingItemDidChange, object: musicPlayer_Lazy) musicPlayer_Lazy!

How to convert code AVFoundation objective c to Swift?

て烟熏妆下的殇ゞ 提交于 2019-12-04 06:32:58
I am using AVFoundation in swift for take pictures but I can't convert any func lines of code from objective c to Swift. My func code is: - (void) capImage { //method to capture image from AVCaptureSession video feed AVCaptureConnection *videoConnection = nil; for (AVCaptureConnection *connection in stillImageOutput.connections) { for (AVCaptureInputPort *port in [connection inputPorts]) { if ([[port mediaType] isEqual:AVMediaTypeVideo] ) { videoConnection = connection; break; } } if (videoConnection) { break; } } NSLog(@"about to request a capture from: %@", stillImageOutput);

Why does CMSampleBufferGetImageBuffer return NULL

十年热恋 提交于 2019-12-04 06:10:26
I have built some code to process video files on OSX, frame by frame. The following is an extract from the code which builds OK, opens the file, locates the video track (only track) and starts reading CMSampleBuffers without problem. However each CMSampleBufferRef I obtain returns NULL when I try to extract the pixel buffer frame. There's no indication in iOS documentation as to why I could expect a NULL return value or how I could expect to fix the issue. It happens with all the videos on which I've tested it, regardless of capture source or CODEC. Any help greatly appreciated. NSString

Swift AVCaptureSession Close Open Button Error : Multiple audio/video AVCaptureInputs are not currently supported

别等时光非礼了梦想. 提交于 2019-12-04 06:05:53
I have a working barcode scanner code. When I click the openCamera button, first time everything is good. When I click the closeCamera button, good, but if I click again the openCamera button gives a fatal error. Code and error are below. In fact, is it possible to toggle camera view with one button? // Barcode Camera Properties let captureSession = AVCaptureSession() var captureDevice:AVCaptureDevice? var captureLayer:AVCaptureVideoPreviewLayer? override func viewDidLoad() { super.viewDidLoad() self.cameraView.alpha = 0 } @IBAction func closeCamera(sender: AnyObject) { self.captureLayer!