AVAssetWriterInput 当前不支持 AVVideoScalingModeFit - IOS 错误
AVAssetWriterInput does not currently support AVVideoScalingModeFit - IOS Error
我正在尝试使用 AVAssetWriterInput 裁剪我在应用程序的截屏视频中阅读的视频。这是我当前的配置。
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 does not currently support AVVideoScalingModeFit"
对于使用此库的任何人来说,这是一个常见错误,但我找不到真正的解决方案。我只看到有人说:"I figured it out eventually" 没有解释。问题肯定与此行有关: "AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill," 告诉 AVAssetWriter 裁剪视频并保持纵横比。有人知道解决这个问题的方法吗?
本身没有"solution to it"。它根本不受支持。您需要使用 Core Image 或 VTPixelTransferSession 或任何适合您的管道的内容自行缩放视频帧。
我正在尝试使用 AVAssetWriterInput 裁剪我在应用程序的截屏视频中阅读的视频。这是我当前的配置。
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 does not currently support AVVideoScalingModeFit"
对于使用此库的任何人来说,这是一个常见错误,但我找不到真正的解决方案。我只看到有人说:"I figured it out eventually" 没有解释。问题肯定与此行有关: "AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill," 告诉 AVAssetWriter 裁剪视频并保持纵横比。有人知道解决这个问题的方法吗?
本身没有"solution to it"。它根本不受支持。您需要使用 Core Image 或 VTPixelTransferSession 或任何适合您的管道的内容自行缩放视频帧。