Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

seek-workaround #249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/video/video_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,14 @@ bool VideoReader::Seek(int64_t pos) {
// final try if all above seek fails
ret = av_seek_frame(fmt_ctx_.get(), actv_stm_idx_, pos, AVSEEK_FLAG_BACKWARD | AVSEEK_FLAG_FRAME);
}
if (ret < 0) LOG(WARNING) << "Failed to seek file to position: " << pos;
if (ret < 0) {
// final try if all above seek fails
pos = pos + 1;
ts = FrameToPTS(pos);
ret = av_seek_frame(fmt_ctx_.get(), actv_stm_idx_, ts, AVSEEK_FLAG_BACKWARD);
LOG(WARNING) << "Seek pos:" << pos << " Seek Pts: " << ts << " Curr Frame: " << curr_frame_ << " Stream index:" << actv_stm_idx_;
}
if (ret < 0) LOG(WARNING) << "Failed to seek file to position: " << pos << " Ret val:" << ret;
decoder_->Start();
if (ret >= 0) {
curr_frame_ = pos;
Expand Down