Browse Source

设置 h264 encode

jsonwang 3 năm trước cách đây
mục cha
commit
1c4b1671a7

+ 27 - 14
BFFramework/Classes/PQGPUImage/akfilters/Tools/PQCompositionExporter.swift

@@ -86,6 +86,7 @@ public class PQCompositionExporter {
         //        guard let videoTrack = asset.tracks(withMediaType:AVMediaType.video).first else { return false }
         //        guard let videoTrack = asset.tracks(withMediaType:AVMediaType.video).first else { return false }
         let audioTrack = asset.tracks(withMediaType: AVMediaType.audio).first
         let audioTrack = asset.tracks(withMediaType: AVMediaType.audio).first
 
 
+        
         //
         //
         //        Float64 seconds = 3;
         //        Float64 seconds = 3;
         //        int32_t preferredTimeScale = 600;  //处理视频内容事常见的时间刻度为600,这是大部分视频帧率24fps、25fps、30fps的公倍数。音频数据常见的时间刻度就是采样率,譬如44 100(44.1kHZ)或48 000(48kHZ)。
         //        int32_t preferredTimeScale = 600;  //处理视频内容事常见的时间刻度为600,这是大部分视频帧率24fps、25fps、30fps的公倍数。音频数据常见的时间刻度就是采样率,譬如44 100(44.1kHZ)或48 000(48kHZ)。
@@ -122,20 +123,32 @@ public class PQCompositionExporter {
             print("Couldn't process movie with error: \(error)")
             print("Couldn't process movie with error: \(error)")
         }
         }
         BFLog(message: "export mShowVidoSize is \(String(describing: input?.mShowVidoSize))")
         BFLog(message: "export mShowVidoSize is \(String(describing: input?.mShowVidoSize))")
-    
-        var videoEncodingSettings: [String: Any] = ["":""]
-        if #available(iOS 11.0, *) {
-              videoEncodingSettings  = [
-                AVVideoCompressionPropertiesKey: [
-                    AVVideoExpectedSourceFrameRateKey: 30,
-                    AVVideoAverageBitRateKey: (videoAverageBitRate / 2) == 0 ? Int(input?.mShowVidoSize.width ?? 0) * Int(input?.mShowVidoSize.height ?? 0) : videoAverageBitRate,
-
-//                    AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC,
-                ],
-                //                AVVideoAllowFrameReorderingKey: videoTrack.requiresFrameReordering],
-                AVVideoCodecKey: AVVideoCodecHEVC,
-            ]
-        }
+        
+        let videoEncodingSettings: [String: Any] = [
+            AVVideoCompressionPropertiesKey: [
+                AVVideoExpectedSourceFrameRateKey: 30,
+                AVVideoAverageBitRateKey: videoAverageBitRate == 0 ? Int(input?.mShowVidoSize.width ?? 0) * Int(input?.mShowVidoSize.height ?? 0) * 2 : videoAverageBitRate,
+                AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel,
+                AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC,
+            ],
+            //                AVVideoAllowFrameReorderingKey: videoTrack.requiresFrameReordering],
+            AVVideoCodecKey: AVVideoCodecH264,
+        ] // deprecated: 11.0, renamed: "AVVideoCodecType.h264" 改名
+
+    //AVVideoCodecH265 text
+//        var videoEncodingSettings: [String: Any] = ["":""]
+//        if #available(iOS 11.0, *) {
+//              videoEncodingSettings  = [
+//                AVVideoCompressionPropertiesKey: [
+//                    AVVideoExpectedSourceFrameRateKey: 30,
+//                    AVVideoAverageBitRateKey: (videoAverageBitRate / 2) == 0 ? Int(input?.mShowVidoSize.width ?? 0) * Int(input?.mShowVidoSize.height ?? 0) : videoAverageBitRate,
+//
+////                    AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC,
+//                ],
+//                //                AVVideoAllowFrameReorderingKey: videoTrack.requiresFrameReordering],
+//                AVVideoCodecKey: AVVideoCodecHEVC,
+//            ]
+//        }
         
         
 //        let videoEncodingSettings: [String: Any] = [
 //        let videoEncodingSettings: [String: Any] = [
 //            AVVideoCompressionPropertiesKey: [
 //            AVVideoCompressionPropertiesKey: [