CMTimeMultiplyByRatio in iOS 16

let videoURL = URL(fileURLWithPath: path ?? "")

let asset = AVURLAsset(url: videoURL, options: nil)
let imageGenerator = AVAssetImageGenerator(asset: asset)
imageGenerator.appliesPreferredTrackTransform = true

 let time = CMTimeMultiplyByRatio(asset.duration, multiplier: 1, divisor: 2) // THIS LINE GIVES ISSUE: "'duration' was deprecated in iOS 16.0: Use load(.duration) instead".  I CANNOT FIGURE OUT THE CORRECT SYNTAX FOR CHANGING asset.duration TO REPLACE WITH load(.duration).  HELP WITH THE CORRECT SYNTAX WOULD BE HELPFUL.

You can fix this warning by calling:

Task {
   let duration = try await asset.load(.duration)
   let time = CMTimeMultiplyByRatio(duration, multiplier: 1, divisor: 2)
}

But I agree with you that it is a bit weird as it turns a synchronous call into an async one, which can become a pain in some contexts. I don't know why they deprecated asset.duration

CMTimeMultiplyByRatio in iOS 16
 
 
Q