我正在用 AVAssetWriterInputPixelBufferAdaptor
为视频写一些帧,行为是w.r.t.时间不是't what I'期待 .
如果我只写一帧:
[videoWriter startSessionAtSourceTime:kCMTimeZero];
[adaptor appendPixelBuffer:pxBuffer withPresentationTime:kCMTimeZero];
这给我一个长度为零的视频,这是我所期待的 .
但是,如果我继续添加第二帧:
// 3000/600 = 5 sec, right?
CMTime nextFrame = CMTimeMake(3000, 600);
[adaptor appendPixelBuffer:pxBuffer withPresentationTime:nextFrame];
我得到十秒的视频,我期待五个 .
这里发生了什么? withPresentationTime
以某种方式设置帧的开始和持续时间吗?
请注意,我不是在调用 endSessionAtSourceTime
,只是 finishWriting
.
2 回答
尝试查看此示例并进行逆向工程以在5秒后添加1帧...
以下是示例代码链接:git@github.com:RudyAramayo / AVAssetWriterInputPixelBufferAdaptorSample.git
这是您需要的代码:
你有没有尝试过这个作为你的第一个电话