|
@@ -62,8 +62,26 @@ public class BFRecordExport {
|
|
|
for (_, itemModel) in itemModels.enumerated() {
|
|
|
itemModel.videoStickers.removeAll()
|
|
|
|
|
|
+ // 是否按录音顺序合成保留录音部分的 最终成果;
|
|
|
+ // 如果需要排序,则排视频的顺序;否则排音频的顺序
|
|
|
+ let needSort = false //
|
|
|
+ if needSort {
|
|
|
+ drangs.sort { range1, range2 in
|
|
|
+ range1.index < range2.index
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ // 音频排序
|
|
|
+ itemModel.voiceStickers.sort { m1, m2 in
|
|
|
+ m1.startTime < m2.startTime
|
|
|
+ }
|
|
|
+ // 字幕排序
|
|
|
+ itemModel.titleStickers.sort { model1, model2 in
|
|
|
+ model1.timelineIn < model2.timelineIn
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if itemModel.mediaType == .IMAGE {
|
|
|
- // 图片素才
|
|
|
+ // 图片素材
|
|
|
let duration = itemModel.materialDuraion
|
|
|
let sticker = splitBaseMaterial(timelineIn: totalDur, model_in: 0, duration: duration)
|
|
|
sticker.originalData = itemModel.coverImg?.pngData()
|
|
@@ -71,6 +89,15 @@ public class BFRecordExport {
|
|
|
sticker.type = StickerType.IMAGE.rawValue
|
|
|
itemModel.videoStickers.append(sticker)
|
|
|
BFLog(1, message: "image sticker - timIn:\(sticker.timelineIn), modIn:\(sticker.model_in), dur:\(duration)")
|
|
|
+
|
|
|
+ var subDur = 0.0
|
|
|
+ for titleS in itemModel.titleStickers {
|
|
|
+ let leng = titleS.timelineOut - titleS.timelineIn
|
|
|
+ titleS.timelineIn = totalDur + subDur
|
|
|
+ titleS.timelineOut = totalDur + subDur + leng
|
|
|
+ subDur += leng
|
|
|
+ }
|
|
|
+
|
|
|
totalDur += duration
|
|
|
continue
|
|
|
}
|
|
@@ -94,8 +121,13 @@ public class BFRecordExport {
|
|
|
sticker.volumeGain = Float64(srange.isRecord ? originSoundInRecordVolumn*100 : originSoundVolumn*100)
|
|
|
itemModel.videoStickers.append(sticker)
|
|
|
subDur += range.duration.seconds
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
+ for titleS in itemModel.titleStickers {
|
|
|
+ titleS.timelineIn = totalDur + titleS.timelineIn
|
|
|
+ titleS.timelineOut = totalDur + titleS.timelineOut
|
|
|
+ }
|
|
|
+
|
|
|
totalDur += subDur
|
|
|
} else {
|
|
|
var subDur = 0.0
|
|
@@ -103,13 +135,12 @@ public class BFRecordExport {
|
|
|
srange.isRecord == true
|
|
|
}
|
|
|
|
|
|
- // 是否按录音顺序排列
|
|
|
- let needSort = false
|
|
|
if needSort {
|
|
|
drangs.sort { range1, range2 in
|
|
|
range1.index < range2.index
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
for srange in drangs {
|
|
|
let range = srange.range
|
|
|
let sticker = splitBaseMaterial(timelineIn: totalDur + subDur, model_in: range.start.seconds, duration: range.duration.seconds)
|
|
@@ -118,9 +149,16 @@ public class BFRecordExport {
|
|
|
itemModel.videoStickers.append(sticker)
|
|
|
subDur += range.duration.seconds
|
|
|
}
|
|
|
+
|
|
|
+ var subtitleDur = 0.0
|
|
|
+ for titleS in itemModel.titleStickers {
|
|
|
+ let leng = titleS.timelineOut - titleS.timelineIn
|
|
|
+ titleS.timelineIn = totalDur + subtitleDur
|
|
|
+ titleS.timelineOut = totalDur + subtitleDur + leng
|
|
|
+ subtitleDur += leng
|
|
|
+ }
|
|
|
totalDur += subDur
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
beginExport(synthesisAll: synthesisAll)
|