|
@@ -19,7 +19,7 @@ public class PQCompositionExporter {
|
|
public let asset: AVAsset
|
|
public let asset: AVAsset
|
|
public let videoComposition: AVVideoComposition?
|
|
public let videoComposition: AVVideoComposition?
|
|
public let audioMix: AVAudioMix?
|
|
public let audioMix: AVAudioMix?
|
|
- public let filters: [ImageProcessingOperation]?
|
|
+ public var filters: [PQBaseFilter]?
|
|
public var mStickers:[PQEditVisionTrackMaterialsModel]?
|
|
public var mStickers:[PQEditVisionTrackMaterialsModel]?
|
|
public let animationTool: AVVideoCompositionCoreAnimationTool?
|
|
public let animationTool: AVVideoCompositionCoreAnimationTool?
|
|
public let exportURL: URL
|
|
public let exportURL: URL
|
|
@@ -51,7 +51,7 @@ public class PQCompositionExporter {
|
|
|
|
|
|
var isEndMovie:Bool = false
|
|
var isEndMovie:Bool = false
|
|
|
|
|
|
- public init(asset: AVAsset, videoComposition: AVVideoComposition? = nil, audioMix: AVAudioMix? = nil, filters: [ImageProcessingOperation]? = nil,stickers:[PQEditVisionTrackMaterialsModel]? = nil, animationTool: AVVideoCompositionCoreAnimationTool? = nil, exportURL: URL) {
|
|
+ public init(asset: AVAsset, videoComposition: AVVideoComposition? = nil, audioMix: AVAudioMix? = nil, filters: [PQBaseFilter]? = nil,stickers:[PQEditVisionTrackMaterialsModel]? = nil, animationTool: AVVideoCompositionCoreAnimationTool? = nil, exportURL: URL) {
|
|
self.asset = asset
|
|
self.asset = asset
|
|
self.videoComposition = videoComposition
|
|
self.videoComposition = videoComposition
|
|
self.audioMix = audioMix
|
|
self.audioMix = audioMix
|
|
@@ -123,16 +123,30 @@ public class PQCompositionExporter {
|
|
}
|
|
}
|
|
BFLog(message: "export mShowVidoSize is \(String(describing: input?.mShowVidoSize))")
|
|
BFLog(message: "export mShowVidoSize is \(String(describing: input?.mShowVidoSize))")
|
|
|
|
|
|
- let videoEncodingSettings: [String: Any] = [
|
|
+ var videoEncodingSettings: [String: Any] = ["":""]
|
|
- AVVideoCompressionPropertiesKey: [
|
|
+ if #available(iOS 11.0, *) {
|
|
- AVVideoExpectedSourceFrameRateKey: 30,
|
|
+ videoEncodingSettings = [
|
|
- AVVideoAverageBitRateKey: videoAverageBitRate == 0 ? Int(input?.mShowVidoSize.width ?? 0) * Int(input?.mShowVidoSize.height ?? 0) * 2 : videoAverageBitRate,
|
|
+ AVVideoCompressionPropertiesKey: [
|
|
- AVVideoProfileLevelKey: AVVideoProfileLevelH264HighAutoLevel,
|
|
+ AVVideoExpectedSourceFrameRateKey: 30,
|
|
- AVVideoH264EntropyModeKey: AVVideoH264EntropyModeCABAC,
|
|
+ AVVideoAverageBitRateKey: (videoAverageBitRate / 2) == 0 ? Int(input?.mShowVidoSize.width ?? 0) * Int(input?.mShowVidoSize.height ?? 0) : videoAverageBitRate,
|
|
- ],
|
|
+
|
|
-
|
|
+
|
|
- AVVideoCodecKey: AVVideoCodecH264,
|
|
+ ],
|
|
- ]
|
|
+
|
|
|
|
+ AVVideoCodecKey: AVVideoCodecHEVC,
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
do {
|
|
do {
|
|
try output = MovieOutput(URL: tmpExportURL ?? exportURL, size: Size(width: Float(input?.mShowVidoSize.width ?? 1080), height: Float(input?.mShowVidoSize.height ?? 1080)), fileType: .mp4, liveVideo: false, videoSettings: videoEncodingSettings, videoNaturalTimeScale: 30, audioSettings: audioEncodingSettings, audioSourceFormatHint: nil)
|
|
try output = MovieOutput(URL: tmpExportURL ?? exportURL, size: Size(width: Float(input?.mShowVidoSize.width ?? 1080), height: Float(input?.mShowVidoSize.height ?? 1080)), fileType: .mp4, liveVideo: false, videoSettings: videoEncodingSettings, videoNaturalTimeScale: 30, audioSettings: audioEncodingSettings, audioSourceFormatHint: nil)
|
|
@@ -147,7 +161,12 @@ public class PQCompositionExporter {
|
|
|
|
|
|
if(mStickers == nil){
|
|
if(mStickers == nil){
|
|
var currentTarget: ImageSource = input!
|
|
var currentTarget: ImageSource = input!
|
|
-
|
|
+
|
|
|
|
+
|
|
|
|
+ filters?.sort(by: { a, b in
|
|
|
|
+ a.zOrder < b.zOrder
|
|
|
|
+ })
|
|
|
|
+
|
|
if filters?.count ?? 0 > 0 {
|
|
if filters?.count ?? 0 > 0 {
|
|
filters!.forEach {
|
|
filters!.forEach {
|
|
currentTarget.addTarget($0, atTargetIndex: 0)
|
|
currentTarget.addTarget($0, atTargetIndex: 0)
|
|
@@ -166,8 +185,7 @@ public class PQCompositionExporter {
|
|
return true
|
|
return true
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+ public func findShowSticker(currTime:Float64) {
|
|
- public func findShowStikcer(currTime:Float64) {
|
|
|
|
|
|
|
|
if(mStickers?.count ?? 0 == 0){
|
|
if(mStickers?.count ?? 0 == 0){
|
|
BFLog(message: "mStickers data is error")
|
|
BFLog(message: "mStickers data is error")
|
|
@@ -182,21 +200,7 @@ public class PQCompositionExporter {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
+
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
if(currentSticker == nil){
|
|
if(currentSticker == nil){
|
|
BFLog(message: "sticker data is error")
|
|
BFLog(message: "sticker data is error")
|
|
@@ -333,7 +337,7 @@ public class PQCompositionExporter {
|
|
input?.progress = { [weak self] currTime, duration, progress in
|
|
input?.progress = { [weak self] currTime, duration, progress in
|
|
|
|
|
|
if(self?.mStickers?.count ?? 0 > 0){
|
|
if(self?.mStickers?.count ?? 0 > 0){
|
|
- self?.findShowStikcer(currTime: CMTimeGetSeconds(self?.input?.currentTime ?? .zero) )
|
|
+ self?.findShowSticker(currTime: CMTimeGetSeconds(self?.input?.currentTime ?? .zero) )
|
|
|
|
|
|
}
|
|
}
|
|
DispatchQueue.main.async {[weak self] in
|
|
DispatchQueue.main.async {[weak self] in
|