使用随机到达的 UIImages 进行 IOS 视频录制
Posted
技术标签:
【中文标题】使用随机到达的 UIImages 进行 IOS 视频录制【英文标题】:IOS Video recording using UIImages arriving at random times 【发布时间】:2013-03-09 18:12:22 【问题描述】:我正在开发一个 ios 应用程序,它从互联网连接随机获取 UIImages,并在图像进入时逐步从它们构建一个视频文件。我让它工作了一点,但图像没有到达的事实以相同的速度一直在弄乱视频。
当每个新的 UIImage 到达时,我如何重新计算 CMTime,以便它针对到达的 UIImage 的不同帧速率进行调整,这些帧速率可以在毫秒到秒之间的任何时间到达??
这是我到目前为止所做的,一些代码没有显示,但这是基本的东西
.
.
adaptor = [AVAssetWriterInputPixelBufferAdaptor
assetWriterInputPixelBufferAdaptorWithAssetWriterInput: videoStream
sourcePixelBufferAttributes:attributes];
CMTime frameTime=CMTimeMake(1,10); // assumed initial frame rate
.
.
-(void)addImageToMovie:(UIImage*)img
append_ok=FALSE;
buffer = [self pixelBufferFromCGImage:[img CGImage] andSize:img.size];
while (!append_ok)
if (adaptor.assetWriterInput.readyForMoreMediaData)
frameTime.value +=1;
append_ok = [adaptor appendPixelBuffer:buffer withPresentationTime:frameTime];
[NSThread sleepForTimeInterval:0.01];
else
[NSThread sleepForTimeInterval:0.01];
if(buffer)
CVBufferRelease(buffer);
【问题讨论】:
【参考方案1】:这取决于帧数。不是加 1,而是将 10 加到 frameTime.value。
【讨论】:
以上是关于使用随机到达的 UIImages 进行 IOS 视频录制的主要内容,如果未能解决你的问题,请参考以下文章