Kodeco Forums

Video Tutorial: Beginning Video with AVFoundation Part 3: Capturing Media: Video

Building on the previous video in this series, you’ll learn how to capture movie files.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4033-beginning-video-with-avfoundation/lessons/4

Hello,

I had a quick question, is there a way to make the preview layer show fully on an iPhone 6s+, I would of assumed due to the constraints it would, and I’ve redone the constraints but for some reason on my phone, a portion of the right edge of the screen and the bottom edge of the screen are fully black. Any ideas what the issue is?

Good tutorial.
One quick thing: The captured video has no audio!

To correct that, need to add a separate audioInput to the captureSession.

See this change in setupSession()

let audioDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeAudio)
... 
// inside the do{  } block, add this:
        let audioInput = try AVCaptureDeviceInput(device: audioDevice)
        if  captureSession.canAddInput(audioInput) {
            captureSession.addInput(audioInput)
        }

Hope this helps!

musa –

I had the same problem on my iPhone 6S+. There was a small edge at the bottom that was blacked out.

Cant recall exactly how I solved it, but try this:
IN the Storyboard, click on the ViewControllerScene, then in the extreme right tab, in Attributes Inspector, under Simulated Metrics, change the Size to iPhone 5.5 inch.

It might solve your problem.

HTH

Hi Michael @skyrocketsw

Good tutorial here. Thx for this.
One quick note:

A. Apple’s Best Practices indicate that UI work should be done on the main UI queue. Accordingly, the following should be performed in the dispatch_async(dispatch_get_main_queue()) {… } block:

  • Update video thumbnail (in the setVideoThumbnailFromURL() method)

  • Updating the TimeLabel as movie recording progresses

B. Changes to captureSession should be performed on a separate queue. So inside the setupSession() method, wrap the statements on a dispatch_async(videoQueue()) {…} block

Thanks a lot! This lesson solved a problem I had been facing for more than two weeks.

@ealshammari Really glad it helped! Cheers! :]