我正在尝试在iOS中导出具有不同比例范围的多个范围。像2秒是慢速运动,3秒是快速运动。但是在导出会话中,如果我要使用多个范围,则它始终无法获得高分辨率。如果我输出的分辨率比输出的分辨率低。这是我的代码。
for i in 0..<arrRanges.count{
let startTime = self.arrRanges[i]["startTime"]
let speed = self.arrRanges[i]["speed"]
var endTime = self.arrRanges[i]["endTime"]
if i == self.arrRanges.count - 1{
endTime = Double(CMTimeGetSeconds((compositionVideoTrack?.timeRange.duration)!))
}else{
let nextStartTime = self.arrRanges[i+1]["startTime"]
endTime = nextStartTime! - 0.1
}
let cduration = endTime! - startTime!
let customScaleTime = CMTimeMakeWithSeconds(cduration * speed!, asset.duration.timescale)
compositionVideoTrack?.scaleTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(startTime!, asset.duration.timescale), CMTimeMakeWithSeconds(cduration, asset.duration.timescale)), toDuration: customScaleTime)
if compositionAudioTrack != nil{
compositionAudioTrack?.scaleTimeRange(CMTimeRangeMake(CMTimeMakeWithSeconds(startTime!, asset.duration.timescale), CMTimeMakeWithSeconds(cduration, asset.duration.timescale)), toDuration: customScaleTime)
}
}
如果我要在全范围内进行唯一的慢动作拍摄,而不是在高分辨率下拍摄。我的代码在这里怎么了?
即使有可用的预设,它也可以为我提供所有分辨率
let compatiblePresets = AVAssetExportSession.exportPresets(compatibleWith: mixComposition)