ios - AVCaptureVideoData输出分辨率

标签 ios swift xcode avfoundation avcapturesession

我试图在视频设置中将输出尺寸指定为 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/

相关文章:

ios - swift 2.0 (XCode 7 beta 5) 中的拆分方法

html - XCode,iOS : Parsing HTML encoding with hpple

iOS、iPhone、iPad : is slow loading a good strategy to avoid memory crashes?

ios - 检测节点的父节点何时更改

swift - 如何在 Swift 4 中使用 #selector() 处理 @objc 推理弃用?

ios - 用户默认设置不起作用

ios - 从 nib 文件在自定义 View 中设置自定义委托(delegate)

arrays - Swift 巨大的数组字典,非常慢

ios - 当 TableView 单元格被选择两次时,它会崩溃并出现意外的 nil 错误

ios - 在 iOS 中使用 Coreplot 每 10 秒绘制一次散点图