主要问题在于assetwriter的videosetting配置处
This commit is contained in:
parent
22c31d4a7e
commit
c67eecd78d
Binary file not shown.
@ -97,11 +97,16 @@ extension CCSpatialShootController {
|
||||
// session.addOutput(wideAngleCameraMovieOutput)
|
||||
|
||||
wideAngleCameraVideoDataOutput = AVCaptureVideoDataOutput()
|
||||
// svdWriter.videoSettings = wideAngleCameraVideoDataOutput?.recommendedVideoSettingsForAssetWriter(writingTo: .heic)
|
||||
guard let wideAngleCameraVideoDataOutput, session.canAddOutput(wideAngleCameraVideoDataOutput) else {
|
||||
print("wideAngleCameraVideoDataOutput....")
|
||||
return
|
||||
}
|
||||
wideAngleCameraVideoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue.global())
|
||||
wideAngleCameraVideoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue.global())
|
||||
wideAngleCameraVideoDataOutput.alwaysDiscardsLateVideoFrames = true
|
||||
wideAngleCameraVideoDataOutput.videoSettings = [
|
||||
kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA),
|
||||
]
|
||||
// wideAngleCameraVideoDataOutput.videoSettings =
|
||||
// [NSDictionary dictionaryWithObject:
|
||||
// [NSNumber numberWithInt:kCVPixelFormatType_32BGRA]
|
||||
@ -124,9 +129,15 @@ extension CCSpatialShootController {
|
||||
print("ultraWideCameraVideoDataOutput....")
|
||||
return
|
||||
}
|
||||
ultraWideCameraVideoDataOutput.alwaysDiscardsLateVideoFrames = true
|
||||
ultraWideCameraVideoDataOutput.setSampleBufferDelegate(self, queue: DispatchQueue.global())
|
||||
ultraWideCameraVideoDataOutput.videoSettings = [
|
||||
kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA),
|
||||
]
|
||||
// svdWriter.videoSettings = wideAngleCameraVideoDataOutput.recommendedVideoSettingsForAssetWriter(writingTo: .mov)
|
||||
session.addOutput(ultraWideCameraVideoDataOutput)
|
||||
|
||||
|
||||
//配置声音输出
|
||||
wuCameraAudioDataOutput = AVCaptureAudioDataOutput()
|
||||
guard let wuCameraAudioDataOutput,
|
||||
@ -147,7 +158,7 @@ extension CCSpatialShootController {
|
||||
self.view.layer.insertSublayer(wideAngleCameraVideoPreviewLayer, at: 0)
|
||||
}
|
||||
|
||||
|
||||
|
||||
DispatchQueue.global().async {
|
||||
self.session.startRunning()
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ class SpatialVideoDataWriter {
|
||||
if let pixelBuffer {
|
||||
let videoWidth = CVPixelBufferGetWidth(pixelBuffer)
|
||||
let videoHeight = CVPixelBufferGetHeight(pixelBuffer)
|
||||
writeVideoDataInit(videoWidth: KScreenHeight, videoHeight: KScreenWidth)
|
||||
writeVideoDataInit(videoWidth: Double(videoWidth), videoHeight: Double(videoHeight))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -86,6 +86,7 @@ class SpatialVideoDataWriter {
|
||||
do {
|
||||
// 创建视频输入
|
||||
assetWriter = try AVAssetWriter(outputURL: outputVideoURL, fileType: .mov)
|
||||
|
||||
videoSettings = [
|
||||
AVVideoWidthKey: videoWidth,
|
||||
AVVideoHeightKey: videoHeight,
|
||||
@ -96,6 +97,13 @@ class SpatialVideoDataWriter {
|
||||
kVTCompressionPropertyKey_HorizontalDisparityAdjustment: 200, // asset-specific
|
||||
]
|
||||
]
|
||||
// var ac = videoSettings[AVVideoCompressionPropertiesKey] as! [String:Any]
|
||||
// ac[kVTCompressionPropertyKey_MVHEVCVideoLayerIDs as String] = [0, 1]
|
||||
// ac[kCMFormatDescriptionExtension_HorizontalFieldOfView as String] = 90_000
|
||||
// ac[kVTCompressionPropertyKey_HorizontalDisparityAdjustment as String] = 200
|
||||
// videoSettings[AVVideoCompressionPropertiesKey] = ac
|
||||
|
||||
|
||||
input_video = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings)
|
||||
input_video.expectsMediaDataInRealTime = true
|
||||
adaptor_inputVideo = AVAssetWriterInputTaggedPixelBufferGroupAdaptor(assetWriterInput: input_video)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user