我已经使用AVCaptureVideoDataOuputAVAssetWriter从摄像机录制了实时视频,但是生成的视频没有持续时间。任何人都可以给出简短的想法或大致方向来使持续时间发挥作用吗?

最佳答案

需要做的是定义一个初始CMTime

self.time = CMMakeTime( 0, 30 /* some frame time */ );


然后

[instanceAVAssetWriter setSessionAtSourceTime:self.time];


captureOutput:didOutputSampleBuffer:fromConnection:

CMSampleBufferRef sb;
CMSampleTimingInfo sampleTimingInfo;

sampleTimingInfo.duration = CMTimeMake(1,30);
sampleTimingInfo.presentationTimeStamp = self.time;
sampleTimingInfo.decodeTimeStamp = kCMTimeInvalid;

CMSampleBufferCreateCopyWithNewTiming(kCFAllocatorDefault, sampleBuffer, 1, &sampleTimingInfo, &sb);


最后

CFRelease( sb );
self.time.value += 1;

关于objective-c - 视频播放后未显示持续时间,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10640879/

10-09 18:31