Issue: FPS Drops to 30 After Trimming Video in Photos App

Hi,

I am recording a video at 240 FPS within my application and saving it to the Photos app. The recorded video retains 240 FPS in the Photos app. However, after trimming the video using the Photos app and importing it back into my app, the FPS is reduced to 30 FPS.

Steps to Reproduce:

  1. Record a video inside the application at 240 FPS.
  2. Save the recorded video to the Photos app.
  3. Verify that the video retains 240 FPS in the Photos app.
  4. Trim the video using the built-in Photos app editor.
  5. Import the trimmed video back into the application.
  6. The FPS of the imported video is now reduced to 30 FPS.

Code Used for Importing Video:

I am using the following code to fetch the video from the Photos app:

let options: PHVideoRequestOptions = PHVideoRequestOptions()
options.version = .current  // Using `.original` preserves FPS, but I need `.current` for other changes
options.deliveryMode = .highQualityFormat
options.isNetworkAccessAllowed = true

PHImageManager.default().requestAVAsset(forVideo: self, options: options) { (avAsset, audioMix, info) in
    if let urlAsset = avAsset as? AVURLAsset {
        completionHandler(urlAsset.url, self)
    } else {
        self.askForOriginal(completionHandler: completionHandler)
    }
}

Observations:

  • The original video retains 240 FPS until it is trimmed in the Photos app.
  • After trimming, the FPS automatically drops to 30 FPS when imported back into the app.
  • If I use options.version = .original, the FPS is preserved, but I need .current to apply other modifications.

Questions:

  1. Is this an expected behavior of PHImageManager when requesting a video with options.version = .current?
  2. Is there a way to preserve the original FPS while still using .current?
  3. Are there any workarounds to extract the trimmed video without FPS reduction?

Any insights or solutions would be greatly appreciated. Thanks in advance!

Are you also seeing a slo-motion treatment on the trimmed video? That is one cause of frame rate being lowered but It's not clear if that's happening here.

It would also be good to know if you are setting this metadata key on high framerate videos that your application is creating: AVMetadataQuickTimeMetadataKeyFullFrameRatePlaybackIntent https://developer.apple.com/documentation/avfoundation/avmetadatakey/quicktimemetadatakeyfullframerateplaybackintent?language=objc

Do you see different behavior if that key is set to 1?

Issue: FPS Drops to 30 After Trimming Video in Photos App
 
 
Q