Explorar el Código

不使用 avAssertOptions AVURLAssetPreferPreciseDurationAndTimingKey 防止有些 音频 初始化失败 https://clipres.yishihui.com/longvideo/material/voice/bgm/f9da84768557462383f640585047ff1c.mp3

jsonwang hace 3 años
padre
commit
b24df7d67a

+ 2 - 2
BFFramework/Classes/PModels/editDarftModels/PQEditSectionModel.swift

@@ -69,7 +69,7 @@ class PQEditSectionModel: PQEditBaseModel {
                 sectionDuration = allStickerAptDuration()
             } else {
                 if audioFilePath.count > 0 {
-                    let audioAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + audioFilePath), options: avAssertOptions)
+                    let audioAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + audioFilePath), options: nil)
                     sectionDuration = Float64(audioAsset.duration.seconds)
                 }
             }
@@ -235,7 +235,7 @@ class PQEditSectionModel: PQEditBaseModel {
             tool.createEmptyWAVFile(url: URL(fileURLWithPath: documentPath))
            
              audioFilePath = documentPath
-             sectionDuration = CMTimeGetSeconds(AVURLAsset(url: URL(fileURLWithPath: documentPath), options: avAssertOptions).duration)
+             sectionDuration = CMTimeGetSeconds(AVURLAsset(url: URL(fileURLWithPath: documentPath), options: nil).duration)
             BFLog(message: " 生成的空声音 \(String(describing: documentPath))  时长 \(String(describing: sectionDuration))")
             
         }

+ 2 - 2
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointEditerController.swift

@@ -468,7 +468,7 @@ extension PQStuckPointEditerController {
         // 所有视频总时长
         var videoTotalDuration: Float64 = 0.0
         for video in section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials(type: "video") {
-            let asset: AVURLAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + video.locationPath), options: avAssertOptions)
+            let asset: AVURLAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + video.locationPath), options: nil)
             videoTotalDuration = videoTotalDuration + Float64(CMTimeGetSeconds(asset.duration))
         }
         if videoTotalDuration == 0 {
@@ -477,7 +477,7 @@ extension PQStuckPointEditerController {
         }
         for sticker in section.sectionTimeline!.visionTrack!.getEnableVisionTrackMaterials() {
             if sticker.type == StickerType.VIDEO.rawValue {
-                let asset: AVURLAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + sticker.locationPath), options: avAssertOptions)
+                let asset: AVURLAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + sticker.locationPath), options: nil)
                 // 要分割的段落
                 let clipNum = Int(max(round(Double(kongduan) * CMTimeGetSeconds(asset.duration) / videoTotalDuration), 1))
                 sticker.duration = CMTimeGetSeconds(asset.duration)

+ 2 - 2
BFFramework/Classes/Stuckpoint/Controller/PQStuckPointPublicController.swift

@@ -420,7 +420,7 @@ extension PQStuckPointPublicController {
         outPutMP4Path.append("video_\(String.qe.timestamp()).mp4")
         let outPutMP4URL = URL(fileURLWithPath: outPutMP4Path)
         BFLog(message: "导出视频地址 \(outPutMP4URL)")
-        let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: avAssertOptions)
+        let inputAsset = AVURLAsset(url: URL(fileURLWithPath: documensDirectory + (audioMixModel?.localPath ?? "")), options: nil)
         // 每次初始化的时候设置初始值 为 nIl
         exporter = PQCompositionExporter(asset: inputAsset, videoComposition: nil, audioMix: nil, filters: nil, stickers: mStickers, animationTool: nil, exportURL: outPutMP4URL)
         exporter.showGaussianBlur = true
@@ -585,7 +585,7 @@ extension PQStuckPointPublicController {
             PQBaseViewModel.updateProject(projectId: editProjectModel?.projectId ?? "", produceStatus: "5") { repseon, _ in
                 BFLog(message: "updateProject 结果 is \(String(describing: repseon))")
             }
-            let asset = AVURLAsset(url: exportLocalURL!, options: avAssertOptions)
+            let asset = AVURLAsset(url: exportLocalURL!, options: nil)
             let tempUploadData = PQUploadModel()
             tempUploadData.duration = CMTimeGetSeconds(asset.duration)
             tempUploadData.localPath = exportLocalURL?.absoluteString

+ 1 - 1
BFFramework/Classes/Stuckpoint/ViewModel/PQGPUImagePlayerView.swift

@@ -330,7 +330,7 @@ public class PQGPUImagePlayerView: UIView, RenderViewDelegate {
         var audioMix: AVMutableAudioMix?
         var composition: AVMutableComposition?
 
-        let asset = AVURLAsset(url: url, options: avAssertOptions)
+        let asset = AVURLAsset(url: url, options: nil)
         BFLog(message: "播放器初始化的音频时长\(asset.duration.seconds)  url is \(url)")
         self.asset = asset
         if (audioMixModel != nil && audioMixModel?.localPath != nil) || (videoStickers != nil && (videoStickers?.count ?? 0) > 0) {