How do you change the frame rate for video captured with AVCaptureMovieFileOutput?
Generated on 1/6/2025
1 search
To change the frame rate for video captured with AVCaptureMovieFileOutput
, you need to configure the AVCaptureDevice
and AVCaptureConnection
appropriately. Here's a general approach based on the information provided in the WWDC sessions:
-
Create an AVCaptureSession: Set up your capture session and add the necessary inputs and outputs.
-
Configure the AVCaptureDevice: Select the appropriate camera and configure its settings. You may need to iterate through the available formats to find one that supports your desired frame rate.
-
Set the Frame Rate: Once you have the correct format, you can set the frame rate by configuring the
activeVideoMinFrameDuration
andactiveVideoMaxFrameDuration
properties of theAVCaptureDevice
. -
Connect the Input and Output: Use an
AVCaptureConnection
to connect your input and output, ensuring that the session coordinates the data flow correctly. -
Start the Session: Commit the configuration and start running the session to begin capturing video.
For more detailed code examples and guidance, you might want to refer to the Build compelling spatial photo and video experiences session from WWDC 2024, which provides insights into setting up video capture with AV Foundation.
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.
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.