【问题标题】:IOS Video recording using UIImages arriving at random times使用随机到达的 UIImages 进行 IOS 视频录制
【发布时间】: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);
     }
  }

【问题讨论】:

    标签: ios video uiimage recording


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多