@@ -908,11 +908,6 @@ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
908908
909909 // The semantics here are basically "return true if we don't know exactly where our seek ended up (destination isn't frame 0)"
910910 if (SeekMode >= 0 ) {
911- int TargetFrame = n + SeekOffset;
912- if (TargetFrame < 0 )
913- throw FFMS_Exception (FFMS_ERROR_SEEKING, FFMS_ERROR_UNKNOWN,
914- " Frame accurate seeking is not possible in this file" );
915-
916911 // Seeking too close to the end of the stream can result in a different decoder delay since
917912 // frames are returned as soon as draining starts, so avoid this to keep the delay predictable.
918913 // Is the +1 necessary here? Not sure, but let's keep it to be safe.
@@ -923,7 +918,7 @@ bool FFMS_VideoSource::SeekTo(int n, int SeekOffset) {
923918 // close to the end in open-gop files: https://trac.ffmpeg.org/ticket/10936
924919 EndOfStreamDist *= 2 ;
925920
926- TargetFrame = std::min (TargetFrame , Frames.RealFrameNumber (std::max (0 , VP.NumFrames - 1 - EndOfStreamDist)));
921+ int TargetFrame = std::clamp (n + SeekOffset, 0 , Frames.RealFrameNumber (std::max (0 , VP.NumFrames - 1 - EndOfStreamDist)));
927922
928923 if (SeekMode < 3 )
929924 TargetFrame = Frames.FindClosestVideoKeyFrame (TargetFrame);
@@ -997,7 +992,6 @@ FFMS_Frame *FFMS_VideoSource::GetFrame(int n) {
997992 // Is the seek destination time known? Does it belong to a frame?
998993 if (CurrentFrame < 0 ) {
999994 if (SeekMode == 1 || StartTime < 0 ) {
1000- // No idea where we are so go back a bit further
1001995 SeekOffset -= 10 ;
1002996 Seek = true ;
1003997 continue ;
0 commit comments