获取视频时长

//            NSDictionary *opts = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO]

//                                                             forKey:AVURLAssetPreferPreciseDurationAndTimingKey];

//            AVURLAsset *urlAsset = [AVURLAsset URLAssetWithURL:[NSURL URLWithString:self.itemVideoUrl] options:opts];  // 初始化视频媒体文件

//            float minute = 0, second = 0;

//            second = urlAsset.duration.value / urlAsset.duration.timescale; // 获取视频总时长,单位秒

//            NSLog(@"movie duration : %.0f", second);

//            if (second >= 60) {

//                int index = second / 60;

//                minute = index;

//                second = second - index*60;

//            }

 需导入AVFoundation框架及头文件

原文地址:https://www.cnblogs.com/limicheng/p/4089087.html