AVCaptureVideoDataOutput Resolution

问题描述 投票:0回答:1

我想在视频设置中指定输出大小为960x720。但是,它似乎不起作用。

self.videoDataOutput = AVCaptureVideoDataOutput()  
if self.session.canAddOutput(self.videoDataOutput!) {  
    self.session.addOutput(videoDataOutput!)   
    self.videoDataOutput!.videoSettings = [kCVPixelBufferPixelFormatTypeKey: Int(kCVPixelFormatType_32BGRA),  
                                           kCVPixelBufferHeightKey: 960,  
                                           kCVPixelBufferWidthKey: 720] as [String : Any]  

}  

是否有其他方式以自定义的较低分辨率获得视频数据输出?

ios swift xcode avfoundation avcapturesession
1个回答
1
投票

对不起,您应该遵守这些预设中的任何一个

https://developer.apple.com/documentation/avfoundation/avcapturesession/preset

或使用此库来缩放它

https://github.com/NextLevel/NextLevelSessionExporter

这是相关部分

let exporter = NextLevelSessionExporter(withAsset: asset) 
exporter.videoOutputConfiguration = [
    AVVideoCodecKey: AVVideoCodec.h264,
    AVVideoWidthKey: NSNumber(integerLiteral: 720),
    AVVideoHeightKey: NSNumber(integerLiteral: 960),
    AVVideoScalingModeKey: AVVideoScalingModeResizeAspectFill,
    AVVideoCompressionPropertiesKey: compressionDict
]
© www.soinside.com 2019 - 2024. All rights reserved.