how do I take a photo while capturing video with AVCaptureSession?
Generated on 4/9/2025
1 search
To take a photo while capturing video with AVCaptureSession
, you can use the AVCapturePhotoOutput
in conjunction with your video capture setup. Here's a general approach based on the information from the WWDC sessions:
-
Set up your
AVCaptureSession
: Start by creating anAVCaptureSession
and configure it with the necessary inputs and outputs for video capture. This typically involves setting up anAVCaptureDevice
for the camera and anAVCaptureMovieFileOutput
for video recording. -
Add
AVCapturePhotoOutput
: In addition to your video output, add anAVCapturePhotoOutput
to your session. This allows you to capture still images while the video is being recorded. -
Capture a Photo: When you want to take a photo, use the
capturePhoto(with:delegate:)
method ofAVCapturePhotoOutput
. This can be done while the video is being recorded, allowing you to capture high-quality still images without interrupting the video capture.
For more detailed code examples and explanations, you might want to refer to the session Build compelling spatial photo and video experiences (05:21) which discusses setting up an AVCaptureSession
and handling inputs and outputs. Additionally, the session Build a great Lock Screen camera capture experience (04:49) provides insights into handling camera capture experiences, which might be useful if you're working with locked devices or specific capture extensions.

Build compelling spatial photo and video experiences
Learn how to adopt spatial photos and videos in your apps. Explore the different types of stereoscopic media and find out how to capture spatial videos in your iOS app on iPhone 15 Pro. Discover the various ways to detect and present spatial media, including the new QuickLook Preview Application API in visionOS. And take a deep dive into the metadata and stereo concepts that make a photo or video spatial.

Keep colors consistent across captures
Meet the Constant Color API and find out how it can help people use your app to determine precise colors. You’ll learn how to adopt the API, explore its scientific and marketing potential, and discover best practices for making the most of the technology.

Build a great Lock Screen camera capture experience
Find out how the LockedCameraCapture API can help you bring your capture application’s most useful information directly to the Lock Screen. Examine the API’s features and functionality, learn how to get started creating a capture extension, and find out how that extension behaves when the device is locked.

Introducing enterprise APIs for visionOS
Find out how you can use new enterprise APIs for visionOS to create spatial experiences that enhance employee and customer productivity on Apple Vision Pro.

Capture HDR content with ScreenCaptureKit
Learn how to capture high dynamic colors using ScreenCaptureKit, and explore new features like HDR support, microphone capture, and straight-to-file recording.