Bläddra i källkod

fix:合成无图像问题

harry 3 år sedan
förälder
incheckning
e15f0a2f27

+ 8 - 2
BFRecordScreenKit/Classes/BFRecordExport.swift.swift

@@ -38,21 +38,27 @@ public class BFRecordExport {
 
     
     //MARK: -
-    public func start(){
+    public func startExprot(){
         // 1,背景视频素材
         let bgMovieInfo: PQEditVisionTrackMaterialsModel = PQEditVisionTrackMaterialsModel()
         bgMovieInfo.type = StickerType.VIDEO.rawValue
-        bgMovieInfo.locationPath = (asset?.url.absoluteString)?.removingPercentEncoding ?? ""
+        bgMovieInfo.locationPath = ((asset?.url.absoluteString)?.removingPercentEncoding ?? "").replacingOccurrences(of: "file://", with: "")
         bgMovieInfo.timelineIn = 0
         bgMovieInfo.timelineOut = CMTimeGetSeconds(asset?.duration ?? CMTime.zero)
         bgMovieInfo.model_in = bgMovieInfo.timelineIn
         bgMovieInfo.out = bgMovieInfo.timelineOut
         bgMovieInfo.canvasFillType = stickerContentMode.aspectFitStr.rawValue
+        bgMovieInfo.volumeGain = 30
+        bgMovieInfo.aptDuration = bgMovieInfo.timelineOut
         mStickers.append(bgMovieInfo)
     
         beginExport(videoStickers: mStickers, audioAsset: self.audioAssets)
     }
     
+    public func cancelExport(){
+        self.exporter?.cancel()
+    }
+    
     enum DispatchError: Error {
         case timeout
     }

+ 1 - 3
BFRecordScreenKit/Classes/BFRecordScreenController.swift

@@ -122,15 +122,13 @@ public class BFRecordScreenController: BFBaseViewController {
     lazy var closeBtn:UIButton = {
         let btn = UIButton(type: .custom)
         btn.setImage(imageInRecordScreenKit(by: "xx"), for: .normal)
-//        btn.contentHorizontalAlignment = .right
-        btn.addTarget(self, action: #selector(backBtnClick), for: .touchUpInside)
+        btn.addTarget(self, action: #selector(close), for: .touchUpInside)
         return btn
     }()
     
     lazy var nextBtn:UIButton = {
         let btn = UIButton(type: .custom)
         btn.setImage(imageInRecordScreenKit(by: "gou"), for: .normal)
-//        btn.contentHorizontalAlignment = .left
         btn.addTarget(self, action: #selector(nextAction), for: .touchUpInside)
         return btn
     }()

+ 9 - 5
Example/BFRecordScreenKit.xcodeproj/project.pbxproj

@@ -27,7 +27,7 @@
 		4A426DA6274FA4E000B3733B /* IntroduceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IntroduceController.swift; sourceTree = "<group>"; };
 		4A96F093274CF8DC008657DA /* PhotoVideoListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoVideoListController.swift; sourceTree = "<group>"; };
 		5E394037E3C86B6D51A62719 /* Pods_BFRecordScreenKit_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_BFRecordScreenKit_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
-		607FACD01AFB9204008FA782 /* BFRecordScreenKit_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BFRecordScreenKit_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
+		607FACD01AFB9204008FA782 /* 开讲.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "开讲.app"; sourceTree = BUILT_PRODUCTS_DIR; };
 		607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
 		607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
 		607FACD71AFB9204008FA782 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
@@ -78,7 +78,7 @@
 		607FACD11AFB9204008FA782 /* Products */ = {
 			isa = PBXGroup;
 			children = (
-				607FACD01AFB9204008FA782 /* BFRecordScreenKit_Example.app */,
+				607FACD01AFB9204008FA782 /* 开讲.app */,
 			);
 			name = Products;
 			sourceTree = "<group>";
@@ -166,7 +166,7 @@
 			);
 			name = BFRecordScreenKit_Example;
 			productName = BFRecordScreenKit;
-			productReference = 607FACD01AFB9204008FA782 /* BFRecordScreenKit_Example.app */;
+			productReference = 607FACD01AFB9204008FA782 /* 开讲.app */;
 			productType = "com.apple.product-type.application";
 		};
 /* End PBXNativeTarget section */
@@ -465,11 +465,13 @@
 				DEVELOPMENT_TEAM = UH52C8A7SN;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = BFRecordScreenKit/Info.plist;
+				INFOPLIST_KEY_CFBundleDisplayName = "开讲";
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				MODULE_NAME = ExampleApp;
 				PRODUCT_BUNDLE_IDENTIFIER = "com.tzld.BFRecordScreenKit-Example";
-				PRODUCT_NAME = "$(TARGET_NAME)";
+				PRODUCT_MODULE_NAME = "$(TARGET_NAME)";
+				PRODUCT_NAME = "开讲";
 				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
 				SWIFT_VERSION = 4.0;
 			};
@@ -483,11 +485,13 @@
 				DEVELOPMENT_TEAM = UH52C8A7SN;
 				ENABLE_BITCODE = NO;
 				INFOPLIST_FILE = BFRecordScreenKit/Info.plist;
+				INFOPLIST_KEY_CFBundleDisplayName = "开讲";
 				IPHONEOS_DEPLOYMENT_TARGET = 10.0;
 				LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
 				MODULE_NAME = ExampleApp;
 				PRODUCT_BUNDLE_IDENTIFIER = "com.tzld.BFRecordScreenKit-Example";
-				PRODUCT_NAME = "$(TARGET_NAME)";
+				PRODUCT_MODULE_NAME = "$(TARGET_NAME)";
+				PRODUCT_NAME = "开讲";
 				SWIFT_SWIFT3_OBJC_INFERENCE = Default;
 				SWIFT_VERSION = 4.0;
 			};

+ 4 - 0
Example/BFRecordScreenKit/AppDelegate.swift

@@ -21,6 +21,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             tbc.tabBar.barTintColor = .black
             tbc.tabBar.backgroundColor = .black
             tbc.tabBar.tintColor = .black
+            
+            for item in tbc.tabBar.items! {
+                item.setTitleTextAttributes([.foregroundColor: UIColor.white], for: .selected)
+            }
         }
         return true
     }

+ 13 - 11
Example/BFRecordScreenKit/Base.lproj/LaunchScreen.xib

@@ -1,12 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="13771" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
-    <device id="retina4_7" orientation="portrait">
-        <adaptation id="fullscreen"/>
-    </device>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="19455" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13772"/>
-        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19454"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -17,15 +14,15 @@
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
                 <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="  Copyright (c) 2015 CocoaPods. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
-                    <rect key="frame" x="20" y="439" width="441" height="21"/>
+                    <rect key="frame" x="20" y="439" width="440" height="21"/>
                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
-                    <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                    <color key="textColor" systemColor="darkTextColor"/>
                     <nil key="highlightedColor"/>
                 </label>
-                <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="BFRecordScreenKit" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
-                    <rect key="frame" x="20" y="140" width="441" height="43"/>
+                <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="开讲" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
+                    <rect key="frame" x="20" y="139.5" width="440" height="43"/>
                     <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
-                    <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
+                    <color key="textColor" systemColor="darkTextColor"/>
                     <nil key="highlightedColor"/>
                 </label>
             </subviews>
@@ -43,4 +40,9 @@
             <point key="canvasLocation" x="548" y="455"/>
         </view>
     </objects>
+    <resources>
+        <systemColor name="darkTextColor">
+            <color white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
 </document>

+ 12 - 2
Example/BFRecordScreenKit/PhotoVideoListController.swift

@@ -20,7 +20,7 @@ class PhotoVideoListController: BFBaseViewController {
     
     lazy var photoMaterialVc: BFPhotosMaterialController = {
         let vc = BFPhotosMaterialController()
-        vc.view.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei)
+        vc.view.frame = CGRect(x: 0, y: cDevice_iPhoneNavBarAndStatusBarHei, width: cScreenWidth, height: cScreenHeigth - cDevice_iPhoneNavBarAndStatusBarHei - cDevice_iPhoneTabBarHei)
         vc.view.backgroundColor = .black
         vc.selectedMaterialHandle = { [weak self] currentMaterialData, selectedPhotoData, _, _ in
             if currentMaterialData?.isSelected ?? false{
@@ -47,12 +47,22 @@ class PhotoVideoListController: BFBaseViewController {
         super.viewDidLoad()
 
         leftButton(image: nil, imageName: nil, tintColor: .white)
-        rightButtonItem(image: nil, title: "下一步   ", titleColor: .white)
         navHeadImageView?.backgroundColor = .black
         
         addChildViewController(photoMaterialVc)
         view.addSubview(photoMaterialVc.view)
         
+        let bottomV = UIView(frame: CGRect(x: 0, y: cScreenHeigth - cDevice_iPhoneTabBarHei, width: cScreenWidth, height: cDevice_iPhoneTabBarHei))
+        bottomV.backgroundColor = .black
+        view.addSubview(bottomV)
+        
+        let nextBtn = UIButton(type: .custom)
+        nextBtn.frame = CGRect(x: cScreenWidth - 80, y: 10, width: 70, height: 29)
+        nextBtn.backgroundColor = UIColor.hexColor(hexadecimal: "#28BE67")
+        nextBtn.setTitle("下一步", for: .normal)
+        nextBtn.addTarget(self, action: #selector(rightBtnClick(sender:)), for: .touchUpInside)
+        bottomV.addSubview(nextBtn)
+        
     }
     
     override func rightBtnClick(sender _: UIButton) {

+ 15 - 5
Example/BFRecordScreenKit/VideoExportController.swift

@@ -17,13 +17,13 @@ class VideoExportController: BFBaseViewController{
     var videoAsset : AVURLAsset?
     
     lazy var progressView : UIView = {
-        let v = UIView(frame: CGRect(x: 10, y: 100, width: 0, height: 30))
+        let v = UIView(frame: CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: 0, height: 30))
         v.backgroundColor = .red
         return v
     }()
     
     lazy var progressL : UILabel = {
-        let la = UILabel(frame: CGRect(x: 10, y: 100, width: cScreenWidth - 20, height: 30))
+        let la = UILabel(frame: CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: cScreenWidth, height: 30))
         la.textColor = .white
         la.text = "0%"
         la.font = UIFont.systemFont(ofSize: 18)
@@ -34,7 +34,7 @@ class VideoExportController: BFBaseViewController{
         let export = BFRecordExport()
         
         export.progress = {[weak self] progress in
-            self?.progressView.frame = CGRect(x: 10, y: 100, width: (cScreenWidth - 20) * CGFloat(progress), height: 30)
+            self?.progressView.frame = CGRect(x: 0, y: cDevice_iPhoneStatusBarHei, width: (cScreenWidth) * CGFloat(progress), height: 30)
             self?.progressL.text = String(format: "%d", Int(progress*100))
         }
         export.exportCompletion = {[weak self] (error, url) in
@@ -47,7 +47,7 @@ class VideoExportController: BFBaseViewController{
                     let item = AVPlayerItem(url: fileUrl)
                     let avplayer = AVPlayer(playerItem: item)
                     let playerLayer = AVPlayerLayer(player: avplayer)
-                    playerLayer.frame = CGRect(x: 10, y: strongSelf.progressView.bottomY+5, width: cScreenWidth - 20, height: cScreenHeigth - strongSelf.progressView.bottomY - 10)
+                    playerLayer.frame = CGRect(x: 10, y: strongSelf.progressView.bottomY, width: cScreenWidth - 20, height: cScreenHeigth - strongSelf.progressView.bottomY - 10)
                     strongSelf.view.layer.addSublayer(playerLayer)
                     avplayer.play()
                 }
@@ -55,6 +55,16 @@ class VideoExportController: BFBaseViewController{
         }
         return export
     }()
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        showNavigation()
+    }
+    
+    override func backBtnClick() {
+        export.cancelExport()
+        super.backBtnClick()
+    }
 
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -65,6 +75,6 @@ class VideoExportController: BFBaseViewController{
         view.addSubview(progressView)
         view.addSubview(progressL)
 
-        export.start()
+        export.startExprot()
     }
 }

+ 1 - 1
Example/BFRecordScreenKit/ViewController.swift

@@ -25,7 +25,7 @@ class ViewController: UIViewController {
     override func viewDidLoad() {
         super.viewDidLoad()
         view.backgroundColor = .black
-        
+        self.navigationController?.isNavigationBarHidden = true
         view.addSubview(addVideoBtn)
         addVideoBtn.snp.makeConstraints { make in
             make.width.height.equalTo(170)