无论我选择AVVideoWidthKey
,AVVideoHeightKey
,AVVideoCleanApertureWidthKey
,AVVideoCleanApertureHeightKey
,我的视频分辨率都是320x240或480x360。
我正在尝试以480p保存视频而我的所有缓冲区都是640x480,我的会话位于AVCaptureSessionPreset640x480
,所有内容都是640x480,但我的输出视频仍然按比例缩小。
我正在使用AVAssetWriterInputPixelBufferAdaptor
和我传递给它的CMSampleBufferRef
,它是640x480。
我看了遍布Stack Overflow,但我还没有发现这个问题。 :/
答案 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];