avfoundation

How to save photos taken using AVFoundation to Photo Album?

十年热恋 提交于 2019-11-28 16:22:23
问题 AVFoundation is just great for those who want to get hands dirty, but there still a lot of basic stuff not easy to figure like how to save the pictures taken from device to Photo Album Any ideas? 回答1: Here is a step by step tutorial on how to capture an image using AVFoundation and save it to photo album. Add a UIView object to the NIB (or as a subview), and create a @property in your controller: @property(nonatomic, retain) IBOutlet UIView *vImagePreview; Connect the UIView to the outlet

Cropping AVAsset video with AVFoundation

﹥>﹥吖頭↗ 提交于 2019-11-28 16:15:41
I am using AVCaptureMovieFileOutput to record some video. I have the preview layer displayed using AVLayerVideoGravityResizeAspectFill which zooms in slightly. The problem I have is that the final video is larger, containing extra image that didn't fit on the screen during preview. This is the preview and resulting video Is there a way I can specify a CGRect that I want to cut from the video using AVAssetExportSession ? EDIT ---- When I apply a CGAffineTransformScale to the AVAssetTrack it zooms into the video, and with the AVMutableVideoComposition renderSize set to view.bounds it crops off

Can I use AVFoundation to stream downloaded video frames into an OpenGL ES texture?

假装没事ソ 提交于 2019-11-28 16:07:16
I've been able to use AVFoundation's AVAssetReader class to upload video frames into an OpenGL ES texture. It has a caveat , however, in that it fails when used with an AVURLAsset that points to remote media. This failure isn't well documented, and I'm wondering if there's any way around the shortcoming. There's some API that was released with iOS 6 that I've been able to use to make the process a breeze. It doesn't use AVAssetReader at all, and instead relies on a class called AVPlayerItemVideoOutput . An instance of this class can be added to any AVPlayerItem instance via a new -addOutput:

Face Detection with Camera

柔情痞子 提交于 2019-11-28 15:50:03
问题 How can I do face detection in realtime just as "Camera" does? I noticed that AVCaptureStillImageOutput is deprecated after 10.0, so I use AVCapturePhotoOutput instead. However, I found that the image I saved for facial detection is not so satisfied? Any ideas? UPDATE After giving a try of @Shravya Boggarapu mentioned. Currently, I use AVCaptureMetadataOutput to detect the face without CIFaceDetector . It works as expected. However, when I'm trying to draw bounds of the face, it seems

Timeline Progress bar for AVPlayer

醉酒当歌 提交于 2019-11-28 15:09:51
问题 AVPlayer is fully customizable, unfortunately there are convenient methods in AVPlayer for showing the time line progress bar. AVPlayer *player = [AVPlayer playerWithURL:URL]; AVPlayerLayer *playerLayer = [[AVPlayerLayer playerLayerWithPlayer:avPlayer] retain];[self.view.layer addSubLayer:playerLayer]; I have an progress bar that indicates the how video has been played, and how much remained just as like MPMoviePlayer . So how to get the timeline of video from AVPlayer and how to update the

swift: how to delete part of audio?

南笙酒味 提交于 2019-11-28 13:02:52
I'm creating a simple audio editing tool to trim and delete from an audio. I implemented the trim function and it is working fine. However I searched and tried to implement the delete function and here is my code: func deleteExportAsset(_ asset: AVAsset, fileName: String, completeAudioTime: CGFloat) -> URL { print("\(#function)") let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let trimmedSoundFileURL = documentsDirectory.appendingPathComponent(fileName) print("saving to \(trimmedSoundFileURL.absoluteString)") if FileManager.default.fileExists

AVAssetWriter AVVideoExpectedSourceFrameRateKey (frame rate) ignored

放肆的年华 提交于 2019-11-28 12:52:27
Me and my team are trying to re-encode a video file to a more "gify" feeling by changing the video frame rate. We are using the following properties for the AVAssetWriterInput : let videoSettings:[String:Any] = [ AVVideoCodecKey: AVVideoCodecH264, AVVideoHeightKey: videoTrack.naturalSize.height, AVVideoWidthKey: videoTrack.naturalSize.width, AVVideoCompressionPropertiesKey: [AVVideoExpectedSourceFrameRateKey: NSNumber(value: 12)] ] But the output video keep playing in the normal frame rate (played using AVPlayer ). What is the right way to reduce video frame rate? (12 for example). Any help in

Merge videos & images in AVMutableComposition using AVMutableCompositionTrack, not AVVideoCompositionCoreAnimationTool?

柔情痞子 提交于 2019-11-28 12:22:09
问题 The code below exports a video using AVMutableComposition . But in the exported video, if you want an image to display for 3 seconds after the source video finishes, is there a way to do that with AVMutableCompositionTrack or do you need to add an image layer and animate its appearance after the video ends? Eventually, the goal is to merge an arbitrary number of images and videos into one master video. Unfortunately, during testing it seems like AVVideoCompositionCoreAnimationTool severely

Pan Gesture with AVPlayer

[亡魂溺海] 提交于 2019-11-28 11:54:42
问题 This feature is really important to my app and would really like some help on it. Basically, I want to add a UIPanGestureRecognizer to a video player so that the user can fast forward/rewind the video with the gesture. Apple has some sample code which uses Swift 3 and has the entire video player already created. The only thing missing is the UIPanGestureRecognizer . This is the link: https://developer.apple.com/library/content/samplecode/AVFoundationSimplePlayer-iOS/Introduction/Intro.html#/

Duet - Merge 2 Videos Side by Side

三世轮回 提交于 2019-11-28 11:49:25
NOTE:- Merge Videos Side By Side WITHOUT Losing Video Quality I think that is a Very Very Important Question, After a lot of searches & Googling, didn't find any helpful material related to this Question. I'm working on a Project where I need to MERGE Videos Side-By-Side in a single file. I had done Merged Videos using AVFoundation But the problem is FIRST Video is showing as an Overlay to a SECOND video(not Merging properly as same as SMULE App/Karaoke App or Tiktok App ). func mergeVideosFilesWithUrl(savedVideoUrl: URL, newVideoUrl: URL, audioUrl:URL) { let savePathUrl : NSURL = NSURL