2
0

3 Commits e4220bf888 ... 633d0956f4

Autor SHA1 Mensagem Data
  zhongbaojian 633d0956f4 Merge branch 'develop' of http://svn.ouj.com:3000/duowan_iOS/SuperShow into develop há 5 anos atrás
  zhongbaojian 662a37cfa7 fix: iphone x 系列合成字幕位置不准问题 há 5 anos atrás
  zhongbaojian 6687c3e2c2 字幕默认不显示第一项,按时间来显示 há 5 anos atrás

+ 11 - 21
SuperShow/Tool/WSSMediaOperationTool.swift

@@ -66,7 +66,7 @@ class WSSMediaOperationTool: NSObject {
             self?.imageVideoDecoder?.startProgressing()
         }
     }
-    
+
     func endImage2Video() {
         if let imagedecoder = imageVideoDecoder {
             imageVideoDecoder?.endProgressing()
@@ -119,16 +119,7 @@ extension WSSMediaOperationTool {
     /// - Parameter videoAsset: 视频资源
     /// - Returns: 视频质量
     class func resolvePresentName(forVideoAsset videoAsset: AVAsset) -> String {
-        var presentName: String = AVAssetExportPreset960x540
-        let videoLength = videoAsset.duration.seconds
-        if videoLength < 30.0 {
-            presentName = AVAssetExportPresetHighestQuality
-        } else if videoLength >= 30.0 && videoLength < 70.0 {
-            presentName = AVAssetExportPreset1280x720
-        } else {
-            presentName = AVAssetExportPreset640x480
-        }
-        return presentName
+        return WSSCreativeTemplateConstant.getAdjustNormalPreset(videoAsset: videoAsset)
     }
 
     /// 计算裁剪时间范围
@@ -1563,16 +1554,16 @@ fileprivate extension WSSMediaOperationTool {
 
         var newWidth: CGFloat
         var newHeight: CGFloat
-        
+
         if videoRate > outputRate {
-            //高对齐
-             newHeight = outputSize.height
-             newWidth = newHeight * videoRate
-        }else {
-             newWidth = outputSize.width
-             newHeight = newWidth / videoRate
-        }
-        
+            // 高对齐
+            newHeight = outputSize.height
+            newWidth = newHeight * videoRate
+        } else {
+            newWidth = outputSize.width
+            newHeight = newWidth / videoRate
+        }
+
         let widthScale = newWidth / videoSize.width
         let heightScale = newHeight / videoSize.height
 
@@ -1639,4 +1630,3 @@ extension WSSMediaOperationTool {
         case unkown = "未知错误"
     }
 }
-

+ 17 - 7
SuperShow/UI/CoolVoice/WSSCoolVoiceSubtitleController.swift

@@ -6,6 +6,7 @@
 //  Copyright © 2019 duowan. All rights reserved.
 //
 
+import DeviceKit
 import OJASwiftKit
 import UIKit
 
@@ -1047,7 +1048,10 @@ fileprivate extension WSSCoolVoiceSubtitleController {
             self?.movieWriter?.finishRecording(completionHandler: { [weak self] in
                 let mixOutputPath: String = kOJSUserCacheDirectory + "/" + "tmp_export_mix_audio_subtitle_video" + ".mp4"
                 let combineVideo = AVURLAsset(url: outputUrl)
-                let presentName = kOJSIsNotchiPhone ? AVAssetExportPresetHighestQuality : WSSMediaOperationTool.resolvePresentName(forVideoAsset: resultVideoAsset)
+                let presentName = WSSMediaOperationTool.resolvePresentName(forVideoAsset: resultVideoAsset)
+
+                WSSSimpleLog("🥞: \(presentName)")
+
                 self?.setupMixAudioExportDisplayLink()
                 self?.mixAudioExportSeesion = try? WSSMediaOperationTool.mixAudio(withAudioAsset: audioAsset,
                                                                                   forVideo: combineVideo,
@@ -1058,6 +1062,8 @@ fileprivate extension WSSCoolVoiceSubtitleController {
                                                                                   exportPath: mixOutputPath,
                                                                                   finish: { [weak self] mixResult in
 
+                                                                                      WSSSimpleLog("#字幕合成#: \(mixOutputPath)")
+
 //                                                                                      WSSHub.dismissHub()
                                                                                       DispatchQueue.main.async {
                                                                                           hideHud()
@@ -1103,12 +1109,16 @@ fileprivate extension WSSCoolVoiceSubtitleController {
     func refreshSubtitlePaster(isFirst: Bool = false) {
         refreshSubtitlePasterData()
 
-        if let firstModel = currentShowingSubtitleInfos.safeObject(atIndex: 0) {
-            /// 初始化displayModel
-            if let vm = firstModel.fontViewModel {
-                textPasterView.changeShowViewModel(vm)
+        if isFirst == false {
+            if let current = self.videoPlayer?.currentSeconds {
+                updatePlayTime(current)
             }
+        } else {
+            // 初始化displayModel
+            updatePlayTime(0.0)
+        }
 
+        if let _ = currentShowingSubtitleInfos.safeObject(atIndex: 0) {
             if isFirst {
                 pasterOverlayView.addSubview(textPasterView)
                 textPasterView.center = textPasterDefaultCenter
@@ -1123,8 +1133,8 @@ fileprivate extension WSSCoolVoiceSubtitleController {
     }
 
     func createTextPasterInput() {
-        let rect = AVMakeRect(aspectRatio: videoSize, insideRect: pasterOverlayView.bounds)
-        let placeholer: UIView = UIView(frame: rect)
+        let rect = AVMakeRect(aspectRatio: videoSize, insideRect: kOJSScreenBounds)
+        let placeholer: UIView = UIView(frame: CGRect(origin: CGPoint.zero, size: rect.size))
 
         /// 初始化文字Text
         textPasterInfoData.removeAll()