我试图在视频设置中指定输出大小为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 - AVCaptureVideoDataOutput分辨率,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55550887/

10-12 14:44
查看更多