Fixed FFMPEG seeking

CQTexperiment
Chris Moeller 2013-11-14 23:28:02 -08:00
parent f56edd882e
commit 092fdda05a
1 changed files with 2 additions and 1 deletions

View File

@ -290,12 +290,13 @@ int lockmgr_callback(void ** mutex, enum AVLockOp op)
- (long)seek:(long)frame
{
if (frame > totalFrames) { return -1; }
if (frame >= totalFrames) { return -1; }
int64_t ts = frame * (formatCtx->duration) / totalFrames;
avformat_seek_file(formatCtx, -1, ts - 1000, ts, ts, AVSEEK_FLAG_ANY);
avcodec_flush_buffers(codecCtx);
readNextPacket = YES; // so we immediately read next packet
bytesConsumedFromDecodedFrame = INT_MAX; // so we immediately begin decoding next frame
framesRead = frame;
return frame;
}