|
@@ -1298,6 +1298,19 @@ extension PQStuckPointEditerController {
|
|
|
|
|
|
return stuckPoints
|
|
|
}
|
|
|
+
|
|
|
+ func clipPoint(clipCount:Int,oldPoints: Array<Float>) {
|
|
|
+ for i in finallyStuckPoints.count...clipCount {
|
|
|
+
|
|
|
+ if ((i % (oldPoints.count - 1)) != 0){
|
|
|
+ finallyStuckPoints.append(finallyStuckPoints[i-1] + oldPoints[i%(oldPoints.count - 1)] - oldPoints[(i-1)%(oldPoints.count - 1)])
|
|
|
+ }else {
|
|
|
+ finallyStuckPoints.append(finallyStuckPoints[i-1] + oldPoints[1] - oldPoints[0])
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
/// 根据不同模式model, maxSpeed ,minSpeed, self?.stuckPointMusicData?.speed 档位,生成音乐时长和最终使用的卡点信息
|
|
|
func dealParameter(model: createStickersModel) {
|
|
@@ -1335,20 +1348,8 @@ extension PQStuckPointEditerController {
|
|
|
}
|
|
|
|
|
|
// 拼接要使用的卡点信息
|
|
|
- for i in 0 ... clipNum {
|
|
|
-
|
|
|
- if(i < stuckPointsTemp.count){
|
|
|
- finallyStuckPoints.append(stuckPointsTemp[i])
|
|
|
- }else{
|
|
|
- let duration = (stuckPointsTemp.last ?? 0.0) - (stuckPointsTemp.first ?? 0.0)
|
|
|
- let index = i % stuckPointsTemp.count
|
|
|
- if((index + 1) < stuckPointsTemp.count){
|
|
|
- let a = duration * Float((i / stuckPointsTemp.count)) + stuckPointsTemp[index + 1]
|
|
|
- finallyStuckPoints.append(a)
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ finallyStuckPoints.append(stuckPointsTemp.first ?? 0.0)
|
|
|
+ clipPoint(clipCount:clipNum , oldPoints: stuckPointsTemp)
|
|
|
|
|
|
break
|
|
|
case .createStickersModelSpeed, .createStickersModelOnlyMusic: // 快慢速
|
|
@@ -1428,31 +1429,31 @@ extension PQStuckPointEditerController {
|
|
|
sticker.clipCount = LACount + LBCount
|
|
|
// LACount + LBCount = 0 ? 11s视频x6倍速
|
|
|
if sticker.clipCount == 0 { sticker.clipCount = 1 }
|
|
|
-
|
|
|
- //每一个素材的取点的开始位置
|
|
|
- var pointStartIndex:Int = 0
|
|
|
- if(lastPointIndex == nil){
|
|
|
- pointStartIndex = 0
|
|
|
- }else{
|
|
|
- pointStartIndex = (lastPointIndex ?? 0) + 1
|
|
|
- }
|
|
|
- for i in pointStartIndex ... (sticker.clipCount + pointStartIndex){
|
|
|
-
|
|
|
- if(i < stuckPointsTemp.count){
|
|
|
- BFLog(message: "直接添加值前:\(stuckPointsTemp[i])")
|
|
|
- finallyStuckPoints.append(stuckPointsTemp[i])
|
|
|
- BFLog(message: "直接添加值后:\(finallyStuckPoints.last ?? 0.0)")
|
|
|
- }else{
|
|
|
- let duration = (stuckPointsTemp.last ?? 0.0) - (stuckPointsTemp.first ?? 0.0)
|
|
|
- let index = i % stuckPointsTemp.count
|
|
|
- if((index + 1) < stuckPointsTemp.count){
|
|
|
- let a = duration * Float((i / stuckPointsTemp.count)) + stuckPointsTemp[index + 1]
|
|
|
- finallyStuckPoints.append(a)
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ if(stuckPointsTemp.count < 1){
|
|
|
+ //todo 和产品沟通提示
|
|
|
+ BFLog(message: "卡点数据有错误!!!")
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ finallyStuckPoints.append(stuckPointsTemp.first ?? 0.0)
|
|
|
+
|
|
|
+ clipPoint(clipCount: sticker.clipCount , oldPoints: stuckPointsTemp)
|
|
|
|
|
|
+// for i in finallyStuckPoints.count...sticker.clipCount {
|
|
|
+//
|
|
|
+// if ((i % (stuckPointsTemp.count - 1)) != 0){
|
|
|
+// finallyStuckPoints.append(finallyStuckPoints[i-1] + stuckPointsTemp[i%(stuckPointsTemp.count - 1)] - stuckPointsTemp[(i-1)%(stuckPointsTemp.count - 1)])
|
|
|
+// }else {
|
|
|
+// finallyStuckPoints.append(finallyStuckPoints[i-1] + stuckPointsTemp[1] - stuckPointsTemp[0])
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+ BFLog(message: "finallyStuckPoints\(finallyStuckPoints)")
|
|
|
+
|
|
|
+
|
|
|
+//
|
|
|
// 3,多补一个卡点 做 C级 速处理,要根据条件不满足 不用补位
|
|
|
if useAssestDurationTemp < assetDuration {
|
|
|
|
|
@@ -1464,7 +1465,7 @@ extension PQStuckPointEditerController {
|
|
|
// 最后一点素材时长
|
|
|
let lastAssetDuration = Float(CMTimeGetSeconds(asset.duration)) - useAssestDurationTemp
|
|
|
|
|
|
- lastPointIndex = (sticker.clipCount % stuckPointsTemp.count) ?? 0
|
|
|
+ lastPointIndex = (sticker.clipCount % stuckPointsTemp.count)
|
|
|
//两个卡点
|
|
|
let a:Float = stuckPointsTemp[lastPointIndex ?? 0]
|
|
|
var b:Float = 0.0
|
|
@@ -1478,30 +1479,8 @@ extension PQStuckPointEditerController {
|
|
|
// 当前卡点段为快速
|
|
|
if tempSpeed >= 1 {
|
|
|
if needSpeed >= 0.4 * tempSpeed {
|
|
|
- // 这里代码要整理
|
|
|
- // 查找使用的最后一个卡点在原数组中的位置
|
|
|
- var lastPointIndex = stuckPointsTemp.firstIndex(where: { (point) -> Bool in
|
|
|
- (point == (finallyStuckPoints.last ?? 0.0).truncatingRemainder(dividingBy: (stuckPointsTemp.last ?? 0)))
|
|
|
- })
|
|
|
- for i in ((lastPointIndex ?? 0) + 1) ... ((lastPointIndex ?? 0) + 1){
|
|
|
-
|
|
|
- if(i < stuckPointsTemp.count){
|
|
|
- BFLog(message: "直接添加值前:\(stuckPointsTemp[i])")
|
|
|
- finallyStuckPoints.append(stuckPointsTemp[i])
|
|
|
- sticker.clipCount = sticker.clipCount + 1
|
|
|
- BFLog(message: "直接添加值后:\(finallyStuckPoints.last ?? 0.0)")
|
|
|
- }else{
|
|
|
- let duration = (stuckPointsTemp.last ?? 0.0) - (stuckPointsTemp.first ?? 0.0)
|
|
|
- let index = i % stuckPointsTemp.count
|
|
|
- if((index + 1) < stuckPointsTemp.count){
|
|
|
- let a = duration * Float((i / stuckPointsTemp.count)) + stuckPointsTemp[index + 1]
|
|
|
- finallyStuckPoints.append(a)
|
|
|
- sticker.clipCount = sticker.clipCount + 1
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+// clipPoint(clipCount: 1 , oldPoints: stuckPointsTemp)
|
|
|
+
|
|
|
|
|
|
}else{
|
|
|
BFLog(message: "条件不满足不用补位")
|
|
@@ -1509,28 +1488,7 @@ extension PQStuckPointEditerController {
|
|
|
} else { // 当前卡点段为慢速
|
|
|
if needSpeed >= 0.4 * tempSpeed && needSpeed >= 0.2 {
|
|
|
// 查找使用的最后一个卡点在原数组中的位置
|
|
|
- var lastPointIndex = stuckPointsTemp.firstIndex(where: { (point) -> Bool in
|
|
|
- (point == (finallyStuckPoints.last ?? 0.0).truncatingRemainder(dividingBy: (stuckPointsTemp.last ?? 0)))
|
|
|
- })
|
|
|
- for i in ((lastPointIndex ?? 0) + 1) ... ((lastPointIndex ?? 0) + 1){
|
|
|
-
|
|
|
- if(i < stuckPointsTemp.count){
|
|
|
- BFLog(message: "直接添加值前:\(stuckPointsTemp[i])")
|
|
|
- finallyStuckPoints.append(stuckPointsTemp[i])
|
|
|
- sticker.clipCount = sticker.clipCount + 1
|
|
|
- BFLog(message: "直接添加值后:\(finallyStuckPoints.last ?? 0.0)")
|
|
|
- }else{
|
|
|
- let duration = (stuckPointsTemp.last ?? 0.0) - (stuckPointsTemp.first ?? 0.0)
|
|
|
- let index = i % stuckPointsTemp.count
|
|
|
- if((index + 1) < stuckPointsTemp.count){
|
|
|
- let a = duration * Float((i / stuckPointsTemp.count)) + stuckPointsTemp[index + 1]
|
|
|
- finallyStuckPoints.append(a)
|
|
|
- sticker.clipCount = sticker.clipCount + 1
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
+// clipPoint(clipCount: 1 , oldPoints: stuckPointsTemp)
|
|
|
}else{
|
|
|
BFLog(message: "条件不满足不用补位")
|
|
|
}
|