作者热门文章
- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试使用 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 裁剪视频并保持纵横比。有人知道解决这个问题的方法吗?
最佳答案
本身没有“解决方案”。它根本不受支持。您需要使用 Core Image 或 VTPixelTransferSession 或任何适合您的管道的内容自行缩放视频帧。
关于ios - AVAssetWriterInput 当前不支持 AVVideoScalingModeFit - IOS 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32674916/
我正在尝试使用 AVAssetWriterInput 裁剪我在应用程序的截屏视频中阅读的视频。这是我当前的配置。 NSDictionary *videoCleanApertureSettings =
我是一名优秀的程序员,十分优秀!