谁能帮我解决这个问题?我可以使用具有以下输出设置的 AVAssetWriter 对视频进行编码。
NSDictionary *videoCompressionSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInteger:dimensions.width], AVVideoWidthKey,
[NSNumber numberWithInteger:dimensions.height], AVVideoHeightKey,
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:bitsPerSecond], AVVideoAverageBitRateKey,
[NSNumber numberWithInteger:30],AVVideoMaxKeyFrameIntervalKey,
nil], AVVideoCompressionPropertiesKey,
nil];
但是,当我尝试通过指定配置文件进行编码时说 AVVideoProfileLevelH264Baseline30 之后的输出设置看起来像
NSDictionary *videoCompressionSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInteger:dimensions.width], AVVideoWidthKey,
[NSNumber numberWithInteger:dimensions.height], AVVideoHeightKey,
[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInteger:bitsPerSecond], AVVideoAverageBitRateKey,
[NSNumber numberWithInteger:30],AVVideoMaxKeyFrameIntervalKey,
AVVideoProfileLevelH264Baseline30,AVVideoProfileLevelKey,
nil], AVVideoCompressionPropertiesKey,
nil];
我的视频录制因这些设置而失败。
那么我的问题在哪里?我已经像这样初始化了资产编写器
_assetWriter = [[AVAssetWriter alloc] initWithURL:_movieURL fileType:AVFileTypeMPEG4 error:&error];