Get the accurate duration of a video
This works for me: import AVFoundation import CoreMedia … if let url = Bundle.main.url(forResource: “small”, withExtension: “mp4″) { let asset = AVAsset(url: url) let duration = asset.duration let durationTime = CMTimeGetSeconds(duration) print(durationTime) } For the video here it prints “5.568” which is correct. Edit from comments: A video that returns 707 seconds when divided by … Read more