首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVAssetWriter无法使用AVVideoProfileLevelKey对视频进行编码

问AVAssetWriter无法使用AVVideoProfileLevelKey对视频进行编码
EN

Stack Overflow用户
提问于 2013-08-29 15:51:55
回答 1查看 2.8K关注 0票数 3

有人能帮我解决这个问题吗?我可以使用以下输出设置使用AVAssetWriter编码视频。

代码语言:javascript
复制
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输出设置之后将如下所示

代码语言:javascript
复制
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];

使用这些设置时,我的视频录制失败。

那么我的问题在哪里呢?我已经像这样初始化了Asset writer

代码语言:javascript
复制
_assetWriter = [[AVAssetWriter alloc] initWithURL:_movieURL fileType:AVFileTypeMPEG4 error:&error];
EN

回答 1

Stack Overflow用户

发布于 2013-10-07 02:31:14

我也遇到过这样的失败。对我来说,问题只出现在OSX10.7 (Lion)上,它根本不支持AVVideoProfileLevelKey……你仍然可以使用H.264编码,但只需省略该参数,操作系统将处理选择要使用的配置文件。如果你在OSX10.8/10.9,或者iOS 4或更高版本上看到这个失败,那么你肯定有其他的问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18505140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档