Skip to content

Camera Capture ​

AVFoundation camera patterns for custom camera UIs. Covers session setup, photo capture, video recording, rotation handling, responsive capture pipeline, and session lifecycle management.

When to Use ​

Use this skill when you're:

  • Building a custom camera UI (not the system picker)
  • Capturing photos with quality/speed tradeoffs
  • Recording video with audio
  • Handling device rotation correctly with RotationCoordinator (iOS 17+)
  • Making capture feel instant (zero-shutter-lag, deferred processing)
  • Making camera launch fast with deferred start (iOS 26 and later)
  • Recording high-data-rate video (ProRes) with Pro Video Storage (iOS 27)
  • Handling session interruptions (phone calls, multitasking, thermal pressure)
  • Switching between front and back cameras
  • Switching cameras on iPhone Duo's two front cameras (the virtual front camera, available today; a camera-direction API from iOS 27.1)

Note: If you just need users to pick existing photos, use photo-library instead. This skill is for building custom camera experiences with AVCaptureSession.

Example Prompts ​

Questions you can ask Claude that will draw from this skill:

  • "How do I set up a camera preview in SwiftUI?"
  • "My camera freezes when I get a phone call"
  • "The photo preview is rotated wrong on front camera"
  • "How do I make photo capture feel instant?"
  • "Should I use deferred processing?"
  • "How do I switch between front and back cameras?"
  • "How do I record video with audio?"
  • "My camera takes too long to capture"
  • "My camera app launches slowly — the preview takes forever to appear"
  • "My ProRes recording drops frames"
  • "How do I support the two front cameras on iPhone Duo?"

What This Skill Provides ​

Session Architecture ​

  • AVCaptureSession setup with dedicated serial queue
  • Input/output configuration with atomic beginConfiguration/commitConfiguration
  • Session presets for photo vs video use cases

Capture Patterns ​

  • Basic photo capture with AVCapturePhotoOutput
  • Video recording with AVCaptureMovieFileOutput and audio
  • Camera switching between front and back with fallback handling

Responsive Capture Pipeline (iOS 17+) ​

  • Zero-shutter-lag with ring buffer for instant capture
  • Responsive capture for overlapping photo captures
  • Fast capture prioritization for burst-like shooting
  • Readiness coordinator for shutter button state management
  • Deferred processing with proxy images and background processing

Launch Performance and Pro Recording ​

  • Deferred start for fast launch — preview up in roughly half the time (iOS 26 and later)
  • Automatic vs manual deferred start, including the video-data-output preview case
  • Pro Video Storage for deterministic ProRes file writes (iOS 27)

Rotation and Orientation ​

  • RotationCoordinator for automatic rotation tracking (replaces deprecated videoOrientation)
  • KVO observation for preview angle updates
  • Capture angle application for correctly oriented photos

Session Lifecycle ​

  • Interruption handling (phone calls, Split View, thermal pressure)
  • Proper start/stop on background queue
  • UI feedback patterns for interrupted states

Pressure Scenarios ​

  • Shipping camera features under deadline pressure
  • Responding to "camera is too slow" complaints
  • Explaining front camera mirroring behavior to designers

Key Pattern ​

SwiftUI Camera Preview ​

swift
struct CameraPreview: UIViewRepresentable {
    let session: AVCaptureSession

    func makeUIView(context: Context) -> PreviewView {
        let view = PreviewView()
        view.previewLayer.session = session
        view.previewLayer.videoGravity = .resizeAspectFill
        return view
    }

    func updateUIView(_ uiView: PreviewView, context: Context) {}

    class PreviewView: UIView {
        override class var layerClass: AnyClass { AVCaptureVideoPreviewLayer.self }
        var previewLayer: AVCaptureVideoPreviewLayer { layer as! AVCaptureVideoPreviewLayer }
    }
}

Documentation Scope ​

This page documents the axiom-media skill -- AVFoundation camera patterns Claude uses when helping you build custom camera features. The skill contains 9 core patterns with code examples, anti-patterns, a shipping checklist, and pressure scenarios.

For diagnostics: See camera-capture-diag for troubleshooting black previews, frozen cameras, and rotation issues.

For API reference: See camera-capture-ref for comprehensive AVCaptureSession, AVCapturePhotoOutput, and RotationCoordinator API coverage.

  • camera-capture-diag – Troubleshooting camera issues (black preview, rotation, slow capture)
  • camera-capture-ref – Complete AVFoundation camera API reference
  • photo-library – Photo picking and library access (use instead if you just need photo selection)
  • iPhone Duo – front-camera switching, direction vs. position, and showing camera UI on both displays

Resources ​

WWDC: 2021-10247, 2023-10105, 2026-303

Tech Talks: 111465

Docs: /avfoundation/avcapturesession, /avfoundation/avcapturedevice/rotationcoordinator, /avfoundation/avprovideostorage

Released under the MIT License