首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVAssetWriterInput参数sourceFormatHint有问题

AVAssetWriterInput参数sourceFormatHint有问题
EN

Stack Overflow用户
提问于 2014-10-20 11:46:18
回答 1查看 1.6K关注 0票数 0

我正在使用AVAssetWriterInput,但sourceFormatHint参数提供了以下警告:

不兼容的整数到指针转换,将'int‘发送到'CMFormatDescriptionRef’类型的参数(又名'const *')

这是代码:

代码语言:javascript
复制
AVAssetWriterInput* videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:settings sourceFormatHint:kCMMediaType_Video];
videoWriterInput.expectsMediaDataInRealTime = YES;
videoWriterInput.transform = videoTrack.preferredTransform;
AVAssetWriter *videoWriter = [[AVAssetWriter alloc] initWithURL:outputURL fileType:@"public.mpeg-4" error:nil];
[videoWriter addInput:videoWriterInput];

我应该在sourceFormatHint中传递哪些参数

EN

回答 1

Stack Overflow用户

发布于 2014-12-16 08:08:13

你好,见下面的setUP,它为我工作.:)

代码语言:javascript
复制
-(BOOL) setUpWriter {
NSError* error = nil;
videoWriter = [[AVAssetWriter alloc] initWithURL:[self tempFileURL] fileType:AVFileTypeQuickTimeMovie error:&error];
NSParameterAssert(videoWriter);

//Configure video
NSDictionary* videoCompressionProps = [NSDictionary dictionaryWithObjectsAndKeys:
                                       [NSNumber numberWithDouble:1024*1024], AVVideoAverageBitRateKey,
                                       nil ];




NSDictionary* videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                               AVVideoCodecH264, AVVideoCodecKey,
                               [NSNumber numberWithInt:320.0], AVVideoWidthKey,
                               [NSNumber numberWithInt:568.0], AVVideoHeightKey,
                               videoCompressionProps, AVVideoCompressionPropertiesKey,
                               nil];
videoWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings];
// videoWriterInput =[AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo outputSettings:videoSettings sourceFormatHint:kCMMediaType_Video];

NSParameterAssert(videoWriterInput);
videoWriterInput.expectsMediaDataInRealTime = YES;
NSDictionary* bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
                                  [NSNumber numberWithInt:kCVPixelFormatType_32ARGB], kCVPixelBufferPixelFormatTypeKey, nil];

avAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:videoWriterInput sourcePixelBufferAttributes:bufferAttributes] ;

//add input
[videoWriter addInput:videoWriterInput];
[videoWriter startWriting];
[videoWriter startSessionAtSourceTime:CMTimeMake(0, 1000)];

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

https://stackoverflow.com/questions/26464929

复制
相关文章

相似问题

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