Przeglądaj źródła

1,音频拼接的起点从0开始

jsonwang 3 lat temu
rodzic
commit
075de8e032

+ 3 - 5
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -664,10 +664,10 @@ extension PQStuckPointPublicController {
         var timeRange:CMTimeRange = CMTimeRange.zero
         if count > 0 {
             for index in 0 ..< count {
-                
-                duration = CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
+                //第0段从0开始到推荐的结束,播放器的开始时间不是从0开始的
+                duration = CMTime(value: CMTimeValue((CMTimeGetSeconds(clipAudioRange.end)) * Double(playerTimescaleInt)), timescale: playerTimescaleInt)
                 BFLog(message: "每一个文件的 duration \(CMTimeGetSeconds(duration))")
-                var timeRange = CMTimeRangeMake(start: mStartTime, duration: duration)
+                var timeRange = CMTimeRangeMake(start: .zero, duration: duration)
                 
                 if(index != 0){
                     //(CMTimeGetSeconds(clipAudioRange.end) - CMTimeGetSeconds(mStartTime))为用户选择的第一段时长
@@ -752,9 +752,7 @@ extension PQStuckPointPublicController {
         assetExport?.outputURL = fileUrl
         assetExport?.exportAsynchronously {
             if assetExport!.status == .completed {
-                // 85.819125
                 let audioAsset = AVURLAsset(url: fileUrl, options: avAssertOptions)
-
                 BFLog(1,message: "拼接声音文件 完成 \(fileUrl) 时长is \(CMTimeGetSeconds(audioAsset.duration))")
                 completeHander(fileUrl)