|  | @@ -39,18 +39,15 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      //MARK: -
 | 
	
		
			
				|  |  | -    public func prepareData(){
 | 
	
		
			
				|  |  | -        if let data = data, data.count > 0{
 | 
	
		
			
				|  |  | -            _ = generationTimeRanges(voiceStickers: data.first!.voiceStickers)
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /// synthesisAll: 合成所有还是只合成录音部分
 | 
	
		
			
				|  |  |      public func startExprot(synthesisAll:Bool){
 | 
	
		
			
				|  |  |          // 1,背景视频素材
 | 
	
		
			
				|  |  |          if let itemModels = data {
 | 
	
		
			
				|  |  | +            
 | 
	
		
			
				|  |  |              var totalDur = 0.0
 | 
	
		
			
				|  |  |              for (index, itemModel) in itemModels.enumerated() {
 | 
	
		
			
				|  |  | +                itemModel.videoStickers.removeAll()
 | 
	
		
			
				|  |  |                  let asset = itemModel.baseMaterial
 | 
	
		
			
				|  |  |                  if let dur = asset?.duration.seconds {
 | 
	
		
			
				|  |  |                      if synthesisAll {
 | 
	
	
		
			
				|  | @@ -96,23 +93,6 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | -    func generationTimeRanges(voiceStickers:[PQVoiceModel]) -> [CMTimeRange]{
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        var ranges = [CMTimeRange]()
 | 
	
		
			
				|  |  | -        var start : Double = 0
 | 
	
		
			
				|  |  | -        for model in voiceStickers {
 | 
	
		
			
				|  |  | -            if model.startTime > start{
 | 
	
		
			
				|  |  | -                let range = CMTimeRange(start: CMTime(seconds: start, preferredTimescale: 100), duration: CMTime(seconds: model.startTime - start, preferredTimescale: 100))
 | 
	
		
			
				|  |  | -                ranges.append(range)
 | 
	
		
			
				|  |  | -                
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            ranges.append(CMTimeRange(start: CMTime(seconds: model.startTime, preferredTimescale: 100), end: CMTime(seconds: model.endTime, preferredTimescale: 100)))
 | 
	
		
			
				|  |  | -            start = model.endTime
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        
 | 
	
		
			
				|  |  | -        return ranges
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  |      func splitBaseMaterial(timelineIn:Double, model_in:Double, duration:Double) -> PQEditVisionTrackMaterialsModel{
 | 
	
		
			
				|  |  |          let bgMovieInfo: PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  |          if let asset = data?.first?.baseMaterial {
 | 
	
	
		
			
				|  | @@ -126,6 +106,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |              bgMovieInfo.volumeGain = 1
 | 
	
		
			
				|  |  |              bgMovieInfo.aptDuration = bgMovieInfo.timelineOut
 | 
	
		
			
				|  |  |              bgMovieInfo.duration = bgMovieInfo.timelineOut
 | 
	
		
			
				|  |  | +            BFLog(1, message: "hhh- timIn:\(timelineIn), modIn:\(model_in), dur:\(duration)")
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          return bgMovieInfo
 | 
	
	
		
			
				|  | @@ -189,7 +170,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |              
 | 
	
		
			
				|  |  |              BFLog(message: "导出设置的码率为:\(orgeBitRate)")
 | 
	
		
			
				|  |  |              if exporter!.prepare(videoSize: size, videoAverageBitRate: orgeBitRate) {
 | 
	
		
			
				|  |  | -                exporter!.start(playeTimeRange: CMTimeRange(start: CMTime.zero, end: composition.duration))
 | 
	
		
			
				|  |  | +                exporter!.start(playeTimeRange: CMTimeRange(start: CMTime.zero, end: synthesisAll ? asset?.duration as! CMTime : composition.duration))
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              exporter?.progressClosure = { [weak self] _, _, progress in
 | 
	
		
			
				|  |  |                  //            BFLog(message: "正片合成进度 \(progress * 100)%")
 | 
	
	
		
			
				|  | @@ -205,7 +186,6 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |                      
 | 
	
		
			
				|  |  |                      BFLog(1, message: "无水印的视频导出完成: \(String(describing: url)) 生成视频时长为:\(outSeconds)")
 | 
	
		
			
				|  |  |                      cShowHUB(superView: nil, msg: ( outSeconds == 0) ? "合成失败请重试。" : "合成成功")
 | 
	
		
			
				|  |  | -                    self?.saveVideoToPhoto(url: url)
 | 
	
		
			
				|  |  |                      self?.exportCompletion?(nil, url)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                  }else{
 | 
	
	
		
			
				|  | @@ -226,18 +206,6 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  | -    func saveVideoToPhoto(url:URL){
 | 
	
		
			
				|  |  | -        PHPhotoLibrary.shared().performChanges {
 | 
	
		
			
				|  |  | -            PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: url)
 | 
	
		
			
				|  |  | -        } completionHandler: { isFinished, _ in
 | 
	
		
			
				|  |  | -            if isFinished {
 | 
	
		
			
				|  |  | -                DispatchQueue.main.async {
 | 
	
		
			
				|  |  | -                    cShowHUB(superView: nil, msg: "保存成功")
 | 
	
		
			
				|  |  | -                }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    
 | 
	
		
			
				|  |  |      func dealAsset(){
 | 
	
		
			
				|  |  |  //        asset?.tracks.first(where: { track in
 | 
	
		
			
				|  |  |  //            if track.mediaType == .audio{
 |