diff --git a/src/output/output.cpp b/src/output/output.cpp index 03d8169e..b1a52f57 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -75,7 +75,6 @@ namespace Mist{ needsLookAhead = 0; lastStats = 0; maxSkipAhead = 7500; - minSkipAhead = 5000; uaDelay = 10; realTime = 1000; lastRecv = Util::epoch(); @@ -856,6 +855,7 @@ namespace Mist{ /// It seeks to the last sync'ed keyframe of the main track, no closer than needsLookAhead+minKeepAway ms from the end. /// Aborts if not live, there is no main track or it has no keyframes. bool Output::liveSeek(){ + static uint32_t seekCount = 2; unsigned long long seekPos = 0; if (!myMeta.live){return false;} long unsigned int mainTrack = getMainSelectedTrack(); @@ -865,14 +865,10 @@ namespace Mist{ if (!mainTrk.keys.size()){return false;} uint32_t minKeepAway = mainTrk.minKeepAway; - //Only skip forward if we can win at least 500ms - if (thisPacket.getTime() + 500 > mainTrk.keys.rbegin()->getTime()){ - return false; - } - for (std::deque::reverse_iterator it = myMeta.tracks[mainTrack].keys.rbegin(); it != myMeta.tracks[mainTrack].keys.rend(); ++it){ seekPos = it->getTime(); - if(seekPos <= thisPacket.getTime()){return false;} + //Only skip forward if we can win a decent amount + if(seekPos <= thisPacket.getTime() + 250*seekCount){break;} bool good = true; //check if all tracks have data for this point in time for (std::set::iterator ti = selectedTracks.begin(); ti != selectedTracks.end(); ++ti){ @@ -891,7 +887,8 @@ namespace Mist{ } //if yes, seek here if (good){ - INFO_MSG("Skipping forward %llums (%u ms LA, %lu ms mKA)", seekPos - thisPacket.getTime(), needsLookAhead, mainTrk.minKeepAway); + INFO_MSG("Skipping forward %llums (%u ms LA, %lu ms mKA, > %lums)", seekPos - thisPacket.getTime(), needsLookAhead, mainTrk.minKeepAway, seekCount*250); + if (seekCount < 20){++seekCount;} seek(seekPos); return true; } @@ -999,7 +996,7 @@ namespace Mist{ if (realTime){ uint8_t i = 6; while (--i && thisPacket.getTime() > (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime && keepGoing()){ - Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+minSkipAhead)/realTime, 1000llu)); + Util::sleep(std::min(thisPacket.getTime() - (((Util::getMS() - firstTime)*1000)+maxSkipAhead)/realTime, 1000llu)); stats(); } } diff --git a/src/output/output.h b/src/output/output.h index 36b8f124..269e79d5 100644 --- a/src/output/output.h +++ b/src/output/output.h @@ -119,7 +119,6 @@ namespace Mist { //stream delaying variables unsigned int maxSkipAhead;///< Maximum ms that we will go ahead of the intended timestamps. - unsigned int minSkipAhead;///< Minimum ms that we will go ahead of the intended timestamps. unsigned int realTime;///< Playback speed in ms of data per second. eg: 0 is infinite, 1000 real-time, 5000 is 0.2X speed, 500 = 2X speed. uint32_t needsLookAhead;///< Amount of millis we need to be able to look ahead in the metadata diff --git a/src/output/output_progressive_mp4.cpp b/src/output/output_progressive_mp4.cpp index ed9c6a74..24ddffb1 100644 --- a/src/output/output_progressive_mp4.cpp +++ b/src/output/output_progressive_mp4.cpp @@ -735,7 +735,6 @@ namespace Mist { //max lead time is set in MS, but the variable is in integer seconds for simplicity. if (H.GetVar("buffer") != "") { maxSkipAhead = JSON::Value(H.GetVar("buffer")).asInt() * 1000; - minSkipAhead = maxSkipAhead - std::min(2500u, maxSkipAhead / 2); } //allow setting of play back rate through buffer variable. //play back rate is set in MS per second, but the variable is a simple multiplier. diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index f6160eb0..7bdfcadf 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -126,7 +126,6 @@ namespace Mist{ } maxSkipAhead = 1500; - minSkipAhead = 500; } bool OutRTMP::listenMode(){ diff --git a/src/output/output_rtsp.cpp b/src/output/output_rtsp.cpp index aa842f7d..b1109e52 100644 --- a/src/output/output_rtsp.cpp +++ b/src/output/output_rtsp.cpp @@ -25,7 +25,6 @@ namespace Mist{ pausepoint = 0; setBlocking(false); maxSkipAhead = 0; - minSkipAhead = 0; expectTCP = false; lastTimeSync = 0; mainConn = &myConn;