首页 文章

使用UIImages随机时间到达的IOS视频录制

提问于
浏览
0

我正在开发一个iOS应用程序,它可以从互联网连接中随机获取UIImages,并在图像进入时逐步构建一个视频文件 . 我让它工作了一点,但事实上图像没有达到相同的程度率一直在弄乱视频 .

如何在每个新的UIImage到达时重新计算CMTime,以便根据到达的UIImages的变化帧速率进行调整,这些帧速率可以从几毫秒到几秒之间到达?

这是我到目前为止所做的,一些代码没有显示,但这是基本的东西

.
.
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 回答

  • 0

    这取决于帧数 . 而不是添加1,将10添加到frameTime.value .

相关问题