我正在尝试使用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目前不支持AVVideoScalingModeFit“
对于任何使用这个库的人来说,这是一个常见的错误,但是我找不到它的实际解决方案。我只是看到人们说:“我终于想出来了”,但没有解释。这个问题肯定与这一行有关:"AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill,“,它告诉AVAssetWriter裁剪视频并保持高宽比。有人知道解决这个问题的办法吗?
发布于 2017-12-12 23:47:20
就其本身而言,没有“解决办法”。这根本是不支持的。您将需要自己缩放视频帧使用核心图像或VTPixelTransferSession或任何适合您的管道。
https://stackoverflow.com/questions/32674916
复制相似问题