Skip to content

Instantly share code, notes, and snippets.

@hiroMTB
Created January 15, 2016 21:39
Show Gist options
  • Save hiroMTB/26eaa40424e9a0ba3689 to your computer and use it in GitHub Desktop.
Save hiroMTB/26eaa40424e9a0ba3689 to your computer and use it in GitHub Desktop.
// QuickTimeImplAvf.mm
// line 296
void MovieBase::seekToFrame( int frame )
{
if( ! mPlayer )
return;
//CMTime currentTime = [mPlayer currentTime];
//CMTime oneFrame = CMTimeMakeWithSeconds(1.0 / mFrameRate, currentTime.timescale); // ERROR, timescale=1
// Plan A : Get correct timescale
CMTime oneFrame = CMTimeMakeWithSeconds(1.0 / mFrameRate, mPlayer.currentItem.asset.duration.timescale );
// plan B : set timescale 600 manualy
//CMTime oneFrame = CMTimeMakeWithSeconds(1.0 / mFrameRate, 600 );
// plan C : Use frameRate
//CMTime oneFrame = CMTimeMake(1, 20);
CMTime startTime = kCMTimeZero;
CMTime addedFrame = CMTimeMultiply(oneFrame, frame);
CMTime added = CMTimeAdd(startTime, addedFrame);
[mPlayer seekToTime:added toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
}
@hiroMTB
Copy link
Author

hiroMTB commented Jan 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment