|
@@ -135,11 +135,11 @@ public class BFRecordItemModel: NSObject {
|
|
|
}
|
|
|
|
|
|
/// 视频分解成帧
|
|
|
- /// - parameter fps : 自定义帧数 每秒内取的帧数
|
|
|
+ /// - parameter frames : 需要取的帧数
|
|
|
/// - parameter firstImagesCount : 获取首先N张连续视频帧后先返回给调用方使用作为缓冲
|
|
|
/// - parameter splitCompleteClosure : 回调
|
|
|
- func splitVideoFileUrlFps(fps: Double, firstImagesCount:Int = 0, splitCompleteClosure: @escaping ((Bool, [UIImage]) -> Void)) {
|
|
|
- guard let localPath = localPath else {
|
|
|
+ func splitVideoFileUrlFps(frames: Int, firstImagesCount:Int = 0, splitCompleteClosure: @escaping ((Bool, [UIImage]) -> Void)) {
|
|
|
+ guard let urlAsset = videoAsset, urlAsset.duration.seconds > 0 else {
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -147,11 +147,11 @@ public class BFRecordItemModel: NSObject {
|
|
|
|
|
|
var times = [NSValue]()
|
|
|
|
|
|
- let urlAsset = AVURLAsset(url: URL(fileURLWithPath: localPath))
|
|
|
+// let urlAsset = AVURLAsset(url: URL(fileURLWithPath: localPath))
|
|
|
let start = 0
|
|
|
- let end = Int(urlAsset.duration.seconds * Float64(fps))
|
|
|
-
|
|
|
- for i in start...end {
|
|
|
+// let end = Int(urlAsset.duration.seconds * Float64(fps))
|
|
|
+ let fps = Double(frames) / urlAsset.duration.seconds
|
|
|
+ for i in start..<frames {
|
|
|
let timeValue = NSValue(time: CMTimeMake(value: Int64(i * 1000), timescale: Int32(fps * 1000)))
|
|
|
|
|
|
times.append(timeValue)
|