AVFoundation Programming Guide指出捕获视频时首选的像素格式是:
kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
或 kCVPixelFormatType_32BGRA
kCVPixelFormatType_422YpCbCr8
或 kCVPixelFormatType_32BGRA
([还]没有针对 iPhone 5 或带摄像头的 iPad 设备的推荐。)
但是,对于我应该如何着手确定应用程序当前运行在什么设备上,没有提供任何帮助。如果首选像素格式在未来变得不同,因此我的应用程序未知设备会怎样?
确定任何设备的首选 YpCbCr 像素格式的正确且面向 future 的方法是什么?
最佳答案
我相信您可以将视频设置设为 nil,AVFoundation 将使用最有效的格式。例如而不是做
NSDictionary *videoSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(id)kCVPixelBufferPixelFormatTypeKey];
videoOutput.videoSettings = videoSettings;
改为这样做
videoOutput.videoSettings = nil;
您也可以尝试完全不设置它。我知道在过去我只会将它设置为 nil,除非我需要以特定格式捕获图像。
编辑
获取 AVFoundation 选择使用的格式。
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(source);
CGColorSpaceRef cref = CVImageBufferGetColorSpace(imageBuffer);
https://stackoverflow.com/questions/7186472/
相关文章:
php - PEAR 邮件连接拒绝 smtp.gmail.com
unix - SqLite3 NFS 挂载问题与锁定 - 我可以使用类似 CIFS nobrl 的东
macos - 什么类型的文件可以在 Mac 上使用 codesign 进行签名?
drupal - 如何总结 drupal 7 中 View 表的列?
security - 如何在 Web 应用程序中保护 HTML 电子邮件?
php - 在 ImageMagick 中量化图像时保留 alpha channel ?
visual-studio - Visual Studio 安装项目预生成事件
android - 向 RadioGroup 和 Radiobutton 添加过渡动画