iOS: get video duration and thumbnails without playing video

后端 未结 3 2091
北荒
北荒 2021-01-31 04:30

I need to get a (local) video\'s duration, and then get access to its individual frames as UIImages. So far I\'ve been using MPMoviePlayerController fo

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 05:12

    You can get in swift like this

    func getMediaDuration(url: NSURL!) -> Float64{
        let asset : AVURLAsset = AVURLAsset(URL: url) as AVURLAsset
        let duration : CMTime = asset.duration
        return CMTimeGetSeconds(duration)
    }
    

提交回复
热议问题