From eec8e38ec267c15e8234d125acad6226fd024d31 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Fri, 26 Sep 2014 09:35:38 -0500 Subject: [PATCH] Fixed more seek issues --- src/FFmpegReader.cpp | 21 +++++++++------------ src/Main.cpp | 6 +++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index 1e7814da..17dc0704 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -682,20 +682,17 @@ bool FFmpegReader::CheckSeek(bool is_video) if ((is_video_seek && !seek_video_frame_found) || (!is_video_seek && !seek_audio_frame_found)) return false; - // CHECK VIDEO SEEK? - int current_pts = 0; - if (is_video && is_video_seek) - current_pts = GetVideoPTS(); - // CHECK AUDIO SEEK? - else if (!is_video && !is_video_seek) - current_pts = packet->pts; + // Determine max seeked frame + int max_seeked_frame = seek_audio_frame_found; // determine max seeked frame + if (seek_video_frame_found > max_seeked_frame) + max_seeked_frame = seek_video_frame_found; // determine if we are "before" the requested frame - if (current_pts > seeking_pts) + if (max_seeked_frame >= seeking_frame) { // SEEKED TOO FAR #pragma omp critical (debug_output) - AppendDebugMethod("FFmpegReader::CheckSeek (Too far, seek again)", "current_pts", current_pts, "seeking_pts", seeking_pts, "seeking_frame", seeking_frame, "", -1, "", -1, "", -1); + AppendDebugMethod("FFmpegReader::CheckSeek (Too far, seek again)", "is_video_seek", is_video_seek, "current_pts", packet->pts, "seeking_pts", seeking_pts, "seeking_frame", seeking_frame, "seek_video_frame_found", seek_video_frame_found, "seek_audio_frame_found", seek_audio_frame_found); // Seek again... to the nearest Keyframe Seek(seeking_frame - 10); @@ -704,7 +701,7 @@ bool FFmpegReader::CheckSeek(bool is_video) { // SEEK WORKED #pragma omp critical (debug_output) - AppendDebugMethod("FFmpegReader::CheckSeek (Successful)", "current_pts", current_pts, "seeking_pts", seeking_pts, "seeking_frame", seeking_frame, "", -1, "", -1, "", -1); + AppendDebugMethod("FFmpegReader::CheckSeek (Successful)", "is_video_seek", is_video_seek, "current_pts", packet->pts, "seeking_pts", seeking_pts, "seeking_frame", seeking_frame, "seek_video_frame_found", seek_video_frame_found, "seek_audio_frame_found", seek_audio_frame_found); // Seek worked, and we are "before" the requested frame is_seeking = false; @@ -1390,8 +1387,8 @@ bool FFmpegReader::IsPartialFrame(int requested_frame) { int max_seeked_frame = seek_audio_frame_found; // determine max seeked frame if (seek_video_frame_found > max_seeked_frame) max_seeked_frame = seek_video_frame_found; - if ((info.has_audio && seek_audio_frame_found && max_seeked_frame > requested_frame) || - (info.has_video && seek_video_frame_found && max_seeked_frame > requested_frame)) + if ((info.has_audio && seek_audio_frame_found && max_seeked_frame >= requested_frame) || + (info.has_video && seek_video_frame_found && max_seeked_frame >= requested_frame)) seek_trash = true; return seek_trash; diff --git a/src/Main.cpp b/src/Main.cpp index 8b07ecb3..9fbb795f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -60,11 +60,11 @@ int main(int argc, char* argv[]) //f->AddOverlayNumber(frame_number); //f->Display(); - if (x == 32) + //if (x == 7654) sinelReader.debug = true; - if (x == 50) - break; + //if (x == 7655) + // break; } cout << sinelReader.OutputDebugJSON() << endl;