How should I configure AVCaptureMovieFileOutput to work with spatial video recording?
Generated on 3/11/2025
1 search
To configure AVCaptureMovieFileOutput
for spatial video recording, you need to follow these steps:
-
Create an AV Capture Session: Start by creating an
AVCaptureSession
and setting up a device input from a capture device like a camera. -
Select the Appropriate Camera: Use the built-in dual wide camera, as spatial video requires both the wide and ultra-wide cameras to stream simultaneously.
-
Choose a Supported Video Format: Iterate through the video formats available on the device and select one that supports spatial video. You can check if a format supports spatial video by verifying if
isSpatialVideoCaptureSupported
is true. -
Enable Spatial Video Recording: Once a suitable format is found, set it as the active format on the video device. Ensure to lock and unlock the video device appropriately and handle any errors if no spatial formats are found.
-
Set Spatial Video Capture Enabled: Check if spatial video capture is supported and, if so, set
isSpatialVideoCaptureEnabled
to true. Note that this feature is only available on iPhone 15 Pro, andisSpatialVideoCaptureSupported
will return false for other devices. -
Video Stabilization and Preview: For improved quality, set the preferred video stabilization mode to cinematic extended enhanced. You can also use the
AVCaptureVideoPreviewLayer
API to get a video preview feed, although it will always show the wide camera due to the monocular display of the iPhone.
For more detailed guidance, you can refer to the session Build compelling spatial photo and video experiences (05:21) from WWDC 2024.

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.

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.

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.

Explore multiview video playback in visionOS
Learn how AVExperienceController can enable playback of multiple videos on Apple Vision Pro. Review best practices for adoption and explore great use cases, like viewing a sports broadcast from different angles or watching multiple games simultaneously. And discover how to design a compelling and intuitive multiview experience in your app.