How to get the FPS of a video?

I am playing a video with AVPlayer, how can I get the float value of the FPS of the video?

I readed it's possible with AVAssetTrack but I don't know how to implement it.

On Swift/SwiftUI

Thanks!

I found this:

@State var fps: Float = 0.0

let asset = yourAVPlayer.currentItem!.asset

let tracks = asset.tracks(withMediaType: .video)

let fps = tracks.first!.nominalFrameRate

another way?

How to get the FPS of a video?
 
 
Q