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:

  1. Create an AVCaptureSession: Set up your capture session and add the necessary inputs and outputs.

  2. 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.

  3. Set the Frame Rate: Once you have the correct format, you can set the frame rate by configuring the activeVideoMinFrameDuration and activeVideoMaxFrameDuration properties of the AVCaptureDevice.

  4. Connect the Input and Output: Use an AVCaptureConnection to connect your input and output, ensuring that the session coordinates the data flow correctly.

  5. 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.