-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
when saving mov(recorded by iphone, sample mov file downloaded from internet works fine) file the result is laggy.
frame shows for 2sec pause for 0.1 sec again frame show for 2 sec repeat until end
i saw the code inside cge.framework.
maybe modifying below codes can help to solve my issue,
but dont know exactly what and how to modify it
- (BOOL)readNextVideoFrameFromOutput
{
if(_readerVideoTrackOutput)
{
if(_videoAssetReader.status == AVAssetReaderStatusReading)
{
CMSampleBufferRef sampleBufferRef = [_readerVideoTrackOutput copyNextSampleBuffer];
if(sampleBufferRef)
{
CMTime currentSampleTime = CMSampleBufferGetOutputPresentationTimeStamp(sampleBufferRef);
if (_playAtActualSpeed)
{
CMTime differenceFromLastFrame = CMTimeSubtract(currentSampleTime, _prevFrameTime);
CFAbsoluteTime currentActualTime = CFAbsoluteTimeGetCurrent();
CGFloat frameTimeDifference = CMTimeGetSeconds(differenceFromLastFrame);
CGFloat actualTimeDifference = currentActualTime - _prevActualFrameTime;
if (frameTimeDifference > actualTimeDifference)
{
usleep(1000000.0 * (frameTimeDifference - actualTimeDifference));
}
_prevFrameTime = currentSampleTime;
_prevActualFrameTime = CFAbsoluteTimeGetCurrent();
}
if(s_fpsLimit > 0)
{
double currTime = CMTimeGetSeconds(currentSampleTime);
int maxFrameForNow = currTime * s_fpsLimit + 5;
if(s_fpsCount > maxFrameForNow)
{
ShopliveFilterSDK_NSLog(@"Too many frames, skip...");
CFRelease(sampleBufferRef);
return YES;
}
else
{
++s_fpsCount;
}
}
CVImageBufferRef movieFrame = CMSampleBufferGetImageBuffer(sampleBufferRef);
[self processVideoFrame:movieFrame sampleTime:currentSampleTime lastTime:_procFrameTime];
_procFrameTime = currentSampleTime;
CFRelease(sampleBufferRef);
return YES;
}
else
{
_readerVideoTrackOutput = nil;
}
}
}
return NO;
}Metadata
Metadata
Assignees
Labels
No labels