AVAssetWriterInput当前不支持AVVideoScalingModeFit – IOS错误
我正在尝试使用AVAssetWriterInput裁剪我在应用程序的截屏video中读取的video。 这是我目前的配置。
NSDictionary *videoCleanApertureSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:320], AVVideoCleanApertureWidthKey, [NSNumber numberWithInt:480], AVVideoCleanApertureHeightKey, [NSNumber numberWithInt:10], AVVideoCleanApertureHorizontalOffsetKey, [NSNumber numberWithInt:10], AVVideoCleanApertureVerticalOffsetKey, nil]; NSDictionary *videoAspectRatioSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:3], AVVideoPixelAspectRatioHorizontalSpacingKey, [NSNumber numberWithInt:3],AVVideoPixelAspectRatioVerticalSpacingKey, nil]; NSDictionary *codecSettings = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:960000], AVVideoAverageBitRateKey, [NSNumber numberWithInt:1],AVVideoMaxKeyFrameIntervalKey, videoCleanApertureSettings, AVVideoCleanApertureKey, videoAspectRatioSettings, AVVideoPixelAspectRatioKey, AVVideoProfileLevelH264BaselineAutoLevel, AVVideoProfileLevelKey, nil]; NSDictionary *videoSettings = @{AVVideoCodecKey:AVVideoCodecH264, AVVideoCompressionPropertiesKey:codecSettings, AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill, AVVideoWidthKey:[NSNumber numberWithInt:320], AVVideoHeightKey:[NSNumber numberWithInt:480]}; _videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
我收到以下错误:“AVAssetWriterInput目前不支持AVVideoScalingModeFit”
这是使用此库的任何人的常见错误,但我无法找到它的实际解决方案。 我只是看到有人说:“我最终想出来了”而没有解释。 问题肯定与这一行有关:“AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill”,它告诉AVAssetWriter裁剪video并保持宽高比。 有人知道解决方案吗?
它本身没有“解决方案”。 它根本不受支持。 您需要使用Core Image或VTPixelTransferSession或适合您的管道的任何内容自行缩放video帧。