|
@@ -15,7 +15,10 @@ import Photos
|
|
|
public class BFRecordExport {
|
|
|
public var progress: ((Float) -> Void)?
|
|
|
public var exportCompletion: ((Error?, URL?) -> Void)?
|
|
|
-
|
|
|
+
|
|
|
+ public var originSoundVolumn : Float = 1.0 // 无录音时原声大小
|
|
|
+ public var originSoundInRecordVolumn : Float = 0.0 // 录音时原声大小
|
|
|
+
|
|
|
public var data: [BFRecordItemModel]? {
|
|
|
didSet {
|
|
|
if data?.count ?? 0 > 0 {
|
|
@@ -59,11 +62,14 @@ public class BFRecordExport {
|
|
|
var subDur = 0.0
|
|
|
let drangs = itemModel.dealedDurationRanges
|
|
|
for srange in drangs {
|
|
|
- let range = srange.range
|
|
|
- let sticker = splitBaseMaterial(timelineIn: totalDur + subDur, model_in: range.start.seconds, duration: range.duration.seconds)
|
|
|
- sticker.volumeGain = srange.isRecord ? 0 : 100
|
|
|
- itemModel.videoStickers.append(sticker)
|
|
|
- subDur += range.duration.seconds
|
|
|
+ if let localPath = itemModel.localPath {
|
|
|
+ let range = srange.range
|
|
|
+ let sticker = splitBaseMaterial(timelineIn: totalDur + subDur, model_in: range.start.seconds, duration: range.duration.seconds)
|
|
|
+ sticker.locationPath = localPath
|
|
|
+ sticker.volumeGain = Float64(srange.isRecord ? originSoundInRecordVolumn*100 : originSoundVolumn*100)
|
|
|
+ itemModel.videoStickers.append(sticker)
|
|
|
+ subDur += range.duration.seconds
|
|
|
+ }
|
|
|
}
|
|
|
totalDur += subDur
|
|
|
} else {
|
|
@@ -84,7 +90,7 @@ public class BFRecordExport {
|
|
|
let range = srange.range
|
|
|
let sticker = splitBaseMaterial(timelineIn: totalDur + subDur, model_in: range.start.seconds, duration: range.duration.seconds)
|
|
|
sticker.locationPath = localPath
|
|
|
- sticker.volumeGain = 0
|
|
|
+ sticker.volumeGain = Float64(srange.isRecord ? originSoundInRecordVolumn*100 : originSoundVolumn*100)
|
|
|
itemModel.videoStickers.append(sticker)
|
|
|
subDur += range.duration.seconds
|
|
|
}
|
|
@@ -123,6 +129,7 @@ public class BFRecordExport {
|
|
|
return URL(fileURLWithPath: outPutMP4Path)
|
|
|
}
|
|
|
|
|
|
+ // 切割素材
|
|
|
func splitBaseMaterial(timelineIn: Double, model_in: Double, duration: Double) -> PQEditVisionTrackMaterialsModel {
|
|
|
let bgMovieInfo: PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel()
|
|
|
bgMovieInfo.type = StickerType.VIDEO.rawValue
|