我正在从一系列图片中创建视频。我的工作目的是创建一个没有压缩的.mov视频。我在开发人员库中看到它存在一个键“AVVideoCompressionPropertiesKey”,但我不知道如何使用此键指定不压缩。
你能帮我吗?
以下是我的示例代码:
NSDictionary *videoCleanApertureSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:320], AVVideoCleanApertureWidthKey,
[NSNumber numberWithInt:480], AVVideoCleanApertureHeightKey,
[NSNumber numberWithInt:10], AVVideoCleanApertureHorizontalOffsetKey,
[NSNumber numberWithInt:10], AVVideoCleanApertureVerticalOffsetKey,
nil];
NSDictionary *codecSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:960000], AVVideoAverageBitRateKey,
[NSNumber numberWithInt:1],AVVideoMaxKeyFrameIntervalKey,
videoCleanApertureSettings, AVVideoCleanApertureKey,
nil];
NSDictionary *videoOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:AVVideoCodecH264, AVVideoCodecKey,codecSettings,AVVideoCompressionPropertiesKey, [NSNumber numberWithInt:size.width], AVVideoWidthKey,
[NSNumber numberWithInt:size.height], AVVideoHeightKey, nil];
self.videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoOutputSettings];
答案 0 :(得分:3)
尝试使用AVVideoCodecJPEG,并将AVVideoQualityKey值设置为NSNumber 1.0。另一种方法是指定H264,将比特率设置为非常高的值,并指定关键帧间隔为1(即所有关键帧)。
答案 1 :(得分:1)
该密钥不用于禁用压缩,是为某些编解码器指定特定的压缩值,如jpg或h264 .I.e。
[videoSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
nil]];
NSMutableDictionary* videoCompressionSettings = [NSMutableDictionary dictionary];
if ([[Preferences instance] recordingH264Keyframes] > 0) {
[videoCompressionSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:[[Preferences instance] recordingH264Keyframes]], AVVideoMaxKeyFrameIntervalKey,
nil]];
}
if ([[Preferences instance] recordingH264Bitrate] > 0) {
[videoCompressionSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:[[Preferences instance] recordingH264Bitrate]*1000], AVVideoAverageBitRateKey,
nil]];
}
if ([videoCompressionSettings count]) {
[videoSettings addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:videoCompressionSettings,AVVideoCompressionPropertiesKey,nil]];
}
答案 2 :(得分:0)
ProRes4444视频编解码器是Apple提供给未压缩编解码器的最接近的东西。此编解码器在iOS上不可用于仅编写OS X视频内容。
在iOS上无法导出未压缩的视频内容。