I have recorded live video from the camera using AVCaptureVideoDataOuput
and AVAssetWriter
but the resulting video has no duration. Can anyone give a brief idea or a point in the general direction to get the duration working?
What needs to be done is define an initial CMTime
.
self.time = CMMakeTime( 0, 30 /* some frame time */ );
then
[instanceAVAssetWriter setSessionAtSourceTime:self.time];
on 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);
and the end
CFRelease( sb );
self.time.value += 1;