翻译:AVAssetReaderTrackOutput

来源:互联网 发布:商为开店软件 编辑:程序博客网 时间:2024/06/05 08:22

AVAssetReaderTrackOutput定义了从一个单一AVAssetTrack对象中读取媒体数据的接口。

Overview

1.你可以使用AVAssetReader的addOutput:方法添加一个AVAssetReaderTrackOutput实例到一个asset reader中,这样就可以读取一个asset track的媒体数据。这个track里面的采样值可以以原来保存的格式被读取出来,也可以转换为不同的格式。

2.AVAssetReaderTrackOutput只能够输出未压缩的输出。对于音频输出设置,这意味着 AVFormatIDKey必须是kAudioFormatLinearPCM。对于视频输出设置,这意味着dictionary 必须保存未压缩的视频输出设置,这些设置定义在Video_Settings中。AVAssetReaderTrackOutput不支持AVSampleRateConverterAudioQualityKey key 或下面的Video_Settings :keys: AVVideoCleanApertureKey, AVVideoPixelAspectRatioKey, AVVideoScalingModeKey, or the AVVideoColorPropertiesKey key.

3.当我们构造video output settings时, pixel format的选择将影响解码的性能和质量。为了优化解码视频时的性能,像素的格式应该是解码器原本支持的格式,这样避免不必要的转换。Below are some recommendations:
For H.264 use kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, or kCVPixelFormatType_420YpCbCr8BiPlanarFullRange if the video is known to be full range.

On iOS use kCVPixelFormatType_420YpCbCr8BiPlanarFullRange for JPEG output.

For other codecs in macOS, kCVPixelFormatType_422YpCbCr8 is the preferred pixel format for video and generally provides the best performance when decoding. If you need to work in the RGB domain it is recommended that on iOS the kCVPixelFormatType_32BGRA value is used, and in macOS kCVPixelFormatType_32ARGB is recommended.

ProRes encoded media can contain up to 12bits/ch. If your source is ProRes encoded and you wish to preserve more than 8bits/ch during decompression then use one of the following pixel formats: kCVPixelFormatType_4444AYpCbCr16, kCVPixelFormatType_422YpCbCr16, kCVPixelFormatType_422YpCbCr10, or kCVPixelFormatType_64ARGB. AVAssetReader does not support scaling with any of these high bit depth pixel formats. If you use them then do not specify kCVPixelBufferWidthKey or kCVPixelBufferHeightKey in the outputSettings dictionary. If you plan to append these sample buffers to an AVAssetWriterInput then note that only the ProRes encoders support these pixel formats.

ProRes 4444 encoded media can contain a mathematically lossless alpha channel. To preserve the alpha channel during decompression use a pixel format with an alpha component such as kCVPixelFormatType_4444AYpCbCr16 or kCVPixelFormatType_64ARGB. To test whether your source contains an alpha channel check that the track’s format description has a kCMFormatDescriptionExtension_Depth key and that its value is 32.

原创粉丝点击