AVAssetWriterInput does not currently support AVVideoScalingModeFit - IOS Error

心已入冬 提交于 2019-12-23 21:50:11

问题


I'm attempting to use the AVAssetWriterInput to crop a video that I read in a screencast of my application. Here is my current configuration.

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];

I'm receiving the following error: "AVAssetWriterInput does not currently support AVVideoScalingModeFit"

This is a common error for anyone using this library, but I can't find the actual solution to it. I just see people saying: "I figured it out eventually" without explaining it. The problem is definitely related to this line: "AVVideoScalingModeKey:AVVideoScalingModeResizeAspectFill," which tells the AVAssetWriter to crop the video and maintain the aspect ratio. Anyone know the solution to this?


回答1:


There is no "solution to it" per se. It's simply unsupported. You'll need to scale the video frames yourself using Core Image or a VTPixelTransferSession or whatever is appropriate for your pipeline.



来源:https://stackoverflow.com/questions/32674916/avassetwriterinput-does-not-currently-support-avvideoscalingmodefit-ios-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!