avfoundation

Using AVCaptureSession and AVAudioPlayer together

此生再无相见时 提交于 2019-12-17 23:15:06
问题 I am able to record video and output the movie to a file correctly. However, I have a problem with video recording (no video ouput) when trying to use AVAudioPlayer to play some audio. Does it mean that I cannot use AVCaptureSession and AVAudioPlayer at the same time? Here is my code to create the capture session and to play the audio. The video capture is started first, then during the capturing, I want to play some audio. Thanks so much for any help. Code to create the capture session to

Implementing long running tasks in background IOS

橙三吉。 提交于 2019-12-17 22:43:10
问题 I have been working on an app in which user can record video using AVFoundation and send to the server, video has maximum size up to 15M, depending on the internet speed & type it can take from 1 to 5 minutes approximately to transfer video to the server. I am transferring the recorded video to the server in the background thread so that user can continue other stuff on the app while video is being uploaded to the server. While reading the Apple Docs for implementing long running tasks in

How to play a music file using URL link in iPhone?

情到浓时终转凉″ 提交于 2019-12-17 21:57:14
问题 I want to play a music file using URL Link in the iPhone. But when I use the below code I am getting error I am not getting where I am going wrong. Can anyone Correct me? -(void)viewDidLoad { [super viewDidLoad]; NSString* resourcePath = @"http://192.167.1.104:8888/SHREYA.mp3"; //your url NSData *_objectData = [NSData dataWithContentsOfURL:[NSURL URLWithString:resourcePath]]; NSError *error; audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:_objectData error:&error]; audioPlayer

Capture picture from iOS camera

99封情书 提交于 2019-12-17 21:36:49
问题 I need to capture an image through the camera. But it gives the following error: 'NSInvalidArgumentException', reason: 'Cannot instantiate a AVCaptureDevice directly.' Follows the code: var session: AVCaptureSession! var device: AVCaptureDevice! var captureVideoPreviewLayer: AVCaptureVideoPreviewLayer! var image: UIImage! var input: AVCaptureDeviceInput! var stillImageOutput: AVCaptureStillImageOutput! var viewControllerScheduling: RentalSchedulingViewController! override func viewDidLoad() {

How to fix my orientation issue with merging videos from front and back camera

白昼怎懂夜的黑 提交于 2019-12-17 19:10:54
问题 I am merging multiply videos (implantation of pause button) and everything working fine exept when merging video from back camera with video from front camera then one of the videos comes turned upside down in the new video(merged video). My code: let mixComposition = AVMutableComposition() let videoTrack = mixComposition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID()) let trackAudio = mixComposition.addMutableTrackWithMediaType(AVMediaTypeAudio,

Grab frames from video using Swift

亡梦爱人 提交于 2019-12-17 18:58:56
问题 I want to grab frames from a video at a specific time. I'm calling my grab-frame-function with a time specified as seconds as a Float64. The problem is that it doesn't grab the current frame. It seems to ignore the decimals. If I call the function with for example 1.22 and 1.70 it will return the same frame. I'm quite new when it comes to Swift so I guess I don't get the CMTime object right. So can anyone see what's wrong with this? func generateThumnail(url : NSURL, fromTime:Float64) ->

Recording Video in iPhone using AVFoundation Framework(AVCaptureSession)?

一笑奈何 提交于 2019-12-17 18:48:30
问题 i am developing an application in which i am trying to record a video using AVCaptureSession class...i came across a few good tutorials like this one http://www.benjaminloulier.com/posts/2-ios4-and-direct-access-to-the-camera but in these tutorials only capturing images from the video frames is done while i want to record a full length video which i can either save in my device or upload it to my server....How can i achieve this using AVFoundation framework?? 回答1: Check out the sample code

Getting a thumbnail of a *.mov video IOS

。_饼干妹妹 提交于 2019-12-17 17:52:26
问题 I want to get a thumbnail of videos (*.mov) which taken with iPhone/iPAD. I am trying to use AVFoundation library for this and getting this error: couldn't generate thumbnail, error:Error Domain=AVFoundationErrorDomain Code=-11822 "Cannot Open" UserInfo=0x15d90a30 {NSLocalizedDescription=Cannot Open, NSLocalizedFailureReason=This media format is not supported.} Code: NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentDir=[paths

AVAssetImageGenerator provides images rotated

a 夏天 提交于 2019-12-17 17:47:09
问题 When obtaining a UIImage of a video via AVAssetImageGenerator, I'm getting back images rotated (well, technically they're not) when the video is shot in portrait orientation. How can I tell what orientation the video was shot and then rotate the image properly? AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:url options:nil]; AVAssetImageGenerator *generate = [[AVAssetImageGenerator alloc] initWithAsset:asset]; NSError *err = NULL; CMTime time = CMTimeMake(0, 60); CGImageRef imgRef =

Swift Merge audio and video files into one video

房东的猫 提交于 2019-12-17 17:38:23
问题 I wrote a program in Swift.I want to merge a video with an audio file, but got this error. "failed Error Domain=AVFoundationErrorDomain Code=-11838 "Operation Stopped" UserInfo=0x17da4230 {NSLocalizedDescription=Operation Stopped, NSLocalizedFailureReason=The operation is not supported for this media.}" code func mergeAudio(audioURL: NSURL, moviePathUrl: NSURL, savePathUrl: NSURL) { var composition = AVMutableComposition() let trackVideo:AVMutableCompositionTrack = composition