|  | @@ -74,7 +74,8 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |                  if needSort {
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |                      // 音频排序
 | 
	
		
			
				|  |  | -                    itemModel.voiceStickers.sort { m1, m2 in
 | 
	
		
			
				|  |  | +                    var useVoices = itemModel.getUsedVoices()
 | 
	
		
			
				|  |  | +                    useVoices.sort { m1, m2 in
 | 
	
		
			
				|  |  |                          m1.startCMTime.seconds < m2.startCMTime.seconds
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                      // 字幕排序
 | 
	
	
		
			
				|  | @@ -110,13 +111,13 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      
 | 
	
		
			
				|  |  |      func parseImage(synthesisAll: Bool, itemModel: BFRecordItemModel, totalDur:Double) -> Double{
 | 
	
		
			
				|  |  | -        if !synthesisAll, itemModel.voiceStickers.count == 0 {
 | 
	
		
			
				|  |  | +        if !synthesisAll, itemModel.getUsedVoices().count == 0 {
 | 
	
		
			
				|  |  |              // 图片无录音在保留模式里不合成
 | 
	
		
			
				|  |  |              return 0
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          var duration = itemModel.materialDuraion.seconds
 | 
	
		
			
				|  |  | -        if itemModel.voiceStickers.count == 0 {
 | 
	
		
			
				|  |  | +        if itemModel.getUsedVoices().count == 0 {
 | 
	
		
			
				|  |  |              // 图片无录音保持2s
 | 
	
		
			
				|  |  |              duration = 2
 | 
	
		
			
				|  |  |              let voice = PQEditVisionTrackMaterialsModel()
 | 
	
	
		
			
				|  | @@ -128,7 +129,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |              voiceList.append(voice)
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              //
 | 
	
		
			
				|  |  | -            for mod in itemModel.voiceStickers {
 | 
	
		
			
				|  |  | +            for mod in itemModel.getUsedVoices() {
 | 
	
		
			
				|  |  |                  let sticker = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  |                  sticker.model_in = 0
 | 
	
		
			
				|  |  |                  sticker.out = mod.endCMTime.seconds - mod.startCMTime.seconds
 | 
	
	
		
			
				|  | @@ -172,9 +173,6 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |                  exportCompletion?(error as Error, nil)
 | 
	
		
			
				|  |  |                  return subDur
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -//                    voiceList.append(contentsOf: itemModel.voiceStickers)
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |              if synthesisAll {
 | 
	
		
			
				|  |  |                  let drangs = itemModel.dealedDurationRanges
 | 
	
		
			
				|  |  |                  for srange in drangs {
 | 
	
	
		
			
				|  | @@ -186,10 +184,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |                      subDur += range.duration.seconds
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      if srange.isRecord {
 | 
	
		
			
				|  |  | -                        // 处理voice
 | 
	
		
			
				|  |  | -                        if let mod = itemModel.voiceStickers.first(where: { m in
 | 
	
		
			
				|  |  | -                            m.startCMTime.seconds == range.start.seconds
 | 
	
		
			
				|  |  | -                        }) {
 | 
	
		
			
				|  |  | +                        itemModel.getUsedVoices().forEach { mod in
 | 
	
		
			
				|  |  |                              let sticker = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  |                              sticker.model_in = 0
 | 
	
		
			
				|  |  |                              sticker.out = mod.endCMTime.seconds - mod.startCMTime.seconds
 | 
	
	
		
			
				|  | @@ -234,16 +229,39 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |                      videoStickers.append(sticker)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      let voiceSticker = itemModel.voiceStickers[index]
 | 
	
		
			
				|  |  | -                    let voice = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  | -                    voice.model_in = 0
 | 
	
		
			
				|  |  | -                    voice.out = voiceSticker.endCMTime.seconds - voiceSticker.startCMTime.seconds
 | 
	
		
			
				|  |  | -                    voice.timelineIn = totalDur + subDur
 | 
	
		
			
				|  |  | -                    voice.timelineOut = totalDur + subDur + voice.out
 | 
	
		
			
				|  |  | -                    voice.aptDuration = voice.out
 | 
	
		
			
				|  |  | -                    voice.duration = voice.out
 | 
	
		
			
				|  |  | -                    voice.locationPath = voiceSticker.wavFilePath
 | 
	
		
			
				|  |  | -                    voice.volumeGain = 100 // Float64(model.volume)
 | 
	
		
			
				|  |  | -                    voiceList.append(voice)
 | 
	
		
			
				|  |  | +                    // mdf by ak 
 | 
	
		
			
				|  |  | +                    if(itemModel.voiceChangeStickers.count > 0){//有变音
 | 
	
		
			
				|  |  | +                        
 | 
	
		
			
				|  |  | +                        let voiceChangeModels = itemModel.voiceChangeStickers.filter { mod in
 | 
	
		
			
				|  |  | +                            mod.recordId == voiceSticker.recordId
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        for voice in voiceChangeModels{
 | 
	
		
			
				|  |  | +                            BFLog(2, message: "当前变音所属:\(voiceSticker.recordId ?? "") text:\(voice.wavFilePath ?? "")")
 | 
	
		
			
				|  |  | +                            let voiceChangeSt = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  | +                            voiceChangeSt.model_in = 0
 | 
	
		
			
				|  |  | +                            voiceChangeSt.out = voice.endCMTime.seconds - voice.startCMTime.seconds
 | 
	
		
			
				|  |  | +                            voiceChangeSt.timelineIn = totalDur + subDur + (voice.startCMTime.seconds - voiceSticker.startCMTime.seconds)
 | 
	
		
			
				|  |  | +                            voiceChangeSt.timelineOut = voiceChangeSt.timelineIn + voiceChangeSt.out
 | 
	
		
			
				|  |  | +                            voiceChangeSt.aptDuration = voiceChangeSt.out
 | 
	
		
			
				|  |  | +                            voiceChangeSt.duration = voiceChangeSt.out
 | 
	
		
			
				|  |  | +                            voiceChangeSt.locationPath = voice.wavFilePath
 | 
	
		
			
				|  |  | +                            voiceChangeSt.volumeGain = 100 // Float64(model.volume)
 | 
	
		
			
				|  |  | +                            voiceList.append(voiceChangeSt)
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                        
 | 
	
		
			
				|  |  | +                    }else{//无变音
 | 
	
		
			
				|  |  | +                        let voice = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  | +                        voice.model_in = 0
 | 
	
		
			
				|  |  | +                        voice.out = voiceSticker.endCMTime.seconds - voiceSticker.startCMTime.seconds
 | 
	
		
			
				|  |  | +                        voice.timelineIn = totalDur + subDur
 | 
	
		
			
				|  |  | +                        voice.timelineOut = totalDur + subDur + voice.out
 | 
	
		
			
				|  |  | +                        voice.aptDuration = voice.out
 | 
	
		
			
				|  |  | +                        voice.duration = voice.out
 | 
	
		
			
				|  |  | +                        voice.locationPath = voiceSticker.wavFilePath
 | 
	
		
			
				|  |  | +                        voice.volumeGain = 100 // Float64(model.volume)
 | 
	
		
			
				|  |  | +                        voiceList.append(voice)
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |                      let titleModels = itemModel.titleStickers.filter { mod in
 | 
	
		
			
				|  |  |                          mod.recordId == voiceSticker.recordId
 | 
	
	
		
			
				|  | @@ -287,7 +305,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |          // 音频分解
 | 
	
		
			
				|  |  | -        for mod in itemModel.voiceStickers {
 | 
	
		
			
				|  |  | +        for mod in itemModel.getUsedVoices() {
 | 
	
		
			
				|  |  |              let sticker = PQEditVisionTrackMaterialsModel()
 | 
	
		
			
				|  |  |              sticker.model_in = 0
 | 
	
		
			
				|  |  |              sticker.type = StickerType.VOICE.rawValue
 | 
	
	
		
			
				|  | @@ -321,7 +339,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      public func clearFileCache() {
 | 
	
		
			
				|  |  |          data?.forEach { itemModel in
 | 
	
		
			
				|  |  | -            itemModel.voiceStickers.forEach { model in
 | 
	
		
			
				|  |  | +            itemModel.getUsedVoices().forEach { model in
 | 
	
		
			
				|  |  |                  if let localPath = model.wavFilePath {
 | 
	
		
			
				|  |  |                      try? FileManager.default.removeItem(atPath: localPath)
 | 
	
		
			
				|  |  |                  }
 | 
	
	
		
			
				|  | @@ -382,10 +400,10 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |          // 处理导出
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          guard let voiceCount = data?.reduce(0, { partialResult, itemModell in
 | 
	
		
			
				|  |  | -            itemModell.voiceStickers.count + partialResult
 | 
	
		
			
				|  |  | +            itemModell.getUsedVoices().count + partialResult
 | 
	
		
			
				|  |  |          }) else {
 | 
	
		
			
				|  |  | -            BFLog(1, message: "voiceStickers count += nil")
 | 
	
		
			
				|  |  | -            let error = NSError(domain: "err", code: ExportError.VoiceLost.rawValue, userInfo: ["msg": "voiceStickers count += nil"])
 | 
	
		
			
				|  |  | +            BFLog(1, message: "getUsedVoices() count += nil")
 | 
	
		
			
				|  |  | +            let error = NSError(domain: "err", code: ExportError.VoiceLost.rawValue, userInfo: ["msg": "getUsedVoices() count += nil"])
 | 
	
		
			
				|  |  |              exportCompletion?(error as Error, nil)
 | 
	
		
			
				|  |  |              return
 | 
	
		
			
				|  |  |          }
 | 
	
	
		
			
				|  | @@ -393,7 +411,7 @@ public class BFRecordExport {
 | 
	
		
			
				|  |  |          guard let totalDuration = data?.reduce(0.0, { partialResult, itemModell in
 | 
	
		
			
				|  |  |              var modelDuraion = 0.0
 | 
	
		
			
				|  |  |              if itemModell.mediaType == .Image {
 | 
	
		
			
				|  |  | -                if itemModell.voiceStickers.count == 0, synthesisAll {
 | 
	
		
			
				|  |  | +                if itemModell.getUsedVoices().count == 0, synthesisAll {
 | 
	
		
			
				|  |  |                      modelDuraion += 2
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |                      modelDuraion = itemModell.materialDuraion.seconds
 |