开发者

iOS - AVPlayer - Get Current FPS / Frame Rate

开发者 https://www.devze.com 2023-03-23 05:12 出处:网络
I am experimenting streaming with HLS to an AVPlayer instance - like the Apple StitchedStreamPlayer sample project.

I am experimenting streaming with HLS to an AVPlayer instance - like the Apple StitchedStreamPlayer sample project.

I am getting the current player time nicely, but in order 开发者_StackOverflow社区to calculate a particular frame or generate a SMPTE timecode I need to know the FPS (Frames Per Second)

Can anyone help me figure out how to retrieve this from AVPlayer or AVPlayerItem or similar?

Many thanks!


[[video_player.currentItem.tracks[0] assetTrack] nominalFrameRate];


func getFPS(_ videoUrl : URL) -> Float {
    let asset:AVAsset = AVAsset(url: videoUrl)
    let tracks = asset.tracks(withMediaType: .video)
    let fps = tracks.first?.nominalFrameRate
    return fps ?? 0.0
}

`

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号