我有一个视频的网址。 我想知道它的持续时间而不是播放它。
我试过了:
let data = "http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"
let a = NSURL(string: data)
let asset = AVAsset(URL: a!)
let duration = asset.duration
let durationTime = CMTimeGetSeconds(duration)
print("the duration is",durationTime)
答案 0 :(得分:0)
如果视频是从picker
let asset = AVURLAsset(url: video)
let durationInSeconds = asset.duration.seconds
print(durationInSeconds)