- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我在 AVAssetWriterInputPixelBufferAdaptor 中使用 pixelBufferPool 来创建像素缓冲区以与 append 方法一起使用。创建4个buffer后,pixelBufferPool属性变为NULL;
我这样设置我的编写器、输入和适配器:
- (BOOL) setupRecorder {
NSError *error = nil;
if([[NSFileManager defaultManager] fileExistsAtPath:[[self tempFileURL] path]])
[[NSFileManager defaultManager] removeItemAtURL:[self tempFileURL] error:&error];
assetWriter = [[AVAssetWriter alloc] initWithURL: [self tempFileURL]
fileType:AVFileTypeQuickTimeMovie
error:&error];
if (error) {
NSLog(@"Error creating asset writer: %@", error);
[assetWriter release];
return NO;
}
// writer
NSDictionary *videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:
AVVideoCodecH264, AVVideoCodecKey,
[NSNumber numberWithInt:videoWidth], AVVideoWidthKey,
[NSNumber numberWithInt:videoHeight], AVVideoHeightKey,
nil];
assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeVideo
outputSettings:videoSettings];
NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kCVPixelFormatType_32BGRA], kCVPixelBufferPixelFormatTypeKey,
nil];
adaptor = [[AVAssetWriterInputPixelBufferAdaptor alloc] initWithAssetWriterInput:assetWriterInput sourcePixelBufferAttributes:bufferAttributes];
[adaptor retain];
assetWriterInput.expectsMediaDataInRealTime = YES;
[assetWriter addInput:assetWriterInput];
return YES;
}
我用这个分发像素缓冲区:
- (CVPixelBufferRef) createPixelBufferRef {
CVPixelBufferPoolRef pixelBufferPool = adaptor.pixelBufferPool;
CVPixelBufferRef pixelBuffer = NULL;
CVReturn cvReturn = CVPixelBufferPoolCreatePixelBuffer(NULL, pixelBufferPool, &pixelBuffer);
if(cvReturn != kCVReturnSuccess)
NSLog(@"CVPixelBuffePoolCreatePixelBuffer: %d", cvReturn);
bufferCreatedCount++;
return pixelBuffer;
}
当我完成将像素缓冲区传递给 appendPixelBuffer 后,我使用 CVPixelBufferRelease 释放像素缓冲区。在变为 NULL 之前,我绝不会调用 markAsFinished、endSessionAtSourceTime 或 finishWriting。此外,适配器本身不会变为 NULL。
我读过的大多数帖子都谈到由于适配器配置错误而从一开始就没有池,但我的有,但时间很短。还有其他人看到这种行为吗?
最佳答案
我遇到了同样的问题。正如我发现的那样,如果您放入 appendPixelBuffer:withPresentationTime:
的一些 CMTime
相等,就会发生这种情况。例如,如果您使用的 CMTimeMakeWithSeconds
的时间刻度太粗略,就会发生这种情况。
关于ios - 一段时间后 AVAssetWriterInputPixelBufferAdaptor pixelBufferPool 变为 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6414138/
我使用下面的代码将图像写入视频 -(void) writeImagesToMovieAtPath:(NSString *) path withSize:(CGSize) size { NSLo
我确定我的缓冲区属性有问题,但我不清楚是什么 -- 没有很好地记录应该去那里的内容,所以我猜测基于 CVPixelBufferPoolCreate -- Core Foundation 对我来说几乎是
我正在尝试制作一个应用程序来记录 UIImageView 的内容以及麦克风音频,并将它们实时记录到视频中。 (有点像会说话的汤姆猫应用程序) 我正在使用 AVAssetWriterInputPixel
我正在捕捉相机画面并将其写入电影。我遇到的问题是,在导出电影之后,它前面有几秒钟的黑色(相对于实际录制开始时间)。 我认为这与[self.assetWriter startSessionAtSourc
我将 CVPixelBufferRefs 附加到连接到 AVAssetWriterInput 的 AVAssetWriterInputPixelBufferAdaptor 以使用 AVAssetWri
我正在尝试以预期的帧速率将 CVPixelBuffers 附加到 AVAssetWriterInputPixelBufferAdaptor,但它似乎太快了,而且我的数学失败了。这不是从相机捕捉,而是捕
我正在使用 AVAssetWriterInputPixelBufferAdaptor 将一些帧写入视频,并且行为 w.r.t.时间不是我所期望的。 如果我只写一帧: [videoWriter sta
我正在尝试使用为 encoding asset writer 提供的示例的组合。以及 pixelBufferFromCGImage 提供的样本在我正在导出的 AVAsset 上覆盖 UIImage。
我在 AVAssetWriterInputPixelBufferAdaptor 中使用 pixelBufferPool 来创建像素缓冲区以与 append 方法一起使用。创建4个buffer后,pix
我正在从一组图像创建一个视频文件。我能够在模拟器上创建视频文件,但是当我尝试在设备上运行相同的代码时,它会出现以下错误: NSURLErrorDomain Code=-3000 "Cannot cre
我已经使用以下代码成功地从图像创建了视频 -(void)writeImageAsMovie:(NSArray *)array toPath:(NSString*)path size:(CGSize)s
我正在尝试使用 ReplayKit 记录我的应用程序的屏幕,在录制视频时裁剪掉其中的某些部分。不太顺利。 ReplayKit 将捕获整个屏幕,因此我决定从 ReplayKit 接收每一帧(作为 CMS
我是一名优秀的程序员,十分优秀!