AVAssetWriterInput,无法选择视频分辨率?

时间:2011-12-06 03:17:05

标签: ios video avfoundation

无论我选择AVVideoWidthKeyAVVideoHeightKeyAVVideoCleanApertureWidthKeyAVVideoCleanApertureHeightKey,我的视频分辨率都是320x240或480x360。

我正在尝试以480p保存视频而我的所有缓冲区都是640x480,我的会话位于AVCaptureSessionPreset640x480,所有内容都是640x480,但我的输出视频仍然按比例缩小。

我正在使用AVAssetWriterInputPixelBufferAdaptor和我传递给它的CMSampleBufferRef,它是640x480。

我看了遍布Stack Overflow,但我还没有发现这个问题。 :/

1 个答案:

答案 0 :(得分:5)

我一直使用此设置并且它可以正常工作。这是一个代码示例。

self.compressionProperties = [[[NSMutableDictionary alloc] initWithObjectsAndKeys:
                               [NSNumber numberWithInt:params.bps], AVVideoAverageBitRateKey,
                               [NSNumber numberWithInt:params.keyFrameInterval],AVVideoMaxKeyFrameIntervalKey,
                               //videoCleanApertureSettings, AVVideoCleanApertureKey,
                               params.videoProfileLevel, AVVideoProfileLevelKey,
                               nil ] autorelease];

self.videoSettings = [[[NSMutableDictionary alloc] initWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,
                       [NSNumber numberWithInt:params.outWidth], AVVideoWidthKey,
                       [NSNumber numberWithInt:params.outHeight], AVVideoHeightKey, 
                       self.compressionProperties, AVVideoCompressionPropertiesKey,
                       nil] autorelease];

...

wobj.writerInput = [[[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:self.videoSettings] autorelease];