void demuxPackets(CancellationToken token) { audioFrameTimer = videoFrameTimer = HRTimer.getTimestamp(); bool success = true; // decode frames one by one, or handle seek requests do { if (seekRequest == true) { // wait for video and audio decoding to pause/block // To make sure no packets are in limbo // before flushing any ffmpeg internal or external queues. videoDecoder.FrameQueue.pause(); if (videoDecoder.seek(seekPosition) == true) { // flush the framequeue and audioplayer buffer videoDecoder.FrameQueue.flush(); audioPlayer.flush(); // refill/buffer the framequeue from the new position fillFrameQueue(); audioFrameTimer = videoFrameTimer = HRTimer.getTimestamp(); } seekRequest = false; // allow video and audio decoding to continue videoDecoder.FrameQueue.start(); } else { success = videoDecoder.demuxPacket(); } } while (success == true && !token.IsCancellationRequested); }