我对 CMTimeRange 有疑问。
尝试设置 CMTimeRange 时出现警告。将输入 CMTimeRange 参数的 CMTimes 很好(如屏幕截图所示)。这段代码有问题吗?
guard let exportSession = AVAssetExportSession(asset: asset, presetName: videoQualityString) else { return }
exportSession.outputURL = resultingFileURL
exportSession.outputFileType = .mp4
// startTime, endTime => CMTime
if let startTime = trimmerView.startTime, let endTime = trimmerView.endTime {
print(startTime, endTime)
print("efehowihfoweihfowiehfoihweofiehw")
let timeRange = CMTimeRange(start: startTime, end: endTime)
print("efehowihfoweihfowiehfoihweofiehw")
exportSession.timeRange = timeRange
exportSession.exportAsynchronously {
switch exportSession.status {
case .completed:
completion(resultingFileURL)
print("complete")
case .failed:
print("failed \(exportSession.error.debugDescription)")
case .cancelled:
print("cancelled \(exportSession.error.debugDescription)")
default: break
}
}
}