|  | @@ -644,7 +644,7 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |          let originaDuration = CMTimeGetSeconds(clipAudioRange.duration)
 |  |          let originaDuration = CMTimeGetSeconds(clipAudioRange.duration)
 | 
											
												
													
														|  |          BFLog(message: "处理主音频 原始时长startTime = \(originaDuration) 要显示时长totalDuration = \(mTotalDuration)")
 |  |          BFLog(message: "处理主音频 原始时长startTime = \(originaDuration) 要显示时长totalDuration = \(mTotalDuration)")
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  | -        if(originaDuration <= CMTimeGetSeconds(clipAudioRange.duration)){
 |  | 
 | 
											
												
													
														|  | 
 |  | +        if(Float64(mTotalDuration) <= originaDuration){
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |              BFLog(message: "不用拼接音频文件 \(originAsset.url) 时长is \(CMTimeGetSeconds(originAsset.duration))")
 |  |              BFLog(message: "不用拼接音频文件 \(originAsset.url) 时长is \(CMTimeGetSeconds(originAsset.duration))")
 | 
											
												
													
														|  |              completeHander(originAsset.url)
 |  |              completeHander(originAsset.url)
 | 
											
										
											
												
													
														|  | @@ -663,7 +663,7 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |          //第一段的区间
 |  |          //第一段的区间
 | 
											
												
													
														|  |          var timeRange:CMTimeRange = CMTimeRange.zero
 |  |          var timeRange:CMTimeRange = CMTimeRange.zero
 | 
											
												
													
														|  |          if count > 0 {
 |  |          if count > 0 {
 | 
											
												
													
														|  | -            for index in 0 ... count {
 |  | 
 | 
											
												
													
														|  | 
 |  | +            for index in 0 ..< count {
 | 
											
												
													
														|  |                  
 |  |                  
 | 
											
												
													
														|  |                  duration = CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
 |  |                  duration = CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
 | 
											
												
													
														|  |                  BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
 |  |                  BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
 | 
											
										
											
												
													
														|  | @@ -671,8 +671,6 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |                  
 |  |                  
 | 
											
												
													
														|  |                  if(index != 0){
 |  |                  if(index != 0){
 | 
											
												
													
														|  |                      //(CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
 |  |                      //(CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
 | 
											
												
													
														|  | -                    duration = CMTime(value: CMTimeValue((CMTimeGetSeconds( clipAudioRange.duration) * Double(index) + (CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))) * Float64(playerTimescaleInt)), timescale: playerTimescaleInt)
 |  | 
 | 
											
												
													
														|  | -                    BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
 |  | 
 | 
											
												
													
														|  |                      timeRange = clipAudioRange
 |  |                      timeRange = clipAudioRange
 | 
											
												
													
														|  |                      
 |  |                      
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
										
											
												
													
														|  | @@ -687,23 +685,28 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |                  let assetTrack: AVAssetTrack = tracks[0]
 |  |                  let assetTrack: AVAssetTrack = tracks[0]
 | 
											
												
													
														|  |               
 |  |               
 | 
											
												
													
														|  |                  let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
 |  |                  let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +       
 | 
											
												
													
														|  |                  do {
 |  |                  do {
 | 
											
												
													
														|  |                      //
 |  |                      //
 | 
											
												
													
														|  |                      try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
 |  |                      try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  } catch {
 |  |                  } catch {
 | 
											
												
													
														|  | 
 |  | +                  
 | 
											
												
													
														|  |                      BFLog(message: "error is \(error)")
 |  |                      BFLog(message: "error is \(error)")
 | 
											
												
													
														|  | 
 |  | +                    completeHander(URL(string: ""))
 | 
											
												
													
														|  | 
 |  | +                    return
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |                  totalDuration = CMTimeAdd(totalDuration, timeRange.duration)
 |  |                  totalDuration = CMTimeAdd(totalDuration, timeRange.duration)
 | 
											
												
													
														|  |                  
 |  |                  
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            
 | 
											
												
													
														|  | 
 |  | +                
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          
 |  |          
 | 
											
												
													
														|  |          if(row > 0){
 |  |          if(row > 0){
 | 
											
												
													
														|  |              duration = CMTime(value: CMTimeValue(Float(CMTimeGetSeconds(totalDuration)) * Float(playerTimescaleInt)), timescale: playerTimescaleInt)
 |  |              duration = CMTime(value: CMTimeValue(Float(CMTimeGetSeconds(totalDuration)) * Float(playerTimescaleInt)), timescale: playerTimescaleInt)
 | 
											
												
													
														|  | -            timeRange = CMTimeRange(start: duration, end: CMTime(value: CMTimeValue((CMTimeGetSeconds(duration) + Double(row)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
 |  | 
 | 
											
												
													
														|  | 
 |  | +            timeRange = CMTimeRange(start: clipAudioRange.start, duration: CMTime(value: Int64(Double(row) * Double(playerTimescaleInt)), timescale: playerTimescaleInt))
 | 
											
												
													
														|  |              
 |  |              
 | 
											
												
													
														|  |                  BFLog(message: "合并的文件地址: \(originAsset.url)")
 |  |                  BFLog(message: "合并的文件地址: \(originAsset.url)")
 | 
											
												
													
														|  |                  let audioAsset = originAsset
 |  |                  let audioAsset = originAsset
 | 
											
										
											
												
													
														|  | @@ -712,19 +715,21 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |                      BFLog(message: "音频数据无效不进行合并,所有任务结束要确保输入的数据都正常! \(originAsset.url)")
 |  |                      BFLog(message: "音频数据无效不进行合并,所有任务结束要确保输入的数据都正常! \(originAsset.url)")
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |                  }
 |  |                  }
 | 
											
												
													
														|  | -                let assetTrack: AVAssetTrack = tracks[0]
 |  | 
 | 
											
												
													
														|  | -             
 |  | 
 | 
											
												
													
														|  | -                let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                do {
 |  | 
 | 
											
												
													
														|  | -                    //
 |  | 
 | 
											
												
													
														|  | -                    try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                } catch {
 |  | 
 | 
											
												
													
														|  | -                    BFLog(message: "error is \(error)")
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | 
 |  | +            let assetTrack: AVAssetTrack = tracks[0]
 | 
											
												
													
														|  | 
 |  | +         
 | 
											
												
													
														|  | 
 |  | +            let compositionAudioTrack: AVMutableCompositionTrack = composition.addMutableTrack(withMediaType: AVMediaType.audio, preferredTrackID: CMPersistentTrackID())!
 | 
											
												
													
														|  | 
 |  | +   
 | 
											
												
													
														|  | 
 |  | +            do {
 | 
											
												
													
														|  | 
 |  | +                //
 | 
											
												
													
														|  | 
 |  | +                try compositionAudioTrack.insertTimeRange(timeRange, of: assetTrack, at: totalDuration)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -                totalDuration = CMTimeAdd(totalDuration, audioAsset.duration)
 |  | 
 | 
											
												
													
														|  | 
 |  | +            } catch {
 | 
											
												
													
														|  | 
 |  | +              
 | 
											
												
													
														|  | 
 |  | +                BFLog(message: "error is \(error)")
 | 
											
												
													
														|  | 
 |  | +                completeHander(URL(string: ""))
 | 
											
												
													
														|  | 
 |  | +                return
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            totalDuration = CMTimeAdd(totalDuration, timeRange.duration)
 | 
											
												
													
														|  |                  
 |  |                  
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |   
 |  |   
 | 
											
										
											
												
													
														|  | @@ -750,7 +755,7 @@ extension PQStuckPointPublicController {
 | 
											
												
													
														|  |                  // 85.819125
 |  |                  // 85.819125
 | 
											
												
													
														|  |                  let audioAsset = AVURLAsset(url: fileUrl, options: avAssertOptions)
 |  |                  let audioAsset = AVURLAsset(url: fileUrl, options: avAssertOptions)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -                BFLog(message: "拼接声音文件 完成 \(fileUrl) 时长is \(CMTimeGetSeconds(audioAsset.duration))")
 |  | 
 | 
											
												
													
														|  | 
 |  | +                BFLog(1,message: "拼接声音文件 完成 \(fileUrl) 时长is \(CMTimeGetSeconds(audioAsset.duration))")
 | 
											
												
													
														|  |                  completeHander(fileUrl)
 |  |                  completeHander(fileUrl)
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |              } else {
 |  |              } else {
 |