|
@@ -479,23 +479,24 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
|
|
|
|
// 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
// 这里加300ms 是因为返回结果为了切到字,时长提前一些时间,具体时间官方没说和原音频有关系。这里我们先延后300ms 单位:毫秒。
|
|
if URL(fileURLWithPath: audioFilePath ?? "b").deletingPathExtension().lastPathComponent.contains(URL(fileURLWithPath: self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").deletingPathExtension().lastPathComponent) {
|
|
if URL(fileURLWithPath: audioFilePath ?? "b").deletingPathExtension().lastPathComponent.contains(URL(fileURLWithPath: self?.recorderManager?.voiceModel?.wavFilePath ?? "aa").deletingPathExtension().lastPathComponent) {
|
|
- newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
|
|
- newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startCMTime.seconds ?? 0.0) + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
|
|
|
|
+ newSubtitle.timelineIn = (self?.recorderManager?.voiceModel?.startCMTime ?? .zero) + CMTime(seconds: Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0, preferredTimescale: 1000)
|
|
|
|
+ newSubtitle.timelineOut = (self?.recorderManager?.voiceModel?.startCMTime ?? .zero) + CMTime(seconds: Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0, preferredTimescale: 1000)
|
|
|
|
|
|
- if newSubtitle.timelineIn - 0.1 > (self?.recorderManager?.voiceModel?.endCMTime.seconds ?? 0) {
|
|
|
|
|
|
+ if (newSubtitle.timelineIn - (self?.recorderManager?.voiceModel?.endCMTime ?? .zero)).seconds > 0.1 {
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
- newSubtitle.timelineIn -= 0.1
|
|
|
|
|
|
+ newSubtitle.timelineIn = newSubtitle.timelineIn - CMTime(seconds: 0.1, preferredTimescale: 1000)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if let voice = self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.first(where: { m in
|
|
if let voice = self?.itemModels[self?.currItemModelIndex ?? 0].voiceStickers.first(where: { m in
|
|
m.wavFilePath == audioFilePath
|
|
m.wavFilePath == audioFilePath
|
|
}) {
|
|
}) {
|
|
- newSubtitle.timelineIn = voice.startCMTime.seconds + Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0
|
|
|
|
- newSubtitle.timelineOut = voice.startCMTime.seconds + Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0
|
|
|
|
|
|
+ newSubtitle.timelineIn = voice.startCMTime + CMTime(seconds: Float64((((payload?["begin_time"]) as? Int) ?? 0) + 300) / 1000.0, preferredTimescale: 1000)
|
|
|
|
+ newSubtitle.timelineOut = voice.startCMTime + CMTime(seconds: Float64(((payload?["time"]) as? Int) ?? 0) / 1000.0, preferredTimescale: 1000)
|
|
|
|
|
|
- if newSubtitle.timelineIn - 0.1 > voice.endCMTime.seconds {
|
|
|
|
|
|
+
|
|
|
|
+ if (newSubtitle.timelineIn - voice.endCMTime).seconds > 0.1 {
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
BFLog(1, message: "卡在录音尾巴上了1")
|
|
- newSubtitle.timelineIn -= 0.1
|
|
|
|
|
|
+ newSubtitle.timelineIn = newSubtitle.timelineIn - CMTime(seconds: 0.1, preferredTimescale: 1000)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -507,7 +508,8 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
newSubtitle.text = showText
|
|
newSubtitle.text = showText
|
|
newSubtitle.audioFilePath = audioFilePath ?? ""
|
|
newSubtitle.audioFilePath = audioFilePath ?? ""
|
|
|
|
|
|
- BFLog(message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn) timelineOut \(newSubtitle.timelineOut) text: \(newSubtitle.text) 音频路径为:\(audioFilePath ?? "")")
|
|
|
|
|
|
+ BFLog(message: "添加字幕数据 timelineIn \(newSubtitle.timelineIn) timelineOut \(newSubtitle.timelineOut) text: \(newSubtitle.text) 音频路径为:\(audioFilePath ?? "") 传入的地址:\(self?.recorderManager?.voiceModel?.wavFilePath ?? "aa")")
|
|
|
|
+
|
|
newSubtitle.setting = self?.subtitleSettingView.subtitle.setting ?? BFSubTitileSettingModel()
|
|
newSubtitle.setting = self?.subtitleSettingView.subtitle.setting ?? BFSubTitileSettingModel()
|
|
|
|
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|
|
self?.itemModels[self?.currItemModelIndex ?? 0].titleStickers.append(newSubtitle)
|
|
@@ -579,7 +581,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
if sself.itemModels[sself.currItemModelIndex].mediaType == .IMAGE {
|
|
if sself.itemModels[sself.currItemModelIndex].mediaType == .IMAGE {
|
|
var duration: Double = 0
|
|
var duration: Double = 0
|
|
sself.itemModels[sself.currItemModelIndex].voiceStickers.forEach { temp in
|
|
sself.itemModels[sself.currItemModelIndex].voiceStickers.forEach { temp in
|
|
- BFLog(message: "录制结束-最终:\(temp.wavFilePath ?? "")-\(temp.startCMTime.seconds)-\(temp.endCMTime.seconds)-\(temp.endCMTime.seconds - temp.startCMTime.seconds)")
|
|
|
|
|
|
+ BFLog(1, message: "录制结束-最终:\(temp.wavFilePath ?? "")-\(temp.startCMTime.seconds)-\(temp.endCMTime.seconds)-\(temp.endCMTime.seconds - temp.startCMTime.seconds)")
|
|
temp.duration = "\(temp.endCMTime.seconds - temp.startCMTime.seconds)"
|
|
temp.duration = "\(temp.endCMTime.seconds - temp.startCMTime.seconds)"
|
|
duration = duration + (temp.endCMTime.seconds - temp.startCMTime.seconds)
|
|
duration = duration + (temp.endCMTime.seconds - temp.startCMTime.seconds)
|
|
}
|
|
}
|
|
@@ -709,9 +711,9 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
}
|
|
}
|
|
var findShowSubtitle: PQEditSubTitleModel?
|
|
var findShowSubtitle: PQEditSubTitleModel?
|
|
for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
|
|
for (index, subtitle) in itemModels[currItemModelIndex].titleStickers.enumerated() {
|
|
- if subtitle.timelineIn <= CMTimeGetSeconds(time), subtitle.timelineOut >= CMTimeGetSeconds(time) {
|
|
|
|
|
|
+ if CMTimeCompare(subtitle.timelineIn, time) <= 0 , CMTimeCompare(subtitle.timelineOut, time) >= 0 {
|
|
findShowSubtitle = subtitle
|
|
findShowSubtitle = subtitle
|
|
- BFLog(1, message: "找到要显示的字幕 in \(findShowSubtitle?.timelineIn ?? 0.0) out \(findShowSubtitle?.timelineOut ?? 0.0) text:\(findShowSubtitle?.text ?? "") currTime is \(CMTimeGetSeconds(time))")
|
|
|
|
|
|
+ BFLog(1, message: "找到要显示的字幕 in \((findShowSubtitle?.timelineIn ?? .zero).seconds) out \((findShowSubtitle?.timelineOut ?? .zero).seconds) text:\(findShowSubtitle?.text ?? "") currTime is \(CMTimeGetSeconds(time))")
|
|
showSubtitleIndex = index
|
|
showSubtitleIndex = index
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -1697,7 +1699,7 @@ public class BFRecordScreenController: BFBaseViewController {
|
|
if itemModels[currItemModelIndex].mediaType == .VIDEO {
|
|
if itemModels[currItemModelIndex].mediaType == .VIDEO {
|
|
if CMTimeGetSeconds(item?.duration ?? CMTime.zero) > 0 {
|
|
if CMTimeGetSeconds(item?.duration ?? CMTime.zero) > 0 {
|
|
currentAssetProgress = CMTime(seconds: time.seconds, preferredTimescale: 1000)
|
|
currentAssetProgress = CMTime(seconds: time.seconds, preferredTimescale: 1000)
|
|
- BFLog(1, message: "video curr:\(CMTimeGetSeconds(currentAssetProgress))")
|
|
|
|
|
|
+// BFLog(1, message: "video curr:\(CMTimeGetSeconds(currentAssetProgress))")
|
|
DispatchQueue.main.async { [weak self] in
|
|
DispatchQueue.main.async { [weak self] in
|
|
BFLog(message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
|
|
BFLog(message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
|
|
self?.progreddL.text = String(format: "%@", CMTimeGetSeconds(time).formatDurationToHMS())
|
|
self?.progreddL.text = String(format: "%@", CMTimeGetSeconds(time).formatDurationToHMS())
|
|
@@ -2052,7 +2054,7 @@ public extension BFRecordScreenController {
|
|
if !(self?.isRecording ?? false), (self?.currentAssetProgress.seconds ?? 0) > (self?.itemModels[self?.currItemModelIndex ?? 0].materialDuraion ?? 0) {
|
|
if !(self?.isRecording ?? false), (self?.currentAssetProgress.seconds ?? 0) > (self?.itemModels[self?.currItemModelIndex ?? 0].materialDuraion ?? 0) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- BFLog(1, message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
|
|
|
|
|
|
+// BFLog(1, message: "更新录音进度\(#function)-\(self?.currentAssetProgress.seconds ?? 0)")
|
|
self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
self?.progreddL.text = String(format: "%@", (self?.currentAssetProgress.seconds ?? 0).formatDurationToHMS())
|
|
self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
self?.progressThumV.progress = (self?.currentAssetProgress.seconds ?? 0)
|
|
self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|
|
self?.updateSubtitle(time: self?.currentAssetProgress ?? CMTime.zero)
|