|
@@ -119,7 +119,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
public var isPointModel:Bool = false
|
|
public var isPointModel:Bool = false
|
|
|
|
|
|
deinit {
|
|
deinit {
|
|
- FilterLog(1, message: "movie filter release")
|
|
|
|
|
|
+ BFLog(1, message: "movie filter release")
|
|
clearData()
|
|
clearData()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,7 +150,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
super.init(fragmentShader: PassthroughFragmentShader, numberOfInputs: 1)
|
|
super.init(fragmentShader: PassthroughFragmentShader, numberOfInputs: 1)
|
|
moveSticker = movieSticker
|
|
moveSticker = movieSticker
|
|
stickerInfo = movieSticker
|
|
stickerInfo = movieSticker
|
|
- FilterLog(2, message: "资源裁剪的 开始时间\(moveSticker!.model_in) 结束时间: \(moveSticker!.out)")
|
|
|
|
|
|
+ BFLog(2, message: "资源裁剪的 开始时间\(moveSticker!.model_in) 结束时间: \(moveSticker!.out)")
|
|
if moveSticker!.videoIsCrop() {
|
|
if moveSticker!.videoIsCrop() {
|
|
requestedStartTime = CMTimeMake(value: Int64(moveSticker!.model_in) * Int64(BASE_FILTER_TIMESCALE), timescale: BASE_FILTER_TIMESCALE)
|
|
requestedStartTime = CMTimeMake(value: Int64(moveSticker!.model_in) * Int64(BASE_FILTER_TIMESCALE), timescale: BASE_FILTER_TIMESCALE)
|
|
}
|
|
}
|
|
@@ -165,14 +165,14 @@ public class PQMovieFilter: PQBaseFilter {
|
|
if (!videoFilePath.contains("var/mobile/Media")) && (!videoFilePath.contains("BFFramework_Resources.bundle")) {
|
|
if (!videoFilePath.contains("var/mobile/Media")) && (!videoFilePath.contains("BFFramework_Resources.bundle")) {
|
|
videoFilePath = documensDirectory + videoFilePath
|
|
videoFilePath = documensDirectory + videoFilePath
|
|
}
|
|
}
|
|
- FilterLog(2, message: "视频地址 \(String(describing: videoFilePath))")
|
|
|
|
|
|
+ BFLog(2, message: "视频地址 \(String(describing: videoFilePath))")
|
|
try loadAsset(url: URL(fileURLWithPath: videoFilePath), videoComposition: nil)
|
|
try loadAsset(url: URL(fileURLWithPath: videoFilePath), videoComposition: nil)
|
|
|
|
|
|
} catch {
|
|
} catch {
|
|
NXLog(message: "load asset with error: \(error)")
|
|
NXLog(message: "load asset with error: \(error)")
|
|
}
|
|
}
|
|
|
|
|
|
- FilterLog(2, message: " move FILTER 初始化 开始显示时间:\(movieSticker.timelineIn) 结束显示时间:\(movieSticker.timelineOut) 裁剪开始时间:\(movieSticker.model_in) 裁剪结束时间:\(movieSticker.out) 路径:\(String(describing: movieSticker.locationPath)) 时长 \(CMTimeGetSeconds(asset?.duration ?? .zero))")
|
|
|
|
|
|
+ BFLog(2, message: " move FILTER 初始化 开始显示时间:\(movieSticker.timelineIn) 结束显示时间:\(movieSticker.timelineOut) 裁剪开始时间:\(movieSticker.model_in) 裁剪结束时间:\(movieSticker.out) 路径:\(String(describing: movieSticker.locationPath)) 时长 \(CMTimeGetSeconds(asset?.duration ?? .zero))")
|
|
|
|
|
|
startReading()
|
|
startReading()
|
|
|
|
|
|
@@ -189,11 +189,11 @@ public class PQMovieFilter: PQBaseFilter {
|
|
inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
|
|
inputSize = inputFramebuffer.sizeForTargetOrientation(.portrait)
|
|
|
|
|
|
currentTime = CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale)
|
|
currentTime = CMTime(value: inputFramebuffer.timingStyle.timestamp!.value, timescale: inputFramebuffer.timingStyle.timestamp!.timescale)
|
|
- FilterLog(2, message: "wwwwwwwww duration is currentSampleTime is \(CMTimeGetSeconds(currentTime))")
|
|
|
|
|
|
+ BFLog(2, message: "wwwwwwwww duration is currentSampleTime is \(CMTimeGetSeconds(currentTime))")
|
|
|
|
|
|
renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: mImageOrientation, size: inputSize, stencil: false)
|
|
renderFramebuffer = sharedImageProcessingContext.framebufferCache.requestFramebufferWithProperties(orientation: mImageOrientation, size: inputSize, stencil: false)
|
|
|
|
|
|
- FilterLog(message: "maxTextureSize is\( renderFramebuffer.context.maximumTextureSizeForThisDevice)")
|
|
|
|
|
|
+ BFLog(message: "maxTextureSize is\( renderFramebuffer.context.maximumTextureSizeForThisDevice)")
|
|
|
|
|
|
|
|
|
|
let textureProperties = InputTextureProperties(textureCoordinates: inputFramebuffer.orientation.rotationNeededForOrientation(mImageOrientation).textureCoordinates(), texture: inputFramebuffer.texture)
|
|
let textureProperties = InputTextureProperties(textureCoordinates: inputFramebuffer.orientation.rotationNeededForOrientation(mImageOrientation).textureCoordinates(), texture: inputFramebuffer.texture)
|
|
@@ -204,10 +204,10 @@ public class PQMovieFilter: PQBaseFilter {
|
|
vertexBufferObject: sharedImageProcessingContext.standardImageVBO, inputTextures: [textureProperties])
|
|
vertexBufferObject: sharedImageProcessingContext.standardImageVBO, inputTextures: [textureProperties])
|
|
releaseIncomingFramebuffers()
|
|
releaseIncomingFramebuffers()
|
|
|
|
|
|
- FilterLog(2, message: "开始显示 movefilter 了 开始\(String(describing: moveSticker?.timelineIn)) 结束 :\(String(describing: moveSticker?.timelineOut)) currentTime \(CMTimeGetSeconds(currentTime)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) ")
|
|
|
|
|
|
+ BFLog(2, message: "开始显示 movefilter 了 开始\(String(describing: moveSticker?.timelineIn)) 结束 :\(String(describing: moveSticker?.timelineOut)) currentTime \(CMTimeGetSeconds(currentTime)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) ")
|
|
|
|
|
|
if enableSeek {
|
|
if enableSeek {
|
|
- FilterLog(2, message: "seek 到 \(CMTimeGetSeconds(currentTime)) ")
|
|
|
|
|
|
+ BFLog(2, message: "seek 到 \(CMTimeGetSeconds(currentTime)) ")
|
|
resetRangeTime(startTime: currentTime)
|
|
resetRangeTime(startTime: currentTime)
|
|
enableSeek = false
|
|
enableSeek = false
|
|
}
|
|
}
|
|
@@ -228,7 +228,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
var showtimeStamp = CMTime(value:targetTime, timescale: BASE_FILTER_TIMESCALE)
|
|
var showtimeStamp = CMTime(value:targetTime, timescale: BASE_FILTER_TIMESCALE)
|
|
showtimeStamp = CMTimeAdd(showtimeStamp, stickerModelIn)
|
|
showtimeStamp = CMTimeAdd(showtimeStamp, stickerModelIn)
|
|
|
|
|
|
- FilterLog(message: "showtimeStamp is \(CMTimeGetSeconds(showtimeStamp))")
|
|
|
|
|
|
+ BFLog(message: "showtimeStamp is \(CMTimeGetSeconds(showtimeStamp))")
|
|
readNextVideoFrame(showTimeStamp: showtimeStamp)
|
|
readNextVideoFrame(showTimeStamp: showtimeStamp)
|
|
|
|
|
|
framebufferIndex = framebufferIndex + 1
|
|
framebufferIndex = framebufferIndex + 1
|
|
@@ -246,12 +246,12 @@ public class PQMovieFilter: PQBaseFilter {
|
|
var showtimeStamp = CMTime(value:targetTime, timescale: BASE_FILTER_TIMESCALE)
|
|
var showtimeStamp = CMTime(value:targetTime, timescale: BASE_FILTER_TIMESCALE)
|
|
showtimeStamp = CMTimeAdd(showtimeStamp, stickerModelIn)
|
|
showtimeStamp = CMTimeAdd(showtimeStamp, stickerModelIn)
|
|
|
|
|
|
- FilterLog(message: "showtimeStamp is \(CMTimeGetSeconds(showtimeStamp))")
|
|
|
|
|
|
+ BFLog(message: "showtimeStamp is \(CMTimeGetSeconds(showtimeStamp))")
|
|
readNextVideoFrame(showTimeStamp: showtimeStamp)
|
|
readNextVideoFrame(showTimeStamp: showtimeStamp)
|
|
|
|
|
|
framebufferIndex = framebufferIndex + 1
|
|
framebufferIndex = framebufferIndex + 1
|
|
}else{
|
|
}else{
|
|
- FilterLog(message: "movefilter 已经不显示了")
|
|
|
|
|
|
+ BFLog(message: "movefilter 已经不显示了")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -261,7 +261,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
// 原视频角度类型
|
|
// 原视频角度类型
|
|
public func moveAssetRotation() -> NXGPUImageRotationMode {
|
|
public func moveAssetRotation() -> NXGPUImageRotationMode {
|
|
let Angle: Int = PQPHAssetVideoParaseUtil.videoRotationAngle(assert: asset!)
|
|
let Angle: Int = PQPHAssetVideoParaseUtil.videoRotationAngle(assert: asset!)
|
|
- // FilterLog(2, message: "原视频素材Angle is \(Angle)")
|
|
|
|
|
|
+ // BFLog(2, message: "原视频素材Angle is \(Angle)")
|
|
// see https://my.oschina.net/NycoWang/blog/904105
|
|
// see https://my.oschina.net/NycoWang/blog/904105
|
|
switch Angle {
|
|
switch Angle {
|
|
case -90, 270:
|
|
case -90, 270:
|
|
@@ -286,14 +286,14 @@ public class PQMovieFilter: PQBaseFilter {
|
|
stickerFPS = asset!.tracks(withMediaType: .video).first?.nominalFrameRate ?? 0.0
|
|
stickerFPS = asset!.tracks(withMediaType: .video).first?.nominalFrameRate ?? 0.0
|
|
let bitRate = asset!.tracks(withMediaType: .video).first?.estimatedDataRate
|
|
let bitRate = asset!.tracks(withMediaType: .video).first?.estimatedDataRate
|
|
|
|
|
|
- FilterLog(2, message: "move filter asset fps is \(String(describing: stickerFPS)) bit rate is \(bitRate ?? 0)")
|
|
|
|
|
|
+ BFLog(2, message: "move filter asset fps is \(String(describing: stickerFPS)) bit rate is \(bitRate ?? 0)")
|
|
|
|
|
|
self.videoComposition = videoComposition
|
|
self.videoComposition = videoComposition
|
|
self.playAtActualSpeed = playAtActualSpeed
|
|
self.playAtActualSpeed = playAtActualSpeed
|
|
|
|
|
|
yuvConversionShader = crashOnShaderCompileFailure("MovieInput") { try sharedImageProcessingContext.programForVertexShader(defaultVertexShaderForInputs(2), fragmentShader: YUVConversionFullRangeFragmentShader) }
|
|
yuvConversionShader = crashOnShaderCompileFailure("MovieInput") { try sharedImageProcessingContext.programForVertexShader(defaultVertexShaderForInputs(2), fragmentShader: YUVConversionFullRangeFragmentShader) }
|
|
self.audioSettings = audioSettings
|
|
self.audioSettings = audioSettings
|
|
- } else { FilterLog(2, message: "asset is nil") }
|
|
|
|
|
|
+ } else { BFLog(2, message: "asset is nil") }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: -
|
|
// MARK: -
|
|
@@ -310,7 +310,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
let videoTrack: AVAssetTrack = asset!.tracks(withMediaType: .video).first!
|
|
let videoTrack: AVAssetTrack = asset!.tracks(withMediaType: .video).first!
|
|
|
|
|
|
videoSize = videoTrack.naturalSize
|
|
videoSize = videoTrack.naturalSize
|
|
- FilterLog(2, message: "视频大小为 : \(videoSize)")
|
|
|
|
|
|
+ BFLog(2, message: "视频大小为 : \(videoSize)")
|
|
|
|
|
|
if videoComposition == nil {
|
|
if videoComposition == nil {
|
|
let readerVideoTrackOutput = AVAssetReaderTrackOutput(track: asset!.tracks(withMediaType: .video).first!, outputSettings: outputSettings)
|
|
let readerVideoTrackOutput = AVAssetReaderTrackOutput(track: asset!.tracks(withMediaType: .video).first!, outputSettings: outputSettings)
|
|
@@ -324,23 +324,23 @@ public class PQMovieFilter: PQBaseFilter {
|
|
}
|
|
}
|
|
assetReader!.timeRange = CMTimeRange(start: CMTime(value: Int64((moveSticker?.model_in ?? 0) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE), duration: CMTimeMake(value: Int64(((moveSticker?.out ?? 0) - (moveSticker?.model_in ?? 0)) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE))
|
|
assetReader!.timeRange = CMTimeRange(start: CMTime(value: Int64((moveSticker?.model_in ?? 0) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE), duration: CMTimeMake(value: Int64(((moveSticker?.out ?? 0) - (moveSticker?.model_in ?? 0)) * Float64(BASE_FILTER_TIMESCALE)), timescale: BASE_FILTER_TIMESCALE))
|
|
|
|
|
|
- FilterLog(2, message: "set assetReader!.timeRange is \(assetReader!.timeRange)")
|
|
|
|
|
|
+ BFLog(2, message: "set assetReader!.timeRange is \(assetReader!.timeRange)")
|
|
|
|
|
|
return assetReader
|
|
return assetReader
|
|
} catch {
|
|
} catch {
|
|
- FilterLog(message:"movie filter ERROR: Unable to create asset reader: \(error)")
|
|
|
|
|
|
+ BFLog(message:"movie filter ERROR: Unable to create asset reader: \(error)")
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
public func startReading() {
|
|
public func startReading() {
|
|
- FilterLog(2, message: "开始初始化")
|
|
|
|
|
|
+ BFLog(2, message: "开始初始化")
|
|
mach_timebase_info(&timebaseInfo)
|
|
mach_timebase_info(&timebaseInfo)
|
|
|
|
|
|
assetReader?.cancelReading()
|
|
assetReader?.cancelReading()
|
|
|
|
|
|
guard let assetReader = createReader() else {
|
|
guard let assetReader = createReader() else {
|
|
- FilterLog(message: "createReader is error")
|
|
|
|
|
|
+ BFLog(message: "createReader is error")
|
|
return // A return statement in this frame will end thread execution.
|
|
return // A return statement in this frame will end thread execution.
|
|
}
|
|
}
|
|
|
|
|
|
@@ -350,19 +350,19 @@ public class PQMovieFilter: PQBaseFilter {
|
|
#if DEBUG
|
|
#if DEBUG
|
|
cShowHUB(superView: nil, msg: "\(String(describing: assetReader.error))")
|
|
cShowHUB(superView: nil, msg: "\(String(describing: assetReader.error))")
|
|
#endif
|
|
#endif
|
|
- FilterLog(message:"ERROR: Unable to start reading: \(String(describing: assetReader.error))")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Unable to start reading: \(String(describing: assetReader.error))")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch {
|
|
} catch {
|
|
- FilterLog(message:"ERROR: Unable to start reading: \(error)")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Unable to start reading: \(error)")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// 设置解码开始时间
|
|
// 设置解码开始时间
|
|
public func resetRangeTime(startTime: CMTime = .zero) {
|
|
public func resetRangeTime(startTime: CMTime = .zero) {
|
|
- FilterLog(2, message: "\(String(describing: moveSticker?.locationPath)) 取帧的时间 \(CMTimeGetSeconds(requestedStartTime ?? .zero))")
|
|
|
|
|
|
+ BFLog(2, message: "\(String(describing: moveSticker?.locationPath)) 取帧的时间 \(CMTimeGetSeconds(requestedStartTime ?? .zero))")
|
|
requestedStartTime = startTime
|
|
requestedStartTime = startTime
|
|
startReading()
|
|
startReading()
|
|
}
|
|
}
|
|
@@ -378,12 +378,12 @@ public class PQMovieFilter: PQBaseFilter {
|
|
|
|
|
|
// 最后一帧的PTS > 要显示的目标时间 就不从解码器要数据,直接返回 view 不刷新 只有慢速时会调用
|
|
// 最后一帧的PTS > 要显示的目标时间 就不从解码器要数据,直接返回 view 不刷新 只有慢速时会调用
|
|
// if CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) + (stickerInfo?.model_in ?? 0) && CMTimeGetSeconds(targetTimeStamp) != 0 {
|
|
// if CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) + (stickerInfo?.model_in ?? 0) && CMTimeGetSeconds(targetTimeStamp) != 0 {
|
|
- FilterLog(2, message: "28797speedRate 目标显示时间 \(String(format: "%.6f", (CMTimeGetSeconds(showTimeStamp)))) 最后显示的时间 \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) speedRate is \(stickerInfo!.speedRate)")
|
|
|
|
|
|
+ BFLog(2, message: "28797speedRate 目标显示时间 \(String(format: "%.6f", (CMTimeGetSeconds(showTimeStamp)))) 最后显示的时间 \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) speedRate is \(stickerInfo!.speedRate)")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
if assetReader == nil {
|
|
if assetReader == nil {
|
|
- FilterLog(2, message: "assetReader is error 出现严重错误!!!!!!!!!!!!!!")
|
|
|
|
|
|
+ BFLog(2, message: "assetReader is error 出现严重错误!!!!!!!!!!!!!!")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -404,7 +404,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
count = count + 1
|
|
count = count + 1
|
|
sampleBuffer = videoTrackOutput!.copyNextSampleBuffer()
|
|
sampleBuffer = videoTrackOutput!.copyNextSampleBuffer()
|
|
if sampleBuffer == nil {
|
|
if sampleBuffer == nil {
|
|
- FilterLog(2, message: " copyNextSampleBuffer is nil error!!!")
|
|
|
|
|
|
+ BFLog(2, message: " copyNextSampleBuffer is nil error!!!")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
targetTimeStamp = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer!)
|
|
targetTimeStamp = CMSampleBufferGetOutputPresentationTimeStamp(sampleBuffer!)
|
|
@@ -413,12 +413,12 @@ public class PQMovieFilter: PQBaseFilter {
|
|
if sampleBuffer != nil && CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) {
|
|
if sampleBuffer != nil && CMTimeGetSeconds(targetTimeStamp) >= CMTimeGetSeconds(showTimeStamp) {
|
|
let endDecoderTime: TimeInterval = Date().timeIntervalSince1970
|
|
let endDecoderTime: TimeInterval = Date().timeIntervalSince1970
|
|
|
|
|
|
- FilterLog(2, message: " 28797speedRate is \(stickerInfo!.speedRate) 当前主线时间为:\(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 要命中时间:\(CMTimeGetSeconds(showTimeStamp)) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 差值\(CMTimeGetSeconds(targetTimeStamp) - (stickerInfo?.model_in ?? 0)) 查找耗时为:\(String(format: "%.6f", TimeInterval(endDecoderTime - beginDecoderTime))) 查找次数\(count) 进场时间: \(String(describing: moveSticker?.timelineIn)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) 裁剪结束时间:\(String(describing: moveSticker?.out)) 原视频时长: \(CMTimeGetSeconds(asset?.duration ?? .zero))")
|
|
|
|
|
|
+ BFLog(1, message: " 28797speedRate is \(stickerInfo!.speedRate) 当前主线时间为:\(String(format: "%.6f", CMTimeGetSeconds(currentTime))) 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 要命中时间:\(CMTimeGetSeconds(showTimeStamp)) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp))) 差值\(CMTimeGetSeconds(targetTimeStamp) - (stickerInfo?.model_in ?? 0)) 查找耗时为:\(String(format: "%.6f", TimeInterval(endDecoderTime - beginDecoderTime))) 查找次数\(count) 进场时间: \(String(describing: moveSticker?.timelineIn)) 裁剪开始时间:\(String(describing: moveSticker?.model_in)) 裁剪结束时间:\(String(describing: moveSticker?.out)) 原视频时长: \(CMTimeGetSeconds(asset?.duration ?? .zero))")
|
|
break
|
|
break
|
|
|
|
|
|
}
|
|
}
|
|
// else {
|
|
// else {
|
|
- // FilterLog(2, message: "不丢帧显示 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp)))")
|
|
|
|
|
|
+ // BFLog(2, message: "不丢帧显示 查找的帧时间为:\(String(format: "%.6f", CMTimeGetSeconds(showTimeStamp).truncatingRemainder(dividingBy: moveSticker!.out))) 命中时间为: \(String(format: "%.6f", CMTimeGetSeconds(targetTimeStamp)))")
|
|
//// usleep(2)
|
|
//// usleep(2)
|
|
//// sharedImageProcessingContext.runOperationSynchronously {
|
|
//// sharedImageProcessingContext.runOperationSynchronously {
|
|
//// self.renderPixelBuffler(movieFrame: CMSampleBufferGetImageBuffer(sampleBuffer!)!, withSampleTime: currentTime)
|
|
//// self.renderPixelBuffler(movieFrame: CMSampleBufferGetImageBuffer(sampleBuffer!)!, withSampleTime: currentTime)
|
|
@@ -437,23 +437,23 @@ public class PQMovieFilter: PQBaseFilter {
|
|
}
|
|
}
|
|
return
|
|
return
|
|
} else {
|
|
} else {
|
|
- FilterLog(2, message: "sampleBuffer is nil data is error self.assetReader?.status is \(String(describing: assetReader?.status))")
|
|
|
|
|
|
+ BFLog(2, message: "sampleBuffer is nil data is error self.assetReader?.status is \(String(describing: assetReader?.status))")
|
|
}
|
|
}
|
|
// 二, 已经播放完一次
|
|
// 二, 已经播放完一次
|
|
if assetReader?.status == .completed {
|
|
if assetReader?.status == .completed {
|
|
- FilterLog(message: "已经播放完一次")
|
|
|
|
|
|
+ BFLog(message: "已经播放完一次")
|
|
// 1 自动循环模式 重头开始循环
|
|
// 1 自动循环模式 重头开始循环
|
|
if moveSticker?.materialDurationFit?.fitType == adapterMode.loopAuto.rawValue {
|
|
if moveSticker?.materialDurationFit?.fitType == adapterMode.loopAuto.rawValue {
|
|
- FilterLog(2, message: "自动循环模式 重头开始循环 \(CMTimeGetSeconds(currentTime))")
|
|
|
|
|
|
+ BFLog(2, message: "自动循环模式 重头开始循环 \(CMTimeGetSeconds(currentTime))")
|
|
|
|
|
|
startReading()
|
|
startReading()
|
|
|
|
|
|
} else if moveSticker?.materialDurationFit?.fitType == adapterMode.staticFrame.rawValue {
|
|
} else if moveSticker?.materialDurationFit?.fitType == adapterMode.staticFrame.rawValue {
|
|
// 2),定帧处理
|
|
// 2),定帧处理
|
|
if lastImageBuffer != nil {
|
|
if lastImageBuffer != nil {
|
|
- FilterLog(2, message: "处理显示定帧")
|
|
|
|
|
|
+ BFLog(2, message: "处理显示定帧")
|
|
let currTime = CMTimeGetSeconds(currentTime)
|
|
let currTime = CMTimeGetSeconds(currentTime)
|
|
- FilterLog(2, message: "process time is \(currTime)")
|
|
|
|
|
|
+ BFLog(2, message: "process time is \(currTime)")
|
|
sharedImageProcessingContext.runOperationSynchronously { [weak self] in
|
|
sharedImageProcessingContext.runOperationSynchronously { [weak self] in
|
|
if let imgBuffer = self?.lastImageBuffer {
|
|
if let imgBuffer = self?.lastImageBuffer {
|
|
renderPixelBuffler(movieFrame: imgBuffer, withSampleTime: currentTime)
|
|
renderPixelBuffler(movieFrame: imgBuffer, withSampleTime: currentTime)
|
|
@@ -472,7 +472,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
// let image = UIImage.init(pixelBuffer: movieFrame)
|
|
// let image = UIImage.init(pixelBuffer: movieFrame)
|
|
// image!.saveImage(currentImage: image!, persent: 0.5, imageName: "\(CMTimeGetSeconds(withSampleTime))")
|
|
// image!.saveImage(currentImage: image!, persent: 0.5, imageName: "\(CMTimeGetSeconds(withSampleTime))")
|
|
// NV12 会返回 2,Y分量和UV 分量, 如果buffer 是BGRA 则返回0
|
|
// NV12 会返回 2,Y分量和UV 分量, 如果buffer 是BGRA 则返回0
|
|
- FilterLog(2, message: "CVPixelBufferGetPlaneCount is \(CVPixelBufferGetPlaneCount(movieFrame))")
|
|
|
|
|
|
+ BFLog(2, message: "CVPixelBufferGetPlaneCount is \(CVPixelBufferGetPlaneCount(movieFrame))")
|
|
|
|
|
|
let bufferHeight = CVPixelBufferGetHeight(movieFrame)
|
|
let bufferHeight = CVPixelBufferGetHeight(movieFrame)
|
|
let bufferWidth = CVPixelBufferGetWidth(movieFrame)
|
|
let bufferWidth = CVPixelBufferGetWidth(movieFrame)
|
|
@@ -490,7 +490,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
|
|
|
|
if luminanceGLTextureResult != kCVReturnSuccess || luminanceGLTexture == nil {
|
|
if luminanceGLTextureResult != kCVReturnSuccess || luminanceGLTexture == nil {
|
|
|
|
|
|
- FilterLog(message:"ERROR: Could not create LuminanceGLTexture")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Could not create LuminanceGLTexture")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -505,7 +505,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
do {
|
|
do {
|
|
luminanceFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: GLint(bufferWidth), height: GLint(bufferHeight)), textureOnly: true, overriddenTexture: luminanceTexture)
|
|
luminanceFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: GLint(bufferWidth), height: GLint(bufferHeight)), textureOnly: true, overriddenTexture: luminanceTexture)
|
|
} catch {
|
|
} catch {
|
|
- FilterLog(message:"ERROR: Could not create a framebuffer of the size (\(bufferWidth), \(bufferHeight)), error: \(error)")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Could not create a framebuffer of the size (\(bufferWidth), \(bufferHeight)), error: \(error)")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
luminanceFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
luminanceFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
@@ -518,7 +518,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
let chrominanceGLTextureResult = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, sharedImageProcessingContext.coreVideoTextureCache, movieFrame, nil, GLenum(GL_TEXTURE_2D), GL_LUMINANCE_ALPHA, GLsizei(bufferWidth / 2), GLsizei(bufferHeight / 2), GLenum(GL_LUMINANCE_ALPHA), GLenum(GL_UNSIGNED_BYTE), 1, &chrominanceGLTexture)
|
|
let chrominanceGLTextureResult = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault, sharedImageProcessingContext.coreVideoTextureCache, movieFrame, nil, GLenum(GL_TEXTURE_2D), GL_LUMINANCE_ALPHA, GLsizei(bufferWidth / 2), GLsizei(bufferHeight / 2), GLenum(GL_LUMINANCE_ALPHA), GLenum(GL_UNSIGNED_BYTE), 1, &chrominanceGLTexture)
|
|
|
|
|
|
if chrominanceGLTextureResult != kCVReturnSuccess || chrominanceGLTexture == nil {
|
|
if chrominanceGLTextureResult != kCVReturnSuccess || chrominanceGLTexture == nil {
|
|
- FilterLog(message:"ERROR: Could not create ChrominanceGLTexture")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Could not create ChrominanceGLTexture")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
@@ -532,7 +532,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
do {
|
|
do {
|
|
chrominanceFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: GLint(bufferWidth), height: GLint(bufferHeight)), textureOnly: true, overriddenTexture: chrominanceTexture)
|
|
chrominanceFramebuffer = try Framebuffer(context: sharedImageProcessingContext, orientation: .portrait, size: GLSize(width: GLint(bufferWidth), height: GLint(bufferHeight)), textureOnly: true, overriddenTexture: chrominanceTexture)
|
|
} catch {
|
|
} catch {
|
|
- FilterLog(message:"ERROR: Could not create a framebuffer of the size (\(bufferWidth), \(bufferHeight)), error: \(error)")
|
|
|
|
|
|
+ BFLog(message:"ERROR: Could not create a framebuffer of the size (\(bufferWidth), \(bufferHeight)), error: \(error)")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
chrominanceFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
chrominanceFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
@@ -544,7 +544,7 @@ public class PQMovieFilter: PQBaseFilter {
|
|
convertYUVToRGBAK(shader: yuvConversionShader!, luminanceFramebuffer: luminanceFramebuffer, chrominanceFramebuffer: chrominanceFramebuffer, resultFramebuffer: movieFramebuffer, colorConversionMatrix: conversionMatrix)
|
|
convertYUVToRGBAK(shader: yuvConversionShader!, luminanceFramebuffer: luminanceFramebuffer, chrominanceFramebuffer: chrominanceFramebuffer, resultFramebuffer: movieFramebuffer, colorConversionMatrix: conversionMatrix)
|
|
CVPixelBufferUnlockBaseAddress(movieFrame, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
|
|
CVPixelBufferUnlockBaseAddress(movieFrame, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
|
|
|
|
|
|
- FilterLog(2, message: "mp4 render process time is \(CMTimeGetSeconds(withSampleTime))")
|
|
|
|
|
|
+ BFLog(2, message: "mp4 render process time is \(CMTimeGetSeconds(withSampleTime))")
|
|
movieFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
movieFramebuffer.timingStyle = .videoFrame(timestamp: Timestamp(withSampleTime))
|
|
|
|
|
|
movieFramebuffer.userInfo = framebufferUserInfo
|
|
movieFramebuffer.userInfo = framebufferUserInfo
|