Questions tagged [avfoundation]

The AVFoundation framework provides both Objective-C and Swift interfaces for editing and playing audio-visual media in a Mac OSX or iOS application. Questions using this framework should include this tag.

6407 questions
41
votes
3 answers

AVURLAsset refuses to load video

I'm trying to load a video file into my iPad app as an AVURLAsset, using the asynchronous-loading stuff to wait for it to be ready. Problem is, when I run it, I get a completely generic "failure" error message that I have no idea what to do with.…
Noah Witherspoon
  • 57,021
  • 16
  • 130
  • 131
41
votes
3 answers

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

The following used to work in Swift 1.2: var recordSettings = [ AVFormatIDKey: kAudioFormatMPEG4AAC, AVEncoderAudioQualityKey : AVAudioQuality.Max.rawValue, AVEncoderBitRateKey : 320000, AVNumberOfChannelsKey: 2, AVSampleRateKey…
lernerbot
  • 903
  • 2
  • 8
  • 21
40
votes
6 answers

Face Detection with Camera

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…
Willjay
  • 6,381
  • 4
  • 33
  • 58
40
votes
5 answers

How to solve the warning: Sending 'ViewController *const __strong' to parameter of incompatible type 'id?

The following code gave a warning of Sending 'ViewController *const __strong' to parameter of incompatible type 'id' (it is the third line in the following code): NSURL *sound0URL = [NSURL fileURLWithPath:[[NSBundle…
Jeremy L
  • 3,770
  • 6
  • 41
  • 62
39
votes
2 answers

AVFoundation + AssetWriter: Generate Movie With Images and Audio

I have to export a movie from my iPhone application which contains UIImage from an NSArray and add some audio files in .caf format that have to start at pre-specified times. Now I have been able to use the AVAssetWriter (after going through many…
MuTaTeD
  • 861
  • 2
  • 8
  • 13
37
votes
2 answers

Can use AVCaptureVideoDataOutput and AVCaptureMovieFileOutput at the same time?

I want to record video and grab frames at the same time with my code. I am using AVCaptureVideoDataOutput for grab frames and AVCaptureMovieFileOutput for video recording. But can't work and get the error code -12780 while working at the same time…
Yu-hua Chang
  • 371
  • 1
  • 4
  • 3
37
votes
3 answers

Capturing Video with AVFoundation

I've been looking around on Stack and I have found similar questions to this, but none have worked for me. I am a complete novice to Swift 3.0. Essentially what I'm trying to do is record a video using AVFoundation. So far I have managed to capture…
Adam Allard
  • 403
  • 1
  • 5
  • 11
36
votes
5 answers

AVPlayerItem fails with AVStatusFailed and error code "Cannot Decode"

I'm running into a strange issue, I hope someone can help. In my iOS app I create a video with a custom soundtrack using MutableComposition by combining a video from the user's photo library and an audio file from the app bundle. I then use an…
user1112293
  • 381
  • 1
  • 3
  • 4
36
votes
12 answers

iPhone AVFoundation camera orientation

I've been tearing my hair out trying to get the AVFoundation camera to capture a picture in the correct orientation (i.e. the device orientation) but I can't get it to work. I have looked at tutorials, I've watched the WWDC presentation and I've…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
36
votes
1 answer

AVPlayer frame animation

I am developing an application that include functionality to play video with per-frame animation. You can see an example of such functionality. I already tried to add CAKeyFrameAnimation to sublayer of AVSynchronizedLayer and have some troubles…
rkyr
  • 3,131
  • 2
  • 23
  • 38
35
votes
4 answers

Is it possible to cache HLS segments with AVPlayer?

Root Problem​ Our video buffers a lot when seeking in iOS. It buffers quite a bit more than our web player which saves copies of the already watched segments in temp storage. ​Desired Solution​ Caching the video segments locally on the device's…
35
votes
5 answers

AVCaptureSession with multiple previews

I have an AVCaptureSession running with an AVCaptureVideoPreviewLayer. I can see the video so I know it's working. However, I'd like to have a collection view and in each cell add a preview layer so that each cell shows a preview of the video. If I…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
34
votes
7 answers

How to properly release an AVCaptureSession

I'm using the AVFoundation classes to capture the live video stream from the camera and to process the video samples. This works nicely. However, I do have problems properly releasing the AVFoundation instances (capture session, preview layer, input…
Codo
  • 75,595
  • 17
  • 168
  • 206
33
votes
5 answers

How to stop a video in AVPlayer?

I am using this code to play video file using avplayer how do I stop it [videoView setHidden:NO]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths…
iTag
  • 413
  • 1
  • 4
  • 10
33
votes
6 answers

Add custom header field in request of AVPlayer

Is it possible to send headers with an http request to an audio file when using AVPlayer? I need to be able to inspect the content of the header when received by the server in order to restrict access to the file being requested.
user732538
  • 333
  • 1
  • 3
  • 5