gpt4 book ai didi

ios - 如何选择用于 AVAssetReader 的像素格式类型 (kCVPixelBufferPixelFormatTypeKey)?

转载 作者:可可西里 更新时间:2023-11-01 03:59:30 26 4
gpt4 key购买 nike

我们正在使用 AVAssetReaderAVAssetWriter 的样式,如 Video Encoding using AVAssetWriter - CRASHES 中所述基本上是读取我们从照片库/ Assets 库中获得的视频,然后以不同的比特率写入它以减小其大小(用于最终的网络上传)。

让这个为我们工作的技巧是在 AVAssetReaderTrackOutputoutputSettings 中指定一个 kCVPixelBufferPixelFormatTypeKey 键和值,像这样:

NSDictionary *outputSettings = [NSDictionary 
dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA]
forKey:(id)kCVPixelBufferPixelFormatTypeKey];
readerTrackOutput =
[[AVAssetReaderTrackOutput alloc] initWithTrack:src_track
outputSettings:outputSettings];

所以基本上我们为 kCVPixelBufferPixelFormatTypeKey 键使用了 kCVPixelFormatType_32BGRA 值。

但显然有许多可能的像素格式类型可供我们选择。运行 Technical Q&A QA1501: Core Video - Available Pixel Formats 中记录的代码在 iOS 6.0.1 iPhone 设备上,这是它显示的支持像素格式类型的列表:

Core Video Supported Pixel Format Types:
Core Video Pixel Format Type: 32
Core Video Pixel Format Type: 24
Core Video Pixel Format Type: 16
Core Video Pixel Format Type (FourCC): L565
Core Video Pixel Format Type (FourCC): 2vuy
Core Video Pixel Format Type (FourCC): yuvs
Core Video Pixel Format Type (FourCC): yuvf
Core Video Pixel Format Type: 40
Core Video Pixel Format Type (FourCC): L008
Core Video Pixel Format Type (FourCC): 2C08
Core Video Pixel Format Type (FourCC): r408
Core Video Pixel Format Type (FourCC): v408
Core Video Pixel Format Type (FourCC): y408
Core Video Pixel Format Type (FourCC): y416
Core Video Pixel Format Type (FourCC): BGRA
Core Video Pixel Format Type (FourCC): b64a
Core Video Pixel Format Type (FourCC): b48r
Core Video Pixel Format Type (FourCC): b32a
Core Video Pixel Format Type (FourCC): b16g
Core Video Pixel Format Type (FourCC): R10k
Core Video Pixel Format Type (FourCC): v308
Core Video Pixel Format Type (FourCC): v216
Core Video Pixel Format Type (FourCC): v210
Core Video Pixel Format Type (FourCC): v410
Core Video Pixel Format Type (FourCC): r4fl
Core Video Pixel Format Type (FourCC): grb4
Core Video Pixel Format Type (FourCC): rgg4
Core Video Pixel Format Type (FourCC): bgg4
Core Video Pixel Format Type (FourCC): gbr4
Core Video Pixel Format Type (FourCC): 420v
Core Video Pixel Format Type (FourCC): 420f
Core Video Pixel Format Type (FourCC): 411v
Core Video Pixel Format Type (FourCC): 411f
Core Video Pixel Format Type (FourCC): 422v
Core Video Pixel Format Type (FourCC): 422f
Core Video Pixel Format Type (FourCC): 444v
Core Video Pixel Format Type (FourCC): 444f
Core Video Pixel Format Type (FourCC): y420
Core Video Pixel Format Type (FourCC): f420
Core Video Pixel Format Type (FourCC): a2vy
Core Video Pixel Format Type (FourCC): L00h
Core Video Pixel Format Type (FourCC): L00f
Core Video Pixel Format Type (FourCC): 2C0h
Core Video Pixel Format Type (FourCC): 2C0f
Core Video Pixel Format Type (FourCC): RGhA
Core Video Pixel Format Type (FourCC): RGfA

尽管 kCVPixelFormatType_32BGRA 对我们有效(至少表面上如此),但我们很好奇是否有比上述列表更好的选择。我们应该如何为我们挑选正确的像素格式类型?

最佳答案

您可以尝试不同的设置并比较性能。以不同的像素格式向编码器提供缓冲区可能会导致编码性能的差异。硬件加速编码器通常使用“420v”。

另请参阅,Query for optimal pixel format when capturing video on iOS?

关于ios - 如何选择用于 AVAssetReader 的像素格式类型 (kCVPixelBufferPixelFormatTypeKey)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14191806/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com