我试图在视频设置中将输出尺寸指定为 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]
}
还有其他方法可以以自定义的较低分辨率输出视频数据吗?
最佳答案
很抱歉,您应该遵守这些预设中的任何一个
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
]
关于ios - AVCaptureVideoData输出分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55550887/