avfoundation

AVAssetWriterInput and readyForMoreMediaData

时光总嘲笑我的痴心妄想 提交于 2019-12-18 16:34:19
问题 Is AVAssetWriterInput's readyForMoreMediaData updated in a background thread? If readyForMoreMediaData is NO, can I block in the main thread and wait until the value changes to YES? I'm using an AVAssetWriterInput by pushing data to it (i.e. without using requestMediaDataWhenReadyOnQueue) and I've set expectsMediaDataInRealTime, and 99.9% of the time I can just call appendSampleBuffer (or appendPixelBuffer) on it as fast as my app can generate frames. This works fine unless you put the device

AVFoundation - Adding blur background to video

痞子三分冷 提交于 2019-12-18 12:45:01
问题 I am working on a video editing app in Swift . In my case my output video looks like as following I am trying to fill the black portion with blur effect exactly like this I searched but didn't get any working solution. Any assistance would be a great help. 回答1: Swift 4 - Adding blur background to video 1. Single video support ❤️ 1. Multiple videos merging support ❤️ 2. Support any canvas in any ratio ❤️ 3. Save final video to camera roll ❤️ 5. Manage all video orientations ❤️ May be I'm late

Video freezes on camera switch with AVFoundation

孤者浪人 提交于 2019-12-18 12:36:40
问题 I made an app with a feature to capture and save video. I have used AVFoundation for that and Apple's AVCam has been my guide. I hope I can make it clear: Everything works fine until I release the videoViewController that handles the AVCamCaptureManager for the first time (In AVCam that would be AVCamViewController). After that when I create it again, the video freezes right after camera switch. Even re-run will not help, nor will clean, or device reset. (Sometimes one of the things help, but

Video freezes on camera switch with AVFoundation

痞子三分冷 提交于 2019-12-18 12:36:30
问题 I made an app with a feature to capture and save video. I have used AVFoundation for that and Apple's AVCam has been my guide. I hope I can make it clear: Everything works fine until I release the videoViewController that handles the AVCamCaptureManager for the first time (In AVCam that would be AVCamViewController). After that when I create it again, the video freezes right after camera switch. Even re-run will not help, nor will clean, or device reset. (Sometimes one of the things help, but

AVAudioRecorder averagePowerForChannel always returns -120.0

走远了吗. 提交于 2019-12-18 12:27:07
问题 I'm trying to use AVAudioRecorder's averagePowerForChannel method to monitor input levels on the microphone for an iPad/iPhone app. I have a callback which polls the average level in a loop — on the iPhone it works fine and returns sensible levels, but for some reason on the iPad it always returns -120.0. Here's some of my setup code: - (void) setupMic { if (micInput) { [micInput release]; micInput = nil; } NSURL *newURL = [[NSURL alloc] initFileURLWithPath:@"/dev/null"]; NSMutableDictionary

Animate AVPlayerLayer videoGravity property

回眸只為那壹抹淺笑 提交于 2019-12-18 12:08:26
问题 I'm trying to copy Apple's behavior in video playback that allows the user to stretch the video image to fill the bounds. @interface FHVideoPlayerView : UIView @end @interface FHVideoPlayerView + (Class)layerClass { return [AVPlayerLayer class]; } - (void)setAspectMode:(FHVideoPlayerAspectMode)aspectMode animated:(BOOL)animated { FHVideoPlayerAspectMode current = [self aspectMode]; FHVideoPlayerAspectMode final = aspectMode; NSString *fromValue; NSString *toValue; AVPlayerLayer *layer =

Deep Copy of Audio CMSampleBuffer

喜你入骨 提交于 2019-12-18 11:55:55
问题 I am trying to create a copy of a CMSampleBuffer as returned by captureOutput in a AVCaptureAudioDataOutputSampleBufferDelegate . The problem I am having is that my frames coming from delegate method captureOutput:didOutputSampleBuffer:fromConnection: being dropped after I retain them in CFArray for long time. Obviously, I need to create deep copies of incoming buffers for further processing. I also know that CMSampleBufferCreateCopy only creates shallow copies. There are few related

AVFoundation Image orientation off by 90 degrees in the preview but fine in Camera roll

£可爱£侵袭症+ 提交于 2019-12-18 11:53:36
问题 Something really strange is happening, I am trying to capture an image using AVFoundation, the Camera roll image seems just fine, but the image preview has the image rotated by 90 degrees. This is the code I am using to capture an image AVCaptureConnection *videoConnection = nil; for (AVCaptureConnection *connection in stillImageOutput.connections) { for (AVCaptureInputPort *port in [connection inputPorts]) { if ([[port mediaType] isEqual:AVMediaTypeVideo] ) { videoConnection = connection;

Most memory efficient way to save a photo to disk on iPhone?

♀尐吖头ヾ 提交于 2019-12-18 11:27:16
问题 From profiling with Instruments I have learned that the way I am saving images to disk is resulting in memory spikes to ~60MB . This results in the App emitting low memory warnings , which (inconsistently) leads crashes on the iPhone4S running iOS7 . I need the most efficient way to save an image to disk. I am currently using this code + (void)saveImage:(UIImage *)image withName:(NSString *)name { NSData *data = UIImageJPEGRepresentation(image, 1.0); DLog(@"*** SIZE *** : Saving file of size

Caching with AVPlayer and AVAssetExportSession

纵饮孤独 提交于 2019-12-18 11:13:55
问题 I would like to cache progressive-download videos using AVPlayer. How can I save an AVPlayer's item to disk? I'm trying to use AVAssetExportSession on the player's currentItem (which is fully loaded). This code is giving me " AVAssetExportSessionStatusFailed (The operation could not be completed) " : AVAsset *mediaAsset = self.player.currentItem.asset; AVAssetExportSession *es = [[AVAssetExportSession alloc] initWithAsset:mediaAsset presetName:AVAssetExportPresetLowQuality]; NSString *outPath